From 113961fd2a2203434b03766d722a0f8c0854bfd0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 19 Jul 2012 19:29:15 +0200 Subject: WINTERMUTE: Change all folder-names to lowercase. --- engines/wintermute/base/BActiveRect.cpp | 107 + engines/wintermute/base/BActiveRect.h | 60 + engines/wintermute/base/BBase.cpp | 178 + engines/wintermute/base/BBase.h | 64 + engines/wintermute/base/BDebugger.cpp | 203 + engines/wintermute/base/BDebugger.h | 95 + engines/wintermute/base/BDynBuffer.cpp | 192 + engines/wintermute/base/BDynBuffer.h | 66 + engines/wintermute/base/BFader.cpp | 176 + engines/wintermute/base/BFader.h | 62 + engines/wintermute/base/BFileEntry.cpp | 50 + engines/wintermute/base/BFileEntry.h | 57 + engines/wintermute/base/BFileManager.cpp | 737 ++++ engines/wintermute/base/BFileManager.h | 85 + engines/wintermute/base/BFrame.cpp | 705 +++ engines/wintermute/base/BFrame.h | 73 + engines/wintermute/base/BGame.cpp | 4478 ++++++++++++++++++++ engines/wintermute/base/BGame.h | 391 ++ engines/wintermute/base/BKeyboardState.cpp | 304 ++ engines/wintermute/base/BKeyboardState.h | 75 + engines/wintermute/base/BNamedObject.cpp | 65 + engines/wintermute/base/BNamedObject.h | 50 + engines/wintermute/base/BObject.cpp | 1128 +++++ engines/wintermute/base/BObject.h | 144 + engines/wintermute/base/BPackage.cpp | 104 + engines/wintermute/base/BPackage.h | 61 + engines/wintermute/base/BParser.cpp | 436 ++ engines/wintermute/base/BParser.h | 89 + engines/wintermute/base/BPersistMgr.cpp | 778 ++++ engines/wintermute/base/BPersistMgr.h | 114 + engines/wintermute/base/BPoint.cpp | 64 + engines/wintermute/base/BPoint.h | 50 + engines/wintermute/base/BQuickMsg.cpp | 54 + engines/wintermute/base/BQuickMsg.h | 48 + engines/wintermute/base/BRegion.cpp | 508 +++ engines/wintermute/base/BRegion.h | 68 + engines/wintermute/base/BRegistry.cpp | 257 ++ engines/wintermute/base/BRegistry.h | 76 + engines/wintermute/base/BResources.cpp | 2820 ++++++++++++ engines/wintermute/base/BResources.h | 44 + engines/wintermute/base/BSaveThumbHelper.cpp | 79 + engines/wintermute/base/BSaveThumbHelper.h | 50 + engines/wintermute/base/BScriptHolder.cpp | 473 +++ engines/wintermute/base/BScriptHolder.h | 74 + engines/wintermute/base/BScriptable.cpp | 188 + engines/wintermute/base/BScriptable.h | 90 + engines/wintermute/base/BSound.cpp | 288 ++ engines/wintermute/base/BSound.h | 88 + engines/wintermute/base/BSoundBuffer.cpp | 383 ++ engines/wintermute/base/BSoundBuffer.h | 100 + engines/wintermute/base/BSoundMgr.cpp | 292 ++ engines/wintermute/base/BSoundMgr.h | 69 + engines/wintermute/base/BSprite.cpp | 758 ++++ engines/wintermute/base/BSprite.h | 90 + engines/wintermute/base/BStringTable.cpp | 229 + engines/wintermute/base/BStringTable.h | 55 + engines/wintermute/base/BSubFrame.cpp | 589 +++ engines/wintermute/base/BSubFrame.h | 86 + engines/wintermute/base/BSurfaceStorage.cpp | 189 + engines/wintermute/base/BSurfaceStorage.h | 57 + engines/wintermute/base/BTransitionMgr.cpp | 131 + engines/wintermute/base/BTransitionMgr.h | 54 + engines/wintermute/base/BViewport.cpp | 98 + engines/wintermute/base/BViewport.h | 55 + engines/wintermute/base/file/BDiskFile.cpp | 131 + engines/wintermute/base/file/BDiskFile.h | 42 + engines/wintermute/base/file/BFile.cpp | 69 + engines/wintermute/base/file/BFile.h | 67 + engines/wintermute/base/file/BPkgFile.cpp | 105 + engines/wintermute/base/file/BPkgFile.h | 46 + engines/wintermute/base/file/BSaveThumbFile.cpp | 146 + engines/wintermute/base/file/BSaveThumbFile.h | 52 + engines/wintermute/base/font/BFont.cpp | 206 + engines/wintermute/base/font/BFont.h | 61 + engines/wintermute/base/font/BFontBitmap.cpp | 540 +++ engines/wintermute/base/font/BFontBitmap.h | 72 + engines/wintermute/base/font/BFontStorage.cpp | 135 + engines/wintermute/base/font/BFontStorage.h | 55 + engines/wintermute/base/font/BFontTT.cpp | 762 ++++ engines/wintermute/base/font/BFontTT.h | 180 + engines/wintermute/base/gfx/base_image.cpp | 269 ++ engines/wintermute/base/gfx/base_image.h | 74 + engines/wintermute/base/gfx/base_renderer.cpp | 257 ++ engines/wintermute/base/gfx/base_renderer.h | 128 + engines/wintermute/base/gfx/base_surface.cpp | 152 + engines/wintermute/base/gfx/base_surface.h | 99 + .../base/gfx/osystem/base_render_osystem.cpp | 701 +++ .../base/gfx/osystem/base_render_osystem.h | 129 + .../base/gfx/osystem/base_surface_osystem.cpp | 532 +++ .../base/gfx/osystem/base_surface_osystem.h | 101 + engines/wintermute/base/particles/PartEmitter.cpp | 1199 ++++++ engines/wintermute/base/particles/PartEmitter.h | 139 + engines/wintermute/base/particles/PartForce.cpp | 59 + engines/wintermute/base/particles/PartForce.h | 57 + engines/wintermute/base/particles/PartParticle.cpp | 257 ++ engines/wintermute/base/particles/PartParticle.h | 90 + engines/wintermute/base/scriptables/SXArray.cpp | 238 ++ engines/wintermute/base/scriptables/SXArray.h | 54 + engines/wintermute/base/scriptables/SXDate.cpp | 297 ++ engines/wintermute/base/scriptables/SXDate.h | 55 + engines/wintermute/base/scriptables/SXFile.cpp | 779 ++++ engines/wintermute/base/scriptables/SXFile.h | 66 + engines/wintermute/base/scriptables/SXMath.cpp | 295 ++ engines/wintermute/base/scriptables/SXMath.h | 53 + .../wintermute/base/scriptables/SXMemBuffer.cpp | 508 +++ engines/wintermute/base/scriptables/SXMemBuffer.h | 59 + engines/wintermute/base/scriptables/SXString.cpp | 404 ++ engines/wintermute/base/scriptables/SXString.h | 58 + engines/wintermute/base/scriptables/ScEngine.cpp | 712 ++++ engines/wintermute/base/scriptables/ScEngine.h | 147 + engines/wintermute/base/scriptables/ScScript.cpp | 1461 +++++++ engines/wintermute/base/scriptables/ScScript.h | 183 + engines/wintermute/base/scriptables/ScStack.cpp | 226 + engines/wintermute/base/scriptables/ScStack.h | 66 + engines/wintermute/base/scriptables/ScValue.cpp | 1054 +++++ engines/wintermute/base/scriptables/ScValue.h | 141 + engines/wintermute/base/scriptables/SxObject.cpp | 67 + engines/wintermute/base/scriptables/SxObject.h | 47 + 118 files changed, 33563 insertions(+) create mode 100644 engines/wintermute/base/BActiveRect.cpp create mode 100644 engines/wintermute/base/BActiveRect.h create mode 100644 engines/wintermute/base/BBase.cpp create mode 100644 engines/wintermute/base/BBase.h create mode 100644 engines/wintermute/base/BDebugger.cpp create mode 100644 engines/wintermute/base/BDebugger.h create mode 100644 engines/wintermute/base/BDynBuffer.cpp create mode 100644 engines/wintermute/base/BDynBuffer.h create mode 100644 engines/wintermute/base/BFader.cpp create mode 100644 engines/wintermute/base/BFader.h create mode 100644 engines/wintermute/base/BFileEntry.cpp create mode 100644 engines/wintermute/base/BFileEntry.h create mode 100644 engines/wintermute/base/BFileManager.cpp create mode 100644 engines/wintermute/base/BFileManager.h create mode 100644 engines/wintermute/base/BFrame.cpp create mode 100644 engines/wintermute/base/BFrame.h create mode 100644 engines/wintermute/base/BGame.cpp create mode 100644 engines/wintermute/base/BGame.h create mode 100644 engines/wintermute/base/BKeyboardState.cpp create mode 100644 engines/wintermute/base/BKeyboardState.h create mode 100644 engines/wintermute/base/BNamedObject.cpp create mode 100644 engines/wintermute/base/BNamedObject.h create mode 100644 engines/wintermute/base/BObject.cpp create mode 100644 engines/wintermute/base/BObject.h create mode 100644 engines/wintermute/base/BPackage.cpp create mode 100644 engines/wintermute/base/BPackage.h create mode 100644 engines/wintermute/base/BParser.cpp create mode 100644 engines/wintermute/base/BParser.h create mode 100644 engines/wintermute/base/BPersistMgr.cpp create mode 100644 engines/wintermute/base/BPersistMgr.h create mode 100644 engines/wintermute/base/BPoint.cpp create mode 100644 engines/wintermute/base/BPoint.h create mode 100644 engines/wintermute/base/BQuickMsg.cpp create mode 100644 engines/wintermute/base/BQuickMsg.h create mode 100644 engines/wintermute/base/BRegion.cpp create mode 100644 engines/wintermute/base/BRegion.h create mode 100644 engines/wintermute/base/BRegistry.cpp create mode 100644 engines/wintermute/base/BRegistry.h create mode 100644 engines/wintermute/base/BResources.cpp create mode 100644 engines/wintermute/base/BResources.h create mode 100644 engines/wintermute/base/BSaveThumbHelper.cpp create mode 100644 engines/wintermute/base/BSaveThumbHelper.h create mode 100644 engines/wintermute/base/BScriptHolder.cpp create mode 100644 engines/wintermute/base/BScriptHolder.h create mode 100644 engines/wintermute/base/BScriptable.cpp create mode 100644 engines/wintermute/base/BScriptable.h create mode 100644 engines/wintermute/base/BSound.cpp create mode 100644 engines/wintermute/base/BSound.h create mode 100644 engines/wintermute/base/BSoundBuffer.cpp create mode 100644 engines/wintermute/base/BSoundBuffer.h create mode 100644 engines/wintermute/base/BSoundMgr.cpp create mode 100644 engines/wintermute/base/BSoundMgr.h create mode 100644 engines/wintermute/base/BSprite.cpp create mode 100644 engines/wintermute/base/BSprite.h create mode 100644 engines/wintermute/base/BStringTable.cpp create mode 100644 engines/wintermute/base/BStringTable.h create mode 100644 engines/wintermute/base/BSubFrame.cpp create mode 100644 engines/wintermute/base/BSubFrame.h create mode 100644 engines/wintermute/base/BSurfaceStorage.cpp create mode 100644 engines/wintermute/base/BSurfaceStorage.h create mode 100644 engines/wintermute/base/BTransitionMgr.cpp create mode 100644 engines/wintermute/base/BTransitionMgr.h create mode 100644 engines/wintermute/base/BViewport.cpp create mode 100644 engines/wintermute/base/BViewport.h create mode 100644 engines/wintermute/base/file/BDiskFile.cpp create mode 100644 engines/wintermute/base/file/BDiskFile.h create mode 100644 engines/wintermute/base/file/BFile.cpp create mode 100644 engines/wintermute/base/file/BFile.h create mode 100644 engines/wintermute/base/file/BPkgFile.cpp create mode 100644 engines/wintermute/base/file/BPkgFile.h create mode 100644 engines/wintermute/base/file/BSaveThumbFile.cpp create mode 100644 engines/wintermute/base/file/BSaveThumbFile.h create mode 100644 engines/wintermute/base/font/BFont.cpp create mode 100644 engines/wintermute/base/font/BFont.h create mode 100644 engines/wintermute/base/font/BFontBitmap.cpp create mode 100644 engines/wintermute/base/font/BFontBitmap.h create mode 100644 engines/wintermute/base/font/BFontStorage.cpp create mode 100644 engines/wintermute/base/font/BFontStorage.h create mode 100644 engines/wintermute/base/font/BFontTT.cpp create mode 100644 engines/wintermute/base/font/BFontTT.h create mode 100644 engines/wintermute/base/gfx/base_image.cpp create mode 100644 engines/wintermute/base/gfx/base_image.h create mode 100644 engines/wintermute/base/gfx/base_renderer.cpp create mode 100644 engines/wintermute/base/gfx/base_renderer.h create mode 100644 engines/wintermute/base/gfx/base_surface.cpp create mode 100644 engines/wintermute/base/gfx/base_surface.h create mode 100644 engines/wintermute/base/gfx/osystem/base_render_osystem.cpp create mode 100644 engines/wintermute/base/gfx/osystem/base_render_osystem.h create mode 100644 engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp create mode 100644 engines/wintermute/base/gfx/osystem/base_surface_osystem.h create mode 100644 engines/wintermute/base/particles/PartEmitter.cpp create mode 100644 engines/wintermute/base/particles/PartEmitter.h create mode 100644 engines/wintermute/base/particles/PartForce.cpp create mode 100644 engines/wintermute/base/particles/PartForce.h create mode 100644 engines/wintermute/base/particles/PartParticle.cpp create mode 100644 engines/wintermute/base/particles/PartParticle.h create mode 100644 engines/wintermute/base/scriptables/SXArray.cpp create mode 100644 engines/wintermute/base/scriptables/SXArray.h create mode 100644 engines/wintermute/base/scriptables/SXDate.cpp create mode 100644 engines/wintermute/base/scriptables/SXDate.h create mode 100644 engines/wintermute/base/scriptables/SXFile.cpp create mode 100644 engines/wintermute/base/scriptables/SXFile.h create mode 100644 engines/wintermute/base/scriptables/SXMath.cpp create mode 100644 engines/wintermute/base/scriptables/SXMath.h create mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.cpp create mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.h create mode 100644 engines/wintermute/base/scriptables/SXString.cpp create mode 100644 engines/wintermute/base/scriptables/SXString.h create mode 100644 engines/wintermute/base/scriptables/ScEngine.cpp create mode 100644 engines/wintermute/base/scriptables/ScEngine.h create mode 100644 engines/wintermute/base/scriptables/ScScript.cpp create mode 100644 engines/wintermute/base/scriptables/ScScript.h create mode 100644 engines/wintermute/base/scriptables/ScStack.cpp create mode 100644 engines/wintermute/base/scriptables/ScStack.h create mode 100644 engines/wintermute/base/scriptables/ScValue.cpp create mode 100644 engines/wintermute/base/scriptables/ScValue.h create mode 100644 engines/wintermute/base/scriptables/SxObject.cpp create mode 100644 engines/wintermute/base/scriptables/SxObject.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp new file mode 100644 index 0000000000..382329087a --- /dev/null +++ b/engines/wintermute/base/BActiveRect.cpp @@ -0,0 +1,107 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { + _owner = owner; + _frame = frame; + CBPlatform::setRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { + _owner = owner; + _region = region; + CBPlatform::copyRect(&_rect, ®ion->_rect); + CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + CBRenderer *Rend = _gameRef->_renderer; + + if (!customViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + + CBPlatform::intersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BActiveRect.h b/engines/wintermute/base/BActiveRect.h new file mode 100644 index 0000000000..935b91eaeb --- /dev/null +++ b/engines/wintermute/base/BActiveRect.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BBase.cpp b/engines/wintermute/base/BBase.cpp new file mode 100644 index 0000000000..76e1150925 --- /dev/null +++ b/engines/wintermute/base/BBase.cpp @@ -0,0 +1,178 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::getEditorProp(const char *propName, const char *initVal) { + _editorPropsIter = _editorProps.find(propName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean + else return initVal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return STATUS_FAILED; + + if (propValue == NULL) { + _editorProps.erase(propName); + } else { + _editorProps[propName] = propValue; + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBBase::parseEditorProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!_gameRef->_editorMode) + return STATUS_OK; + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + + + setEditorProp(propName, propValue); + + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + buffer->putTextIndent(indent, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BBase.h b/engines/wintermute/base/BBase.h new file mode 100644 index 0000000000..e8c87f1f9e --- /dev/null +++ b/engines/wintermute/base/BBase.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool _persistable; + bool setEditorProp(const char *propName, const char *propValue); + const char *getEditorProp(const char *propName, const char *initVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBBase(); + CBGame *_gameRef; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BDebugger.cpp b/engines/wintermute/base/BDebugger.cpp new file mode 100644 index 0000000000..92f282b6d1 --- /dev/null +++ b/engines/wintermute/base/BDebugger.cpp @@ -0,0 +1,203 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BDebugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + _enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::initialize() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::shutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameInit() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameShutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameTick() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onLog(unsigned int errorCode, const char *text) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptInit(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::attachClient(IWmeDebugClient *client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::detachClient(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::queryData(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::getPropInt(const char *propName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::getPropFloat(const char *propName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::getPropString(const char *propName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::getPropBool(const char *propName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, int propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, double propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, const char *propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, bool propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::continueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDebugger.h b/engines/wintermute/base/BDebugger.h new file mode 100644 index 0000000000..cea432f7a8 --- /dev/null +++ b/engines/wintermute/base/BDebugger.h @@ -0,0 +1,95 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/wme_debugger.h" + +// TODO: The entire debugger should possibly be removed + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool _enabled; + bool initialize(); + bool shutdown(); + + // internal interface + bool onGameInit(); + bool onGameShutdown(); + bool onGameTick(); + bool onLog(unsigned int errorCode, const char *text); + bool onScriptInit(CScScript *script); + bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + bool onScriptShutdown(CScScript *script); + bool onScriptChangeLine(CScScript *script, int line); + bool onScriptChangeScope(CScScript *script, CScValue *scope); + bool onScriptShutdownScope(CScScript *script, CScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + bool onVariableChangeValue(CScValue *var, CScValue *value); + + bool onScriptHitBreakpoint(CScScript *script); + + // IWmeDebugServer interface + virtual bool attachClient(IWmeDebugClient *client); + virtual bool detachClient(IWmeDebugClient *client); + virtual bool queryData(IWmeDebugClient *client); + + virtual int getPropInt(const char *propName); + virtual double getPropFloat(const char *propName); + virtual const char *getPropString(const char *propName); + virtual bool getPropBool(const char *propName); + + virtual bool setProp(const char *propName, int propValue); + virtual bool setProp(const char *propName, double propValue); + virtual bool setProp(const char *propName, const char *propValue); + virtual bool setProp(const char *propName, bool propValue); + + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); + + virtual bool addBreakpoint(const char *scriptFilename, int line); + virtual bool removeBreakpoint(const char *scriptFilename, int line); + + virtual bool continueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BDynBuffer.cpp b/engines/wintermute/base/BDynBuffer.cpp new file mode 100644 index 0000000000..9a2e071287 --- /dev/null +++ b/engines/wintermute/base/BDynBuffer.cpp @@ -0,0 +1,192 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BDynBuffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::cleanup() { + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) initSize = _initSize; + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + if (_offset + size > _size) { + _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putString(const char *val) { + if (!val) putString("(null)"); + else { + putDWORD(strlen(val) + 1); + putBytes((byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + putBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDynBuffer.h b/engines/wintermute/base/BDynBuffer.h new file mode 100644 index 0000000000..66e8182c68 --- /dev/null +++ b/engines/wintermute/base/BDynBuffer.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool _initialized; + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void putTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp new file mode 100644 index 0000000000..7184c6664c --- /dev/null +++ b/engines/wintermute/base/BFader.cpp @@ -0,0 +1,176 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFader.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::update() { + if (!_active) return STATUS_OK; + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) time = CBPlatform::getTime() - _startTime; + else time = _gameRef->_timer - _startTime; + + if (time >= _duration) _currentAlpha = _targetAlpha; + else { + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::display() { + if (!_active) return STATUS_OK; + + if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); + + _sourceAlpha = RGBCOLGetA(sourceColor); + _targetAlpha = 0; + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = RGBCOLGetA(targetColor); + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->_saving) _startTime = 0; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFader.h b/engines/wintermute/base/BFader.h new file mode 100644 index 0000000000..cc90d4603d --- /dev/null +++ b/engines/wintermute/base/BFader.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool _system; + uint32 getCurrentColor(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFileEntry.cpp b/engines/wintermute/base/BFileEntry.cpp new file mode 100644 index 0000000000..39223bfb8e --- /dev/null +++ b/engines/wintermute/base/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileEntry.h b/engines/wintermute/base/BFileEntry.h new file mode 100644 index 0000000000..5fdf2b6308 --- /dev/null +++ b/engines/wintermute/base/BFileEntry.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp new file mode 100644 index 0000000000..1cfb3d47d3 --- /dev/null +++ b/engines/wintermute/base/BFileManager.cpp @@ -0,0 +1,737 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/base/file/BDiskFile.h" +#include "engines/wintermute/base/file/BSaveThumbFile.h" +#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/BResources.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/savefile.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + _basePath = NULL; + + initPaths(); + registerPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::cleanup() { + // delete registered paths + for (int i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (int i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + + // delete file entries + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; + } + _files.clear(); + + // close open files + for (int i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + + // delete packages + for (int i = 0; i < _packages.size(); i++) + delete _packages[i]; + _packages.clear(); + + delete[] _basePath; + _basePath = NULL; + + return STATUS_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + return NULL; + } + + /* + if (File->GetSize() > MAX_FILE_SIZE) { + _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[file->size() + 1]; + if (buffer == NULL) { + _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + closeFile(file); + delete [] buffer; + return NULL; + }; + + buffer[file->size()] = '\0'; + if (size != NULL) *size = file->size(); + closeFile(file); + + return buffer; +} + +Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::InSaveFile *file = saveMan->openForLoading(filename); + return file; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { + // TODO + warning("Implement SaveFile"); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + file->finalize(); + delete file; +#if 0 + RestoreCurrentDir(); + + CBUtils::CreatePath(filename, false); + + FILE *f = fopen(filename, "wb"); + if (!f) { + _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); + return STATUS_FAILED; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { + // unmount all non-local packages + for (int i = 0; i < _packages.size(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->close(); + } + + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; + + bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); + + char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return STATUS_FAILED; + + strcpy(buffer, path.c_str()); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (type) { + case PATH_SINGLE: + _singlePaths.push_back(buffer); + break; + case PATH_PACKAGE: + _packagePaths.push_back(buffer); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::reloadPaths() { + // delete registered paths + for (int i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (int i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + return initPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::initPaths() { + restoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_SINGLE, ".\\"); + + + // package files paths + addPath(PATH_PACKAGE, "./"); + + pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_PACKAGE, "data"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackages() { + restoreCurrentDir(); + + _gameRef->LOG(0, "Scanning packages..."); + debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.dcp"); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + registerPackage((*it)->getName().c_str()); + } +#if 0 + AnsiString extension = AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < _packagePaths.getSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); + + //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } +#endif + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +// FILE *f = fopen(filename, "rb"); + Common::File *package = new Common::File(); + package->open(filename); + if (!package->isOpen()) { + _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + return STATUS_OK; + } + + uint32 absoluteOffset = 0; + bool boundToExe = false; + + if (searchSignature) { + uint32 Offset; + if (!findPackageSignature(package, &Offset)) { + delete package; + return STATUS_OK; + } else { + package->seek(Offset, SEEK_SET); + absoluteOffset = Offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete package; + return STATUS_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = package->readUint32LE(); + dirOffset += absoluteOffset; + package->seek(dirOffset, SEEK_SET); + } + + for (uint32 i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(_gameRef); + if (!pkg) return STATUS_FAILED; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = package->readByte(); + pkg->_name = new char[nameLength]; + package->read(pkg->_name, nameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (uint32 j = 0; j < NumFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = package->readByte(); + name = new char[nameLength]; + package->read(name, nameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + + CBPlatform::strupr(name); + + offset = package->readUint32LE(); + offset += absoluteOffset; + length = package->readUint32LE(); + compLength = package->readUint32LE(); + flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + timeDate1 = package->readUint32LE(); + timeDate2 = package->readUint32LE(); + } + _filesIter = _files.find(name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(_gameRef); + file->_package = pkg; + file->_offset = offset; + file->_length = length; + file->_compressedLength = compLength; + file->_flags = flags; + + _files[name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = offset; + _filesIter->_value->_length = length; + _filesIter->_value->_compressedLength = compLength; + _filesIter->_value->_flags = flags; + } + } + delete [] name; + } + } + + + delete package; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::isValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::startsWith(plainName, "xdevice_", true)) { + return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openPackage(const Common::String &name) { + //TODO: Is it really necessary to do this when we have the ScummVM-system? + + //RestoreCurrentDir(); + + Common::File *ret = new Common::File(); + char filename[MAX_PATH_LENGTH]; + + for (int i = 0; i < _packagePaths.size(); i++) { + sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + } + + sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + delete ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openSingleFile(const Common::String &name) { + restoreCurrentDir(); + + Common::File *ret = NULL; + char filename[MAX_PATH_LENGTH]; + + for (int i = 0; i < _singlePaths.size(); i++) { + sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); + ret->open(filename); + if (ret->isOpen()) + return ret; + } + + // didn't find in search paths, try to open directly + ret->open(name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { + restoreCurrentDir(); + + Common::File f; + bool found = false; + + for (int i = 0; i < _singlePaths.size(); i++) { + sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); + f.open(fullname); + if (f.isOpen()) { + f.close(); + found = true; + break; + } + } + + if (!found) { + f.open(filename.c_str()); + if (f.isOpen()) { + f.close(); + found = true; + strcpy(fullname, filename.c_str()); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { + char *upc_name = new char[strlen(filename.c_str()) + 1]; + strcpy(upc_name, filename.c_str()); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; + + delete [] upc_name; + + return ret; +} + +bool CBFileManager::hasFile(const Common::String &filename) { + //TODO: Do this in a much simpler fashion + Common::SeekableReadStream *stream = openFile(filename, true, false); + if (!stream) { + return false; + } + delete stream; + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) return NULL; + //_gameRef->LOG(0, "open file: %s", filename); + /*#ifdef __WIN32__ + if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); + } + } + #endif*/ + + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) _openFiles.push_back(file); + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::closeFile(Common::SeekableReadStream *File) { + for (int i = 0; i < _openFiles.size(); i++) { + if (_openFiles[i] == File) { + delete _openFiles[i]; + _openFiles.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { + restoreCurrentDir(); + + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + if (DID_SUCCEED(SaveThumbFile->open(filename))) { + ret = SaveThumbFile->getMemStream(); + } + delete SaveThumbFile; + return ret; + } + + + + ret = openDiskFile(filename, this); + if (ret) return ret; + + ret = openPkgFile(filename, this); + if (ret) return ret; + + ret = CBResources::getFile(filename); + if (ret) return ret; + + warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::restoreCurrentDir() { + if (!_basePath) return STATUS_OK; + else { + /*if (!chdir(_basePath)) return STATUS_OK; + else return STATUS_FAILED;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::setBasePath(const Common::String &path) { + cleanup(); + + if (path.c_str()) { + _basePath = new char[path.size() + 1]; + strcpy(_basePath, path.c_str()); + } + + initPaths(); + registerPackages(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h new file mode 100644 index 0000000000..8e7551480d --- /dev/null +++ b/engines/wintermute/base/BFileManager.h @@ -0,0 +1,85 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + +#include "engines/wintermute/base/BFileEntry.h" +#include "common/archive.h" +#include "common/str.h" + +namespace Common { +class File; +} + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool findPackageSignature(Common::File *f, uint32 *offset); + bool cleanup(); + bool setBasePath(const Common::String &path); + bool restoreCurrentDir(); + char *_basePath; + bool getFullPath(const Common::String &filename, char *fullname); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *getPackageEntry(const Common::String &filename); + Common::File *openSingleFile(const Common::String &name); + Common::File *openPackage(const Common::String &name); + bool registerPackages(); + bool initPaths(); + bool reloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + bool addPath(TPathType type, const Common::String &path); + bool requestCD(int cd, char *packageFile, const char *filename); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + Common::Array _singlePaths; + Common::Array _packagePaths; + Common::Array _packages; + Common::Array _openFiles; + + Common::HashMap _files; +private: + bool registerPackage(const Common::String &filename, bool searchSignature = false); + Common::HashMap::iterator _filesIter; + bool isValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp new file mode 100644 index 0000000000..4af9262701 --- /dev/null +++ b/engines/wintermute/base/BFrame.cpp @@ -0,0 +1,705 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete _sound; + _sound = NULL; + + for (int i = 0; i < _subframes.getSize(); i++) + delete _subframes[i]; + _subframes.removeAll(); + + for (int i = 0; i < _applyEvent.getSize(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.removeAll(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; + + for (int i = 0; i < _subframes.getSize(); i++) { + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); + if (DID_FAIL(res)) return res; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) owner->updateOneSound(_sound); + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (int i = 0; i < _applyEvent.getSize(); i++) { + owner->applyEvent(_applyEvent[i]); + } + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; + CBPlatform::setRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.scanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); + break; + + case TOKEN_MOVE: + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &mirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &editorSelected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.scanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.scanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(_gameRef); + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else _subframes.add(subframe); + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { + if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + _applyEvent.add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.scanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FRAME definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading FRAME definition"); + return STATUS_FAILED; + } + + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (surface_file != NULL) { + if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + + if (!sub->_surface) { + delete sub; + _gameRef->LOG(0, "Error loading SUBFRAME"); + return STATUS_FAILED; + } + + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } + + if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + else sub->_rect = rect; + + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; + + + sub->_editorSelected = editorSelected; + _subframes.insertAt(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + CBPlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (int i = 0; i < _subframes.getSize(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + + if (_sound && _sound->_soundFilename) + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + + if (_editorExpanded) + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + + if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + + for (int i = 1; i < _subframes.getSize(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (int i = 0; i < _applyEvent.getSize(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + CBBase::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + _applyEvent.persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { + stack->pushBool(false); + delete _sound; + _sound = NULL; + } else stack->pushBool(true); + } else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushNative(_subframes[index], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + CBSubFrame *sub = (CBSubFrame *)val->getNative(); + for (int i = 0; i < _subframes.getSize(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + sub->setDefaultRect(); + } + _subframes.add(sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertSubframe") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= _subframes.getSize()) _subframes.add(sub); + else _subframes.insertAt(index, sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _applyEvent.getSize()) { + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushString(_applyEvent[index]); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + stack->pushNULL(); + return STATUS_OK; + } + } + _applyEvent.add(event); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.removeAt(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delay") == 0) { + _scValue->setInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _scValue->setBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _scValue->setBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _scValue->setInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _scValue->setInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumSubframes") == 0) { + _scValue->setInt(_subframes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); + else return CBScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Delay") == 0) { + _delay = MAX(0, value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _keyframe = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _killSound = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _moveX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _moveY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); + else return CBScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBFrame::scToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFrame.h b/engines/wintermute/base/BFrame.h new file mode 100644 index 0000000000..3d487b4ebc --- /dev/null +++ b/engines/wintermute/base/BFrame.h @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool _killSound; + bool _keyframe; + bool oneTimeDisplay(CBObject *owner, bool muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *_sound; + bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool saveAsText(CBDynBuffer *buffer, int indent); + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray _applyEvent; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BGame.cpp b/engines/wintermute/base/BGame.cpp new file mode 100644 index 0000000000..3e577541b7 --- /dev/null +++ b/engines/wintermute/base/BGame.cpp @@ -0,0 +1,4478 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFader.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BQuickMsg.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BSubFrame.h" + +#include "engines/wintermute/base/BTransitionMgr.h" +#include "engines/wintermute/base/BViewport.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/ui/UIWindow.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/video/VidPlayer.h" +#include "engines/wintermute/video/VidTheoraPlayer.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _debugAbsolutePathWarning = true; + _debugShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _videoPlayer = NULL; + _theoraPlayer = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + _doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _localSaveDir = NULL; + CBUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + CBPlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + +/*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices +#else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + getDebugMgr()->onGameShutdown(); + + _registry->writeBool("System", "LastRun", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _saveLoadImage; + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _saveLoadImage = NULL; + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::outputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::cleanup() { + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + unregisterObject(_fader); + _fader = NULL; + + for (int i = 0; i < _regObjects.getSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.removeAll(); + + _windows.removeAll(); // refs only + _focusedWindow = NULL; // ref only + + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (int i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.removeAll(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + _quickMessages.removeAll(); + + _viewportStack.removeAll(); + _viewportSP = -1; + + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) + break; + + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) + break; + + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) + break; + + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) + break; + + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) + break; + + _mathClass = new CSXMath(this); + if (_mathClass == NULL) + break; + + _scEngine = new CScEngine(this); + if (_scEngine == NULL) + break; + + _videoPlayer = new CVidPlayer(this); + if (_videoPlayer == NULL) + break; + + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) + break; + + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) + break; + + _fader = new CBFader(this); + if (_fader == NULL) + break; + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _debugMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _fileManager; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) return STATUS_FAILED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + #ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #endif*/ + int secs = g_system->getMillis() / 1000; + int hours = secs / 3600; + secs = secs % 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + if (_debugMgr) _debugMgr->onLog(res, buff); + + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initLoop() { + _viewportSP = -1; + + _currentTime = CBPlatform::getTime(); + + getDebugMgr()->onGameTick(); + _renderer->initLoop(); + _soundMgr->initLoop(); + updateMusicCrossfade(); + + _surfaceStorage->initLoop(); + _fontStorage->initLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //_gameRef->LOG(0, "%d", _fps); + + getMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) _fader->update(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) *offsetX = _offsetX; + if (offsetY != NULL) *offsetY = _offsetY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + _gameRef->LOG(0, "'GAME' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _systemFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + _videoFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.scanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.scanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.scanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.scanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.scanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.scanStr((char *)params, "%d", &_indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.scanStr((char *)params, "%d", &_indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + _indicatorColor = BYTETORGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.scanStr((char *)params, "%d", &_indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.scanStr((char *)params, "%d", &_indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::setString(&_saveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.scanStr((char *)params, "%d", &_saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::setString(&_loadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.scanStr((char *)params, "%d", &_loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + LOG(0, stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + bool res = CBObject::scCallMethod(script, stack, thisStack, name); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Msg") == 0) { + stack->correctParams(1); + quickMessage(stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RunScript") == 0) { + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + stack->correctParams(1); + if (DID_FAIL(addScript(stack->pop()->getString()))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadStringTable") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + CScValue *Val = stack->pop(); + + bool ClearOld; + if (Val->isNULL()) ClearOld = true; + else ClearOld = Val->getBool(); + + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidObject") == 0) { + stack->correctParams(1); + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *) obj)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + resetContent(); + stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CBObject *obj = (CBObject *)val->getNative(); + unregisterObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadWindow") == 0) { + stack->correctParams(1); + CUIWindow *win = new CUIWindow(_gameRef); + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { + _windows.add(win); + registerObject(win); + stack->pushNative(win, true); + } else { + delete win; + win = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExpandString") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); + _stringTable->expand(&str); + stack->pushString(str); + delete [] str; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); + else { + stack->correctParams(4); + channel = stack->pop()->getInt(); + } + + const char *filename = stack->pop()->getString(); + CScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + CScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); + + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); + else { + if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); + else stack->pushString(_music[channel]->_soundFilename); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + uint32 time = stack->pop()->getInt(); + + if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); + else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { + int channel = 0; + if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else stack->pushBool(_music[channel]->isPlaying()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + int volume = stack->pop()->getInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); + else stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getVolumePercent()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->correctParams(4); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); + + if (_musicCrossfadeRunning) { + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->pushBool(false); + return STATUS_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; + + _musicCrossfadeRunning = true; + + stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundLength") == 0) { + stack->correctParams(1); + + int length = 0; + const char *filename = stack->pop()->getString(); + + CBSound *sound = new CBSound(_gameRef); + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; + } + stack->pushInt(length); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMousePos") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + Point32 p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LockMouseRect") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + if (right < left) CBUtils::swap(&left, &right); + if (bottom < top) CBUtils::swap(&top, &bottom); + + CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK; + // TODO: ADDVIDEO + */ + + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + stack->correctParams(6); + const char *filename = stack->pop()->getString(); + warning("PlayVideo: %s - not implemented yet", filename); + CScValue *valType = stack->pop(); + int Type; + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + Type = (int)VID_PLAY_STRETCH; + + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK;*/ + // TODO: ADDVIDEO + + stack->correctParams(7); + const char *filename = stack->pop()->getString(); + CScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) + type = (int)VID_PLAY_STRETCH; + else type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else { + stack->pushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QuitGame") == 0) { + stack->correctParams(0); + stack->pushNULL(); + _quitting = true; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + _registry->writeInt("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + _registry->writeString("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + AnsiString val = _registry->readString("PrivateSettings", key, initVal); + stack->pushString(val.c_str()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveGame") == 0) { + stack->correctParams(3); + int slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); + + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); + stack->pushBool(true); + if (DID_FAIL(SaveGame(slot, desc, quick))) { + stack->pop(); + stack->pushBool(false); + } + delete [] desc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadGame") == 0) { + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->getInt(); + _loading = true; + stack->pushBool(false); + script->sleep(0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->correctParams(1); + int Slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(Slot)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + emptySaveSlot(slot); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); + else stack->pushString(_activeCursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->correctParams(0); + if (!_activeCursor) stack->pushNULL(); + else stack->pushNative(_activeCursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->correctParams(0); + delete _activeCursor; + _activeCursor = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->correctParams(0); + + if (_activeCursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FileExists") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + // TODO: Replace with fileExists + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (!file) stack->pushBool(false); + else { + _fileManager->closeFile(file); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Screenshot") == 0) { + stack->correctParams(1); + char filename[MAX_PATH_LENGTH]; + + CScValue *Val = stack->pop(); + + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO + int fileNum = 0; + + while (true) { + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + if (!Common::File::exists(filename)) + break; + fileNum++; + } + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + _windows.add(win); + registerObject(win); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CBObject *obj = (CBObject *)stack->pop()->getNative(); + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == obj) { + unregisterObject(_windows[i]); + stack->pushBool(true); + return STATUS_OK; + } + } + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenDocument") == 0) { + stack->correctParams(0); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->correctParams(0); + DEBUG_DumpClassRegistry(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _loadImageX = stack->pop()->getInt(); + _loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _loadImageName; + _loadImageName = NULL; + } else { + CBUtils::setString(&_loadImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _saveImageX = stack->pop()->getInt(); + _saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _saveImageName; + _saveImageName = NULL; + } else { + CBUtils::setString(&_saveImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->correctParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive) stack->pushNULL(); + else stack->pushNative(_cursorNoninteractive, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->correctParams(4); + + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + displayContent(false, true); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->correctParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _renderer->dumpData(filename); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccOutputText") == 0) { + stack->correctParams(2); + /* const char *Str = */ + stack->pop()->getString(); + /* int Type = */ + stack->pop()->getInt(); + // do nothing + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool asHex = stack->pop()->getBool(false); + + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (file) { + crc remainder = crc_initialize(); + byte buf[1024]; + int bytesRead = 0; + + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); + + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (asHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + stack->pushString(Hex); + } else + stack->pushInt(checksum); + + _fileManager->closeFile(file); + file = NULL; + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->enableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->disableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Hwnd") == 0) { + _scValue->setInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentTime") == 0) { + _scValue->setInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowsTime") == 0) { + _scValue->setInt((int)CBPlatform::getTime()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowedMode") == 0) { + _scValue->setBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _scValue->setInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _scValue->setInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + _scValue->setNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ActiveObject") == 0) { + _scValue->setNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenWidth") == 0) { + _scValue->setInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenHeight") == 0) { + _scValue->setInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + _scValue->setBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DebugMode") == 0) { + _scValue->setBool(_debugDebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundAvailable") == 0) { + _scValue->setBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyboard") == 0) { + if (_keyboardState) _scValue->setNative(_keyboardState, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _scValue->setBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _scValue->setInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _scValue->setBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FPS") == 0) { + _scValue->setInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + _scValue->setBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + _scValue->setInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _scValue->setBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _scValue->setInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _scValue->setBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _scValue->setBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Frozen") == 0) { + _scValue->setBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSTalk") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSCaptions") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSKeypress") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardPause") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _scValue->setBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveDirectory") == 0) { + AnsiString dataDir = getDataDir(); + _scValue->setString(dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _scValue->setBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _scValue->setInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _scValue->setBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Platform") == 0) { + _scValue->setString(CBPlatform::getPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeviceType") == 0) { + _scValue->setString(getDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MostRecentSaveSlot") == 0) { + _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Store") == 0) { + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); + + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _mousePos.x = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _mousePos.y = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + bool res = CBObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + CBScriptable *obj = value->getNative(); + if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + setInteractive(value->getBool()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _subtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _videoSubtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + int Enc = value->getInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + _textEncoding = (TTextEncoding)Enc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _textRTL = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = value->getInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _suspendedRendering = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _autorunDisabled = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _autoSaveSlot = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _cursorHidden = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayQuickMsg() { + if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + + // update + for (int i = 0; i < _quickMessages.getSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.removeAt(i); + i--; + } + } + + int posY = 20; + + // display + for (int i = 0; i < _quickMessages.getSize(); i++) { + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessage(const char *text) { + if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.removeAt(0); + } + _quickMessages.add(new CBQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::registerObject(CBObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unregisterObject(CBObject *object) { + if (!object) return STATUS_OK; + + // is it a window? + for (int i = 0; i < _windows.getSize(); i++) { + if ((CBObject *)_windows[i] == object) { + _windows.removeAt(i); + + // get new focused window + if (_focusedWindow == object) _focusedWindow = NULL; + + break; + } + } + + // is it active object? + if (_activeObject == object) _activeObject = NULL; + + // is it main object? + if (_mainObject == object) _mainObject = NULL; + + // destroy object + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) { + _regObjects.removeAt(i); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::invalidateValues(void *value, void *data) { + CScValue *val = (CScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { + ((CBScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::validObject(CBObject *object) { + if (!object) return false; + if (object == this) return true; + + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "String") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXString(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MemBuffer") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "File") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXFile(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Date") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXDate(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Array") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXArray(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Object") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXObject(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sleep") == 0) { + stack->correctParams(1); + + script->sleep((uint32)stack->pop()->getInt()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WaitFor") == 0) { + stack->correctParams(1); + + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Random") == 0) { + stack->correctParams(2); + + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); + + stack->pushInt(CBUtils::randomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->correctParams(1); + + script->_timeSlice = (uint32)stack->pop()->getInt(); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->correctParams(4); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); + int a; + CScValue *val = stack->pop(); + if (val->isNULL()) a = 255; + else a = val->getInt(); + + stack->pushInt(BYTETORGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeHSL") == 0) { + stack->correctParams(3); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); + + stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(0); + + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); + script->sleep(0); + } + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToString") == 0) { + stack->correctParams(1); + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete [] str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToInt") == 0) { + stack->correctParams(1); + int val = stack->pop()->getInt(); + stack->pushInt(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToFloat") == 0) { + stack->correctParams(1); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + stack->pushBool(val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + script->runtimeError("Call to undefined function '%s'. Ignored.", name); + stack->correctParams(0); + stack->pushNULL(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (!_interactive && _gameRef->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + } else { + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; + else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); + else if (_cursor) return drawCursor(_cursor); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + LOG(0, "Saving game '%s'...", filename); + + _gameRef->applyEvent("BeforeSave", true); + + bool ret; + + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } + + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + + _registry->writeInt("System", "MostRecentSaveSlot", slot); + +save_finish: // TODO: Remove gotos + delete pm; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + return loadGame(filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(const char *filename) { + LOG(0, "Loading game '%s'...", filename); + getDebugMgr()->onGameShutdown(); + + bool ret; + + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + + + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + _debugAbsolutePathWarning = false; + if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + + //if(DID_FAIL(ret = cleanup())) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + +load_finish: + _debugAbsolutePathWarning = true; + + _indicatorDisplay = false; + delete pm; + _loadInProgress = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::initAfterLoad() { + CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); + + _scEngine->refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadRegion(void *region, void *data) { + ((CBRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSubFrame(void *subframe, void *data) { + ((CBSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSound(void *sound, void *data) { + ((CBSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadFont(void *font, void *data) { + ((CBFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadScript(void *script, void *data) { + ((CScScript *)script)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayWindows(bool inGame) { + bool res; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) return res; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + delete _music[channel]; + _music[channel] = NULL; + + _music[channel] = new CBSound(_gameRef); + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; + } + if (loopStart) _music[channel]->setLoopStart(loopStart); + return _music[channel]->play(looping); + } else { + delete _music[channel]; + _music[channel] = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setMusicStartTime(int channel, uint32 time) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadSettings(const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return STATUS_FAILED; + } + buffer = params; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.scanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.scanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + _registry->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::setString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); + ret = STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading game settings '%s'", filename); + ret = STATUS_FAILED; + } + + _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; + + delete [] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) + cleanup(); + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_doNotExpandStrings)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); + } + + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); + + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); + + _regObjects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); + + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); + + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); + + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); + + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); + + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); + + persistMgr->transfer(TMEMBER(_mouseLockRect)); + + _windows.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); + + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); + + if (!persistMgr->_saving) + _quitting = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::focusWindow(CUIWindow *Window) { + CUIWindow *Prev = _focusedWindow; + + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.getSize() - 1) { + _windows.removeAt(i); + _windows.add(Window); + + _gameRef->_focusedWindow = Window; + } + + if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + return focusWindow(Prev); + else return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::freeze(bool includingMusic) { + if (_freezeLevel == 0) { + _scEngine->pauseAll(); + _soundMgr->pauseAll(includingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unfreeze() { + if (_freezeLevel == 0) return STATUS_OK; + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleKeypress(Common::Event *event, bool printable) { + if (isVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + stopVideo(); + return true; + } + + if (event->type == Common::EVENT_QUIT) { + onWindowClose(); + return true; + } + + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. + _renderer->switchFullscreen(); + return true; + } + + + _keyboardState->handleKeyPress(event); + _keyboardState->readKey(event); +// TODO + + if (_focusedWindow) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + /*if (event->type != SDL_TEXTINPUT) {*/ + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + _gameRef->_focusedWindow->applyEvent("Keypress"); + else + applyEvent("Keypress"); + /*}*/ + } + return true; + } else { /*if (event->type != SDL_TEXTINPUT)*/ + applyEvent("Keypress"); + return true; + } //else return true; + + return false; +} + +void CBGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleMouseWheel(int Delta) { + bool handled = false; + if (_focusedWindow) { + handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + + if (!handled) { + if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); + handled = true; + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); + handled = true; + } + + } + } + + if (!handled) { + if (Delta < 0) { + applyEvent("MouseWheelDown"); + } else { + applyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) *verMajor = DCGF_VER_MAJOR; + if (verMinor) *verMinor = DCGF_VER_MINOR; + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setWindowTitle() { + if (_renderer) { + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') strcat(title, " - "); + strcat(title, "WME Lite"); + + + Utf8String utf8Title; + if (_textEncoding == TEXT_UTF8) { + utf8Title = Utf8String(title); + } else { + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } +#if 0 + CBRenderOSystem *renderer = static_cast(_renderer); + // TODO + + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotFilename(int slot, char *buffer) { + AnsiString dataDir = getDataDir(); + //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + strcpy(buffer, filename.c_str()); + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDataDir() { + AnsiString userDir = PathUtil::getUserDirectory(); + AnsiString baseDir = _registry->getBasePath(); + return PathUtil::combine(userDir, baseDir); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(filename))) { + _debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + + _debugAbsolutePathWarning = true; + strcpy(buffer, pm->_savedDescription); + delete pm; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isSaveSlotUsed(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!File) return false; + delete File; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::emptySaveSlot(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(this); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setActiveObject(CBObject *obj) { + // not-active when game is frozen + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; + } + + if (obj == _activeObject) return STATUS_OK; + + if (_activeObject) _activeObject->applyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + _activeObject = obj; + if (_activeObject) { + _activeObject->applyEvent("MouseEntry"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pushViewport(CBViewport *viewport) { + _viewportSP++; + if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); + else _viewportStack[_viewportSP] = viewport; + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) return STATUS_FAILED; + else { + if (_viewportSP >= 0) { + CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) *custom = true; + } else { + CBPlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) *custom = false; + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { + if (_viewportSP >= 0) { + if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; + if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) _transMgr->_origInteractive = state; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + if (_indicatorDisplay) displayIndicator(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayIndicator() { + if (_saveLoadImage) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + _renderer->setupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + + _renderer->setup2D(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::updateMusicCrossfade() { + /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + + if (!_musicCrossfadeRunning) return STATUS_OK; + if (_state == GAME_FROZEN) return STATUS_OK; + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + + if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); + if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; + + if (currentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); + + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); + + + if (_musicCrossfadeSwap) { + // swap channels + CBSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + CSysClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::invalidateDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::restoreDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) return true; + if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopVideo() { + if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return STATUS_FAILED; + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool CBGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) return STATUS_OK; + + _renderer->_active = activate; + + if (refreshMouse) { + Point32 p; + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); + } + + if (activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + return STATUS_OK; + } else return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayDebugInfo() { + char str[100]; + + if (_debugShowFPS) { + sprintf(str, "FPS: %d", _gameRef->_fps); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (_gameRef->_debugDebugMode) { + if (!_gameRef->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + else + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + + strcat(str, " ("); + strcat(str, _renderer->getName()); + strcat(str, ")"); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->displayDebugInfo(); + + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::getMousePos(Point32 *pos) { + CBPlatform::getCursorPos(pos); + + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { + Common::Rect rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= _gameRef->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= _gameRef->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); + + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); + + Point32 newPos = *pos; + + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::miniUpdate() { + if (!_miniUpdateEnabled) return STATUS_OK; + + if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->initLoop(); + _lastMiniUpdate = CBPlatform::getTime(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 pos; + CBPlatform::getCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); + + + if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = CBPlatform::getTime(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; + return false; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + _registry->saveValues(); + + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; + + SaveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BGame.h b/engines/wintermute/base/BGame.h new file mode 100644 index 0000000000..7441d81b07 --- /dev/null +++ b/engines/wintermute/base/BGame.h @@ -0,0 +1,391 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +#include "engines/wintermute/base/BDebugger.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/Rect32.h" +#include "common/events.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); + +class CBSoundMgr; +class CBFader; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRenderer; +class CBRegistry; +class CBSaveThumbHelper; +class CBSurfaceStorage; +class CSXMath; +class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) + + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); + + bool isLeftDoubleClick(); + bool isRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual bool miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + char *_localSaveDir; + bool _saveDirChecked; + + int _indicatorProgress; +protected: + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + CBSurface *_saveLoadImage; + bool displayIndicator(); + + bool _reportTextureFormat; +public: + int _thumbnailWidth; + int _thumbnailHeight; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; + + bool _doNotExpandStrings; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; + CBDebugger *getDebugMgr(); + + void LOG(bool res, const char *fmt, ...); + + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; + CBGame(); + + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + bool _debugAbsolutePathWarning; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + + CBStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; +protected: + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + CBFader *_fader; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); +public: + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + +private: + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; +public: + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + virtual bool handleMouseWheel(int delta); + bool _quitting; + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual void handleKeyRelease(Common::Event *event); +protected: + int _freezeLevel; +public: + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(CUIWindow *window); + CVidPlayer *_videoPlayer; + CVidTheoraPlayer *_theoraPlayer; + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; +protected: + static void afterLoadRegion(void *region, void *data); + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +public: + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); + CBRegistry *_registry; + bool _useD3D; + virtual bool cleanup(); + virtual bool loadGame(int slot); + virtual bool loadGame(const char *filename); + virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + Point32 _mousePos; + bool validObject(CBObject *object); + bool unregisterObject(CBObject *object); + bool registerObject(CBObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + + CBArray _regObjects; +public: + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); + bool _forceNonStreamedSounds; + void resetMousePos(); + int _subtitlesSpeed; + void setInteractive(bool state); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(CBViewport *Viewport); + bool setActiveObject(CBObject *Obj); + CBSprite *_lastCursor; + bool drawCursor(CBSprite *Cursor); + + virtual bool initAfterLoad(); + CBSaveThumbHelper *_cachedThumbnail; + AnsiString getDataDir(); + void addMem(int bytes); + + bool _touchInterface; + bool _constrainedMemory; + AnsiString getDeviceType() const; + +private: + CBDebugger *_debugMgr; + + struct LastClickInfo { + LastClickInfo() { + posX = posY = 0; + time = 0; + } + + int posX; + int posY; + uint32 time; + }; + + LastClickInfo _lastClick[2]; + bool isDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void autoSaveOnExit(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BKeyboardState.cpp b/engines/wintermute/base/BKeyboardState.cpp new file mode 100644 index 0000000000..85ab15f58e --- /dev/null +++ b/engines/wintermute/base/BKeyboardState.cpp @@ -0,0 +1,304 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BKeyboardState.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + delete[] _keyStates; +} + +void CBKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void CBKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; + } else vKey = val->getInt(); + + warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->setString(key); + } else _scValue->setString(""); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Printable") == 0) { + _scValue->setBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KeyCode") == 0) { + _scValue->setInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsShift") == 0) { + _scValue->setBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsAlt") == 0) { + _scValue->setBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsControl") == 0) { + _scValue->setBool(_currentControl); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::readKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = keyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { + //if(!persistMgr->_saving) cleanup(); + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); + + if (!persistMgr->_saving) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +enum VKeyCodes { + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BKeyboardState.h b/engines/wintermute/base/BKeyboardState.h new file mode 100644 index 0000000000..e3a4a903f7 --- /dev/null +++ b/engines/wintermute/base/BKeyboardState.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BScriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + bool readKey(Common::Event *event); + + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + uint8 *_keyStates; + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BNamedObject.cpp b/engines/wintermute/base/BNamedObject.cpp new file mode 100644 index 0000000000..9587da45e8 --- /dev/null +++ b/engines/wintermute/base/BNamedObject.cpp @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BNamedObject.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::setName(const char *name) { + delete[] _name; + + _name = new char [strlen(name) + 1]; + if (_name != NULL) strcpy(_name, name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BNamedObject.h b/engines/wintermute/base/BNamedObject.h new file mode 100644 index 0000000000..4d5fdb0c0e --- /dev/null +++ b/engines/wintermute/base/BNamedObject.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *_name; + void setName(const char *name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp new file mode 100644 index 0000000000..1bb52c0ce6 --- /dev/null +++ b/engines/wintermute/base/BObject.cpp @@ -0,0 +1,1128 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = _gameRef->getSequence(); + + CBPlatform::setRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) + _caption[i] = NULL; + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) + _gameRef->_activeObject = NULL; + + CBScriptHolder::cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) + return; + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::getCaption(int caseVal) { + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else return _caption[caseVal - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + afterMove(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->getInt())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveCursor") == 0) { + stack->correctParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursor") == 0) { + stack->correctParams(0); + if (!_cursor || !_cursor->_filename) stack->pushNULL(); + else stack->pushString(_cursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursorObject") == 0) { + stack->correctParams(0); + if (!_cursor) stack->pushNULL(); + else stack->pushNative(_cursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasCursor") == 0) { + stack->correctParams(0); + + if (_cursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCaption") == 0) { + stack->correctParams(2); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadSound") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + if (DID_SUCCEED(playSFX(filename, false, false))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySound") == 0) { + stack->correctParams(3); + + const char *filename; + bool looping; + uint32 loopStart; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + + if (val1->_type == VAL_BOOL) { + filename = NULL; + looping = val1->getBool(); + loopStart = val2->getInt(); + } else { + if (val1->isNULL()) filename = NULL; + else filename = val1->getString(); + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); + } + + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->correctParams(2); + + const char *filename; + const char *eventName; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + + if (val2->isNULL()) { + filename = NULL; + eventName = val1->getString(); + } else { + filename = val1->getString(); + eventName = val2->getString(); + } + + if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(pauseSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(resumeSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->correctParams(0); + + if (_sFX && _sFX->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->correctParams(1); + + uint32 Time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(0); + else stack->pushInt(_sFX->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->correctParams(1); + + int volume = stack->pop()->getInt(); + if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(_sFXVolume); + else stack->pushInt(_sFX->getVolumePercent()); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXNone") == 0) { + stack->correctParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->correctParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->correctParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + _scValue->setString(getCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(getHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ready") == 0) { + _scValue->setBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _scValue->setBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _scValue->setBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _scValue->setBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _scValue->setBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + _scValue->setInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (_scale < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (_scaleX < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (_scaleY < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _scValue->setFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (!_rotateValid) _scValue->setNULL(); + else _scValue->setFloat((double)_rotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _scValue->setFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _scValue->setBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _scValue->setBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _scValue->setBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _scValue->setBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + _scValue->setNULL(); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Caption") == 0) { + setCaption(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _movable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _registrable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _zoomable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _rotatable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alphaColor = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + int i = value->getInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + _blendMode = (TSpriteBlendMode)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (value->isNULL()) _scale = -1; + else _scale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (value->isNULL()) _scaleX = -1; + else _scaleX = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (value->isNULL()) _scaleY = -1; + else _scaleY = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _relativeScale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (value->isNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)value->getFloat(); + _rotateValid = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _relativeRotate = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _shadowable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _autoSoundPanning = value->getBool(); + if (!_autoSoundPanning) resetSoundPan(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _saveState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::showCursor() { + if (_cursor) return _gameRef->drawCursor(_cursor); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { + // just play loaded sound + if (filename == NULL && _sFX) { + if (_gameRef->_editorMode || _sFXStart) { + _sFX->setVolumePercent(_sFXVolume); + _sFX->setPositionTime(_sFXStart); + if (!_gameRef->_editorMode) _sFXStart = 0; + } + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } + + if (filename == NULL) return STATUS_FAILED; + + // create new sound + delete _sFX; + + _sFX = new CBSound(_gameRef); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); + if (_sFXStart) { + _sFX->setPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } else { + delete _sFX; + _sFX = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::pauseSFX() { + if (_sFX) return _sFX->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resumeSFX() { + if (_sFX) return _sFX->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) return _sFX->setVolumePercent(volume); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) updateOneSound(_sFX); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateOneSound(CBSound *sound) { + bool Ret = STATUS_OK; + + if (sound) { + if (_autoSoundPanning) + Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + + Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resetSoundPan() { + if (!_sFX) return STATUS_OK; + else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, eventName); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BObject.h b/engines/wintermute/base/BObject.h new file mode 100644 index 0000000000..c855c770b7 --- /dev/null +++ b/engines/wintermute/base/BObject.h @@ -0,0 +1,144 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "engines/wintermute/base/BScriptHolder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(CBSound *sound); + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + CBSound *_sFX; + + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + + virtual bool handleMouseWheel(int delta); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); + const char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual bool showCursor(); + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + Rect32 _rect; + bool _rectSet; + int _iD; + bool _movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; + + // base + virtual bool update() { + return STATUS_FAILED; + }; + virtual bool display() { + return STATUS_FAILED; + }; + virtual bool invalidateDeviceObjects() { + return STATUS_OK; + }; + virtual bool restoreDeviceObjects() { + return STATUS_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPackage.cpp b/engines/wintermute/base/BPackage.cpp new file mode 100644 index 0000000000..020b7b902f --- /dev/null +++ b/engines/wintermute/base/BPackage.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPackage.h b/engines/wintermute/base/BPackage.h new file mode 100644 index 0000000000..8c803fddd9 --- /dev/null +++ b/engines/wintermute/base/BPackage.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/BBase.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp new file mode 100644 index 0000000000..f675d0ca50 --- /dev/null +++ b/engines/wintermute/base/BParser.cpp @@ -0,0 +1,436 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (_whiteSpace != NULL) delete [] _whiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + skipCharacters(buf, _whiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else strcpy(_lastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + skipCharacters(buf, _whiteSpace); + + // get optional name + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = getAssignmentText(buf); + else + *data = getSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + _gameRef->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') _parserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getAssignmentText(char **buf) { + ++*buf; // skip the '=' + skipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = getSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::getToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::getTokenFloat(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::getTokenInt(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { + char *t = getToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::scanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BParser.h b/engines/wintermute/base/BParser.h new file mode 100644 index 0000000000..ae886953a9 --- /dev/null +++ b/engines/wintermute/base/BParser.h @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, TokenDesc *tokens, char **params); + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + char *getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + char *_whiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp new file mode 100644 index 0000000000..0f2cc6bc8a --- /dev/null +++ b/engines/wintermute/base/BPersistMgr.cpp @@ -0,0 +1,778 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BPersistMgr.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BSound.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + delete[] _savedDescription; + _savedDescription = NULL; // ref to buffer +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; + } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; +} + +Common::String CBPersistMgr::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); +} + +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void CBPersistMgr::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 CBPersistMgr::getMaxUsedSlot() { + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); it++) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool CBPersistMgr::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initSave(const char *desc) { + if (!desc) return STATUS_FAILED; + + cleanup(); + _saving = true; + + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); + + if (_saveStream) { + // get thumbnails + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + } + } + + uint32 magic = DCGF_MAGIC; + putDWORD(magic); + + magic = SAVE_MAGIC_2; + putDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(VerMajor); + _saveStream->writeByte(VerMinor); + _saveStream->writeByte(ExtMajor); + _saveStream->writeByte(ExtMinor); + + // new in ver 2 + putDWORD((uint32)DCGF_VER_BUILD); + putString(_gameRef->_name); + + // thumbnail data size + bool thumbnailOK = false; + + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } + + thumbnailOK = true; + } + } + if (!thumbnailOK) putDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + + uint32 dataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(desc) + 1 + // description + sizeof(uint32); // timestamp + + putDWORD(dataOffset); + putString(desc); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); + } + return STATUS_OK; +} + +bool CBPersistMgr::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + if (_loadStream) { + uint32 magic; + magic = getDWORD(); + + if (magic != DCGF_MAGIC) { + cleanup(); + return STATUS_FAILED; + } + + magic = getDWORD(); + + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); + + if (magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)getDWORD(); + _savedName = getStringObj(); + + // load thumbnail + _thumbnailDataSize = getDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + getBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; + } + } else _savedVerBuild = 35; // last build with ver1 savegames + + uint32 dataOffset = getDWORD(); + + _savedDescription = getString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); + + _offset = dataOffset; + + return STATUS_OK; + } + } + + cleanup(); + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initLoad(const char *filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + cleanup(); + return STATUS_FAILED; + } + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + + } + + /* + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::saveFile(const char *filename) { + return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putString(const Common::String &val) { + if (!val.size()) putString("(null)"); + else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String CBPersistMgr::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + Common::String retString = ret; + delete[] ret; + + if (retString == "(null)") { + retString = ""; + } + + return retString; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::getString() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else return ret; +} + +bool CBPersistMgr::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +TimeDate CBPersistMgr::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + +void CBPersistMgr::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float CBPersistMgr::getFloat() { + char *str = getString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +void CBPersistMgr::putDouble(double val) { + Common::String str = Common::String::format("F%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double CBPersistMgr::getDouble() { + char *str = getString(); + double value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool CBPersistMgr::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// int +bool CBPersistMgr::transfer(const char *name, int *val) { + if (_saving) { + _saveStream->writeSint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +bool CBPersistMgr::transfer(const char *name, uint32 *val) { + if (_saving) { + _saveStream->writeUint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readUint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// float +bool CBPersistMgr::transfer(const char *name, float *val) { + if (_saving) { + putFloat(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// double +bool CBPersistMgr::transfer(const char *name, double *val) { + if (_saving) { + putDouble(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getDouble(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// char* +bool CBPersistMgr::transfer(const char *name, char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// const char* +bool CBPersistMgr::transfer(const char *name, const char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +bool CBPersistMgr::transfer(const char *name, Common::String *val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { + size_t size; + + if (_saving) { + size = val.size(); + _saveStream->writeUint32LE(size); + + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); + } + } else { + val.clear(); + size = _loadStream->readUint32LE(); + + for (size_t i = 0; i < size; i++) { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) val.push_back(str); + delete[] str; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +bool CBPersistMgr::transfer(const char *name, byte *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +bool CBPersistMgr::transfer(const char *name, Rect32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +bool CBPersistMgr::transfer(const char *name, Point32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +bool CBPersistMgr::transfer(const char *name, Vector2 *val) { + if (_saving) { + putFloat(val->x); + putFloat(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = getFloat(); + val->y = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +bool CBPersistMgr::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { + if (_saving) return true; + + // it's ok if we are same or newer than the saved game + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPersistMgr.h b/engines/wintermute/base/BPersistMgr.h new file mode 100644 index 0000000000..2e6ee8058c --- /dev/null +++ b/engines/wintermute/base/BPersistMgr.h @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/savestate.h" +#include "common/stream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/rect.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *_savedDescription; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const char *filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + Common::String getStringObj(); + void putString(const Common::String &val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); + bool initLoad(const char *filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool _saving; + + uint32 _richBufferSize; + byte *_richBuffer; + + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~CBPersistMgr(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + bool putTimeDate(const TimeDate &t); + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BPoint.cpp b/engines/wintermute/base/BPoint.cpp new file mode 100644 index 0000000000..4c80e154f2 --- /dev/null +++ b/engines/wintermute/base/BPoint.cpp @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPoint::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPoint.h b/engines/wintermute/base/BPoint.h new file mode 100644 index 0000000000..3e4adb5d13 --- /dev/null +++ b/engines/wintermute/base/BPoint.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BQuickMsg.cpp b/engines/wintermute/base/BQuickMsg.cpp new file mode 100644 index 0000000000..32bd04afe2 --- /dev/null +++ b/engines/wintermute/base/BQuickMsg.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BQuickMsg.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) strcpy(_text, text); + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (_text) delete [] _text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::getText() { + return _text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BQuickMsg.h b/engines/wintermute/base/BQuickMsg.h new file mode 100644 index 0000000000..c247183714 --- /dev/null +++ b/engines/wintermute/base/BQuickMsg.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *getText(); + uint32 _startTime; + char *_text; + CBQuickMsg(CBGame *inGame, const char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp new file mode 100644 index 0000000000..1c38174cb8 --- /dev/null +++ b/engines/wintermute/base/BRegion.cpp @@ -0,0 +1,508 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::cleanup() { + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + CBPlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::pointInRegion(int x, int y) { + if (_points.getSize() < 3) return false; + + Point32 pt; + pt.x = x; + pt.y = y; + + Rect32 rect; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; + + if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int i; + + for (i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AddPoint") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + _points.add(new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points.insertAt(Index, new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points[Index]->x = x; + _points[Index]->y = y; + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemovePoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + delete _points[index]; + _points[index] = NULL; + + _points.removeAt(index); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + CScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); + } + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.getSize()); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", nameOverride); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::ptInPolygon(int x, int y) { + if (_points.getSize() < 3) return false; + + int counter = 0; + double xinters; + dPoint p, p1, p2; + + p.x = (double)x; + p.y = (double)y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (int i = 1; i <= _points.getSize(); i++) { + p2.x = (double)_points[i % _points.getSize()]->x; + p2.y = (double)_points[i % _points.getSize()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < _points.getSize(); i++) { + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); + + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); + } + CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < region->_points.getSize(); i++) { + int xVal, yVal; + + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(xVal + x, yVal + y)); + } + + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; + + return createRegion() ? STATUS_OK : STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegion.h b/engines/wintermute/base/BRegion.h new file mode 100644 index 0000000000..2a92d9daff --- /dev/null +++ b/engines/wintermute/base/BRegion.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "engines/wintermute/base/BPoint.h" +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); + bool ptInPolygon(int x, int y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool _active; + int _editorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + Rect32 _rect; + CBArray _points; + virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BRegistry.cpp b/engines/wintermute/base/BRegistry.cpp new file mode 100644 index 0000000000..fef09d7479 --- /dev/null +++ b/engines/wintermute/base/BRegistry.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/tinyxml/tinyxml.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/utils.h" +#include "common/config-manager.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + _iniName = NULL; + + setIniName("./wme.ini"); + loadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + saveValues(); + delete[] _iniName; + _iniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + + bool found = false; + ret = getValue(_localValues, subKey, key, found); + if (!found) ret = getValue(_values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + _values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + if (ConfMan.hasKey("master_volume")) { + return ConfMan.getInt("master_volume"); + } else { + return init; + } + } else if (key == "SFXVolume") { + if (ConfMan.hasKey("sfx_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "SpeechVolume") { + if (ConfMan.hasKey("speech_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "MusicVolume") { + if (ConfMan.hasKey("music_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } + } + AnsiString val = readString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + ConfMan.setInt("master_volume", value); + return true; + } else if (key == "SFXVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "SpeechVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "MusicVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } + } + writeString(subKey, key, StringUtil::toString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (readInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return writeInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setIniName(const char *name) { + delete[] _iniName; + _iniName = NULL; + + if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { + _iniName = new char [strlen(name) + 3]; + sprintf(_iniName, "./%s", name); + } else { + _iniName = new char [strlen(name) + 1]; + strcpy(_iniName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::getIniName() { + return _iniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadValues(bool local) { + if (local) loadXml("settings.xml", _localValues); + else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveValues() { + saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setBasePath(const char *basePath) { + _basePath = PathUtil::getFileNameWithoutExtension(basePath); + + loadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it)._value; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt)._value; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName.c_str()); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::createPath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt)._value; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + Common::DumpFile stream; + stream.open(fileName.c_str()); + + if (!stream.isOpen()) return; + else { + stream.write(printer.CStr(), printer.Size()); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegistry.h b/engines/wintermute/base/BRegistry.h new file mode 100644 index 0000000000..123d1d8a2f --- /dev/null +++ b/engines/wintermute/base/BRegistry.h @@ -0,0 +1,76 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void setIniName(const char *name); + char *getIniName(); + bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); + int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void setBasePath(const char *basePath); + AnsiString getBasePath() const { + return _basePath; + } + + void loadValues(bool local); + void saveValues(); + +private: + char *_iniName; + + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; + + PathValueMap _localValues; + PathValueMap _values; + + AnsiString _basePath; + + void loadXml(const AnsiString fileName, PathValueMap &values); + void saveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp new file mode 100644 index 0000000000..b99441b5db --- /dev/null +++ b/engines/wintermute/base/BResources.cpp @@ -0,0 +1,2820 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BResources.h" +#include "common/str.h" +#include "common/memstream.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + +Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { + if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BResources.h b/engines/wintermute/base/BResources.h new file mode 100644 index 0000000000..6ec0541b5c --- /dev/null +++ b/engines/wintermute/base/BResources.h @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace WinterMute { + +class CBResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &fileName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSaveThumbHelper.cpp b/engines/wintermute/base/BSaveThumbHelper.cpp new file mode 100644 index 0000000000..415d4ed1e4 --- /dev/null +++ b/engines/wintermute/base/BSaveThumbHelper.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSaveThumbHelper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + if (doFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + } + + CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) return STATUS_FAILED; + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new CBImage(_gameRef); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); + } + + + delete screenshot; + screenshot = NULL; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSaveThumbHelper.h b/engines/wintermute/base/BSaveThumbHelper.h new file mode 100644 index 0000000000..30db32cfb2 --- /dev/null +++ b/engines/wintermute/base/BSaveThumbHelper.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + CBImage *_thumbnail; + CBImage *_richThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BScriptHolder.cpp b/engines/wintermute/base/BScriptHolder.cpp new file mode 100644 index 0000000000..65d37b2e5c --- /dev/null +++ b/engines/wintermute/base/BScriptHolder.cpp @@ -0,0 +1,473 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/AdGame.h" +#include "engines/wintermute/base/BScriptHolder.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) delete [] _filename; + + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + if (handler) { + //_scripts.add(handler); + numHandlers++; + ret = STATUS_OK; + } + } + } + if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->correctParams(0); + byte *p = 0; + *p = 10; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ApplyEvent") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool ret; + ret = applyEvent(val->getString()); + + if (DID_SUCCEED(ret)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AttachScript") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DetachScript") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool killThreads = stack->pop()->getBool(false); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + _scripts[i]->finish(killThreads); + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { + return CBBase::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_name)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::addScript(const char *filename) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + return STATUS_OK; + } + } + } + + CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.add(scr); + _gameRef->_scEngine->_scripts.add(scr); + _gameRef->getDebugMgr()->onScriptInit(scr); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::removeScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) { + _scripts.removeAt(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleEvent(const char *EventName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleMethod(const char *MethodName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + _gameRef->LOG(0, "'PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading PROPERTY definition"); + return STATUS_FAILED; + } + + + CScValue *val = new CScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->_freezable = freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.getSize() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (_name && strcmp(_name, "") != 0) { + strcat(buf, " Name: "); + strcat(buf, _name); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::sendEvent(const char *eventName) { + return DID_SUCCEED(applyEvent(eventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptHolder.h b/engines/wintermute/base/BScriptHolder.h new file mode 100644 index 0000000000..1e82b8cacf --- /dev/null +++ b/engines/wintermute/base/BScriptHolder.h @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CBScriptHolder : public CBScriptable { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + virtual CScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + bool cleanup(); + bool removeScript(CScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + bool parseProperty(byte *buffer, bool complete = true); + char *_filename; + bool _freezable; + bool _ready; + + CBArray _scripts; + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +public: + virtual bool sendEvent(const char *eventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BScriptable.cpp b/engines/wintermute/base/BScriptable.cpp new file mode 100644 index 0000000000..d1e3556a85 --- /dev/null +++ b/engines/wintermute/base/BScriptable.cpp @@ -0,0 +1,188 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { + _refCount = 0; + + if (noValue) _scValue = NULL; + else _scValue = new CScValue(_gameRef); + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->getProp(name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scSetProperty(const char *name, CScValue *value) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->setProp(name, value); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scCompare(CBScriptable *val) { + if (this < val) return -1; + else if (this > val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::dbgGetNativeClass() { + return getClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { + return scGetProperty(name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptable.h b/engines/wintermute/base/BScriptable.h new file mode 100644 index 0000000000..534bd3bdf1 --- /dev/null +++ b/engines/wintermute/base/BScriptable.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/base/BNamedObject.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool canHandleMethod(const char *eventMethod); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(CBScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + CScValue *_scValue; + CScValue *_scProp; + +public: + // IWmeDebugObject + const char *dbgGetNativeClass(); + IWmeDebugProp *dbgGetProperty(const char *name); + +}; + +// Implemented in their respective .cpp-files +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXMath(CBGame *inGame); +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXStore(CBGame *inGame); +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSound.cpp b/engines/wintermute/base/BSound.cpp new file mode 100644 index 0000000000..2b54b39500 --- /dev/null +++ b/engines/wintermute/base/BSound.cpp @@ -0,0 +1,288 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSoundBuffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + _sound = NULL; + _soundFilename = NULL; + + _soundType = Audio::Mixer::kSFXSoundType; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (_sound) _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + + delete[] _soundFilename; + _soundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + delete[] _soundFilename; + _soundFilename = NULL; + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = new char[strlen(filename) + 1]; + strcpy(_soundFilename, filename); + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSoundSimple() { + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->setPosition(_soundPosition); + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->resume(); + else return STATUS_OK; + } else return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getLength() { + if (_sound) return _sound->getLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) _sound->_freezePaused = true; + return _sound->pause(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::persist(CBPersistMgr *persistMgr) { + if (persistMgr->_saving && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) + _soundPosition = _sound->getPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPaused() { + return _sound && _soundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPositionTime(uint32 time) { + if (!_sound) return STATUS_FAILED; + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) + _soundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getPositionTime() { + if (!_sound) return 0; + + if (!_sound->isPlaying()) + return 0; + else return _sound->getPosition(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolumePercent(int percent) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(percent * 255 / 100); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(volume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPrivateVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->_privateVolume = volume; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolumePercent() { + if (!_sound) + return 0; + else return _sound->_privateVolume * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolume() { + if (!_sound) + return 0; + else return _sound->_privateVolume; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setLoopStart(uint32 pos) { + if (!_sound) + return STATUS_FAILED; + else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPan(float pan) { + if (_sound) + return _sound->setPan(pan); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { + if (!_sound) + return STATUS_OK; + + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + bool ret = _sound->applyFX(type, param1, param2, param3, param4); + + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; + + return ret; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSound.h b/engines/wintermute/base/BSound.h new file mode 100644 index 0000000000..9dc825e4ac --- /dev/null +++ b/engines/wintermute/base/BSound.h @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "audio/mixer.h" + +namespace WinterMute { + +class CBSoundBuffer; +class CBSound : public CBBase { +public: + bool setPan(float pan); + int _soundPrivateVolume; + int getVolume(); + int getVolumePercent(); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); + uint32 getPositionTime(); + bool setPositionTime(uint32 time); + bool _soundPaused; + bool _soundFreezePaused; + bool isPlaying(); + bool isPaused(); + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + char *_soundFilename; + bool setSoundSimple(); + bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + +private: + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSoundBuffer.cpp b/engines/wintermute/base/BSoundBuffer.cpp new file mode 100644 index 0000000000..4808cc9007 --- /dev/null +++ b/engines/wintermute/base/BSoundBuffer.cpp @@ -0,0 +1,383 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BSoundBuffer.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" +#include "common/system.h" +#include "common/substream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; + + delete[] _filename; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + _streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +#if 0 + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } +#endif + + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = _gameRef->_fileManager->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + Common::String strFilename(filename); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); + } else if (strFilename.hasSuffix(".wav")) { + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + } + } + } else { + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + } + if (!_stream) { + return STATUS_FAILED; + } + CBUtils::setString(&_filename, filename); + + return STATUS_OK; +#if 0 + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { + _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); + return STATUS_FAILED; + } + + CBUtils::setString(&_filename, filename); + + /* + bool res; + bool NewlyCreated = false; + + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = _gameRef->_fileManager->openFile(filename); + if(!_file){ + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + // switch to streamed for big files + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!_soundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(_file); + if(DID_FAIL(res)){ + _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); + return res; + } + } + + + + // store filename + if(!_filename){ + _filename = new char[strlen(filename)+1]; + strcpy(_filename, filename); + } + + // close file (if not streaming) + if(!_streamed && _file){ + _gameRef->_fileManager->closeFile(_file); + _file = NULL; + } + */ + + return STATUS_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; + if (looping) { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setLooping(bool looping) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + _looping = looping; +#if 0 + + + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::resume() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setVolume(int volume) { + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; + if (_stream && _handle) { + byte vol = (byte)(_volume); + g_system->getMixer()->setChannelVolume(*_handle, vol); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPosition(uint32 pos) { + warning("CBSoundBuffer::SetPosition - not implemented yet"); +#if 0 + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); + } +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; +#if 0 + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; + } + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return STATUS_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("CBSoundBuffer::ApplyFX - not implemented yet"); + switch (type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundBuffer.h b/engines/wintermute/base/BSoundBuffer.h new file mode 100644 index 0000000000..9384670fbb --- /dev/null +++ b/engines/wintermute/base/BSoundBuffer.h @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "engines/wintermute/base/BBase.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); + bool isPlaying(); + + void setLooping(bool looping); + + uint32 getPosition(); + bool setPosition(uint32 pos); + uint32 getLength(); + + bool setLoopStart(uint32 pos); + uint32 getLoopStart() const { + return _loopStart; + } + + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); + void updateVolume(); + + void setType(Audio::Mixer::SoundType Type); + + bool loadFromFile(const char *filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + Common::SeekableReadStream *_file; + char *_filename; + bool _streamed; + + int _privateVolume; +private: + int _volume; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp new file mode 100644 index 0000000000..8d9b775c68 --- /dev/null +++ b/engines/wintermute/base/BSoundMgr.cpp @@ -0,0 +1,292 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSoundMgr.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BSoundBuffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::cleanup() { + for (int i = 0; i < _sounds.size(); i++) + delete _sounds[i]; + _sounds.clear(); +#if 0 + BASS_Free(); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::saveSettings() { + if (_soundAvailable) { + _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _soundAvailable = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initLoop() { + if (!_soundAvailable) + return STATUS_OK; +#if 0 + + BASS_Update(500); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (!_soundAvailable) + return NULL; + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (_gameRef->_fileManager->hasFile(newFile)) { + filename = newFile.c_str(); + } + } + + sound = new CBSoundBuffer(_gameRef); + if (!sound) return NULL; + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", filename); + delete sound; + return NULL; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { + if (!sound) + return STATUS_FAILED; + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i] == sound) { + delete _sounds[i]; + _sounds.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { + if (!_soundAvailable) + return STATUS_OK; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); + break; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); + break; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); + break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); + } + g_wintermute->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { + int volume = 0; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); + break; + default: + error("Sound-type not set"); + break; + } + + return (byte)(volume * 100 / 255); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (int i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::pauseAll(bool includingMusic) { + + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + _sounds[i]->pause(); + _sounds[i]->_freezePaused = true; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::resumeAll() { + + for (int i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)_gameRef->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundMgr.h b/engines/wintermute/base/BSoundMgr.h new file mode 100644 index 0000000000..a021abadaa --- /dev/null +++ b/engines/wintermute/base/BSoundMgr.h @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace WinterMute { +class CBSoundBuffer; +class CBSoundMgr : public CBBase { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte getMasterVolumePercent(); + byte getMasterVolume(); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); + byte getVolumePercent(Audio::Mixer::SoundType type); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); + uint32 _volumeOriginal; + int _volumeMaster; + bool removeSound(CBSoundBuffer *sound); + CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initLoop(); + bool initialize(); + bool _soundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + Common::Array _sounds; + void saveSettings(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp new file mode 100644 index 0000000000..c93a40ca75 --- /dev/null +++ b/engines/wintermute/base/BSprite.cpp @@ -0,0 +1,758 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + setName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::cleanup() { + CBScriptHolder::cleanup(); + + for (int i = 0; i < _frames.getSize(); i++) + delete _frames[i]; + _frames.removeAll(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + GetCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->afterMove(); + + x = _owner->_posX; + y = _owner->_posY; + } + + // draw frame + return display(x, y, registerOwner, zoomX, zoomY, alpha); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + if (!file) { + _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + else return loadFile("invalid.bmp", lifeTime, cacheType); + } else { + _gameRef->_fileManager->closeFile(file); + file = NULL; + } + + bool ret; + + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + CBFrame *frame = new CBFrame(_gameRef); + CBSubFrame *subframe = new CBSubFrame(_gameRef); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer) { + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + delete [] buffer; + } + } + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + cleanup(); + + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + _gameRef->LOG(0, "'SPRITE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int frameCount = 1; + CBFrame *frame; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.scanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.scanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.scanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.scanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.scanStr((char *)params, "%b", &_streamed); + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (_gameRef->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.scanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(_gameRef); + + if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + delete frame; + _gameRef->LOG(0, "Error parsing frame %d", frameCount); + return STATUS_FAILED; + } + + _frames.add(frame); + frameCount++; + if (_currentFrame == -1) _currentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITE definition"); + return STATUS_FAILED; + } + _canBreak = !_continuous; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::reset() { + if (_frames.getSize() > 0) _currentFrame = 0; + else _currentFrame = -1; + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { + //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) return false; + + uint32 timer; + if (_owner && _owner->_freezable) timer = _gameRef->_timer; + else timer = _gameRef->_liveTimer; + + int lastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.getSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + killAllSounds(); + } + applyEvent("FrameChanged"); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.getSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + CBPlatform::setRectEmpty(rect); + for (int i = 0; i < _frames.getSize(); i++) { + Rect32 frame; + Rect32 temp; + CBPlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (_editorMuted) + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + + if (_editorBgFile) { + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + CBScriptHolder::saveAsText(buffer, indent + 2); + + int i; + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + + for (i = 0; i < _frames.getSize(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int Index = stack->pop()->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + stack->pushNULL(); + } else stack->pushNative(_frames[Index], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteFrame") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (Val->isInt()) { + int Index = Val->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->getNative(); + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddFrame") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.add(sub); + } else delete sub; + } + _frames.add(frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertFrame") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) + index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) + filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); + else delete sub; + } + + if (index >= _frames.getSize()) + _frames.add(frame); + else _frames.insertAt(index, frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _paused = true; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Play") == 0) { + stack->correctParams(0); + _paused = false; + stack->pushNULL(); + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFrames") == 0) { + _scValue->setInt(_frames.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentFrame") == 0) { + _scValue->setInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _scValue->setBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Owner") == 0) { + if (_owner == NULL) _scValue->setNULL(); + else _scValue->setNative(_owner, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Finished") == 0) { + _scValue->setBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Paused") == 0) { + _scValue->setBool(_paused); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _precise = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _looping = value->getBool(); + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::killAllSounds() { + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i]->_sound) + _frames[i]->_sound->stop(); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSprite.h b/engines/wintermute/base/BSprite.h new file mode 100644 index 0000000000..3c67e5f3fe --- /dev/null +++ b/engines/wintermute/base/BSprite.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BScriptHolder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + bool killAllSounds(); + CBSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool _editorAllFrames; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + int _moveY; + int _moveX; + bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void reset(); + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + uint32 _lastFrameTime; + bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + CBSprite(CBGame *inGame, CBObject *owner = NULL); + virtual ~CBSprite(); + CBArray _frames; + bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp new file mode 100644 index 0000000000..44f26ba7e8 --- /dev/null +++ b/engines/wintermute/base/BStringTable.cpp @@ -0,0 +1,229 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BStringTable.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return STATUS_FAILED; + + if (scumm_stricmp(key, "@right-to-left") == 0) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + _stringsIter = _strings.find(finalKey); + if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + + _strings[finalKey] = val; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; + + const char *value = strchr(str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = getKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::expand(char **str, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return; + + if (str == NULL || *str == NULL || *str[0] != '/') return; + + char *value = strchr(*str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *str; + *str = new_str; + + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return string; + + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; + + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; + + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) _strings.clear(); + + uint32 size; + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + uint32 pos = 0; + + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else _gameRef->_textEncoding = TEXT_ANSI; + + uint32 lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (uint32 i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); + } + + delete [] line; + pos += lineLength + 1; + } + + delete [] buffer; + + _gameRef->LOG(0, " %d strings loaded", _strings.size()); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BStringTable.h b/engines/wintermute/base/BStringTable.h new file mode 100644 index 0000000000..92d3604b4d --- /dev/null +++ b/engines/wintermute/base/BStringTable.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *expandStatic(const char *string, bool forceExpand = false); + bool loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + bool addString(const char *key, const char *val, bool reportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + Common::HashMap _strings; + char *getKey(const char *str); +private: + Common::HashMap::iterator _stringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp new file mode 100644 index 0000000000..60048ac05a --- /dev/null +++ b/engines/wintermute/base/BSubFrame.cpp @@ -0,0 +1,589 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + CBPlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + CBPlatform::setRectEmpty(&rect); + char *surfaceFile = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); + return STATUS_FAILED; + } + + if (surfaceFile != NULL) { + if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + + /* + if(_surface == NULL) + { + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); + return STATUS_FAILED; + } + */ + if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + else _rect = rect; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) return STATUS_OK; + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + } else { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + } + } + if (_gameRef->_suspendedRendering) return STATUS_OK; + + bool res; + + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) alpha = _alpha; + + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; + + CBPlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { + if (complete) + buffer->putTextIndent(indent, "SUBFRAME {\n"); + + if (_surface && _surface->getFileNameStr() != "") + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + + if (_transparent != 0xFFFF00FF) + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + + Rect32 rect; + CBPlatform::setRectEmpty(&rect); + if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!CBPlatform::equalRect(&rect, &_rect)) + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + + if (_hotspotX != 0 || _hotspotY != 0) + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + + if (_alpha != 0xFFFFFFFF) { + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + } + + if (_mirrorX) + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + + if (_mirrorY) + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + + if (_2DOnly) + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + + if (_3DOnly) + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + + if (_decoration) + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + + if (_editorSelected) + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + + if (complete) + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::setDefaultRect() { + if (_surface) { + CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + + if (!_surfaceFilename) stack->pushNULL(); + else stack->pushString(_surfaceFilename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (Val->isNULL()) { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; + stack->pushBool(true); + } else { + const char *filename = Val->getString(); + if (DID_SUCCEED(setSurface(filename))) { + setDefaultRect(); + stack->pushBool(true); + } else stack->pushBool(false); + } + + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + + _scValue->setInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TransparentColor") == 0) { + _scValue->setInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _scValue->setBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _scValue->setBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _scValue->setBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _scValue->setBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _scValue->setInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _scValue->setInt(_hotspotY); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _2DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _3DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _mirrorX = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _mirrorY = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _hotspotX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _hotspotY = value->getInt(); + return STATUS_OK; + } + + else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(filename) + 1]; + strcpy(_surfaceFilename, filename); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return STATUS_OK; + } + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return STATUS_OK; + else return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSubFrame.h b/engines/wintermute/base/BSubFrame.h new file mode 100644 index 0000000000..57ffcae675 --- /dev/null +++ b/engines/wintermute/base/BSubFrame.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void setDefaultRect(); + uint32 _transparent; + bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool _editorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + Rect32 _rect; + + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + CBSurface *_surface; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp new file mode 100644 index 0000000000..f50d174898 --- /dev/null +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -0,0 +1,189 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::cleanup(bool warn) { + for (int i = 0; i < _surfaces.size(); i++) { + if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::initLoop() { + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; + sortSurfaces(); + for (int i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::removeSurface(CBSurface *surface) { + for (int i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + for (int i = 0; i < _surfaces.size(); i++) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!_gameRef->_fileManager->hasFile(filename)) { + if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); + if (_gameRef->_debugDebugMode) + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + else + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + + CBSurface *surface; + surface = _gameRef->_renderer->createSurface(); + + if (!surface) return NULL; + + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.push_back(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::restoreAll() { + bool ret; + for (int i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +{ + + if(!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + + + // sort by validity + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSurfaceStorage.h b/engines/wintermute/base/BSurfaceStorage.h new file mode 100644 index 0000000000..c054c2a55b --- /dev/null +++ b/engines/wintermute/base/BSurfaceStorage.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + +#include "engines/wintermute/base/BBase.h" +#include "common/array.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 _lastCleanupTime; + bool initLoop(); + bool sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); + bool cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + bool restoreAll(); + CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + Common::Array _surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp new file mode 100644 index 0000000000..7c9a95368a --- /dev/null +++ b/engines/wintermute/base/BTransitionMgr.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BTransitionMgr.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) return STATUS_OK; + + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return STATUS_OK; + } + + if (nonInteractive) { + _preserveInteractive = true; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; + } /*else _preserveInteractive */; + + + _type = type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return STATUS_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::update() { + if (isReady()) return STATUS_OK; + + if (!_started) { + _started = true; + _lastTime = CBPlatform::getTime(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (isReady()) { + if (_preserveInteractive) + _gameRef->_interactive = _origInteractive; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BTransitionMgr.h b/engines/wintermute/base/BTransitionMgr.h new file mode 100644 index 0000000000..faedb6fe3e --- /dev/null +++ b/engines/wintermute/base/BTransitionMgr.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp new file mode 100644 index 0000000000..0f2a67d3bf --- /dev/null +++ b/engines/wintermute/base/BViewport.cpp @@ -0,0 +1,98 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BViewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); + } + + CBPlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *CBViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/BViewport.h b/engines/wintermute/base/BViewport.h new file mode 100644 index 0000000000..1150b8ebe7 --- /dev/null +++ b/engines/wintermute/base/BViewport.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int getHeight(); + int getWidth(); + Rect32 *getRect(); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int _offsetY; + int _offsetX; + CBObject *_mainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + Rect32 _rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp new file mode 100644 index 0000000000..f2938cebc9 --- /dev/null +++ b/engines/wintermute/base/file/BDiskFile.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/BDiskFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/file.h" +#include "common/zlib.h" + +namespace WinterMute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { + char fullPath[MAX_PATH_LENGTH]; + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; + + for (int i = 0; i < fileManager->_singlePaths.size(); i++) { + sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); + correctSlashes(fullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + // if we didn't find it in search paths, try to open directly + if (!file) { + strcpy(fullPath, filename.c_str()); + correctSlashes(fullPath); + + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + if (file) { + uint32 magic1, magic2; + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + + if (compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = file->readUint32LE(); + CompSize = file->readUint32LE(); + UncompSize = file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + error("Error allocating memory for compressed file '%s'", filename.c_str()); + delete file; + return NULL; + } + + byte *data = new byte[UncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + file->seek(DataOffset + prefixSize, SEEK_SET); + file->read(CompBuffer, CompSize); + + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + error("Error uncompressing file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + + delete [] CompBuffer; + + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; + } else { + file->seek(0, SEEK_SET); + return file; + } + + return file; + + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BDiskFile.h b/engines/wintermute/base/file/BDiskFile.h new file mode 100644 index 0000000000..23e1a0a315 --- /dev/null +++ b/engines/wintermute/base/file/BDiskFile.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BFile.cpp b/engines/wintermute/base/file/BFile.cpp new file mode 100644 index 0000000000..911039e36d --- /dev/null +++ b/engines/wintermute/base/file/BFile.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = getPos(); + seek(0); + byte *data = new byte[getSize()]; + read(data, getSize()); + seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFile.h b/engines/wintermute/base/file/BFile.h new file mode 100644 index 0000000000..d1737df0ce --- /dev/null +++ b/engines/wintermute/base/file/BFile.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/base/BBase.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +protected: + uint32 _pos; + uint32 _size; +public: + virtual uint32 getSize() { + return _size; + }; + virtual uint32 getPos() { + return _pos; + }; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; + virtual bool isEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp new file mode 100644 index 0000000000..7eafe7919e --- /dev/null +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -0,0 +1,105 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/util.h" +#include "common/file.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" + +namespace WinterMute { + +// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. +class CBPkgFile : public Common::SeekableReadStream { + uint32 _size; + Common::SeekableReadStream *_stream; +public: + CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} + virtual ~CBPkgFile() { + delete _stream; + } + virtual uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } + virtual bool eos() const { + return _stream->eos(); + } + virtual int32 pos() const { + return _stream->pos(); + } + virtual int32 size() const { + return _size; + } + virtual bool seek(int32 offset, int whence = SEEK_SET) { + return _stream->seek(offset, whence); + } +}; + +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { + CBFileEntry *fileEntry; + Common::SeekableReadStream *file = NULL; + char fileName[MAX_PATH_LENGTH]; + strcpy(fileName, filename.c_str()); + + // correct slashes + for (uint32 i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '/') fileName[i] = '\\'; + } + + fileEntry = fileManager->getPackageEntry(fileName); + if (!fileEntry) return NULL; + + file = fileEntry->_package->getFilePointer(); + if (!file) return NULL; + + // TODO: Cleanup + bool compressed = (fileEntry->_compressedLength != 0); + /* _size = fileEntry->_length; */ + + if (compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); + } else { + file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); + } + if (file->size() == 0) { + file = new CBPkgFile(file, fileEntry->_length); + } + + file->seek(0); + + return file; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h new file mode 100644 index 0000000000..f8a5831485 --- /dev/null +++ b/engines/wintermute/base/file/BPkgFile.h @@ -0,0 +1,46 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPKGFILE_H +#define WINTERMUTE_BPKGFILE_H + +#include "engines/wintermute/base/BFileEntry.h" + +namespace Common { +class SeekableReadStream; +class File; +} + +namespace WinterMute { + +class CBFileManager; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp new file mode 100644 index 0000000000..b2eebb690b --- /dev/null +++ b/engines/wintermute/base/file/BSaveThumbFile.cpp @@ -0,0 +1,146 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/BSaveThumbFile.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::open(const Common::String &filename) { + close(); + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (uint32 i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int slot = atoi(tempFilename); + delete [] tempFilename; + + char slotFilename[MAX_PATH_LENGTH + 1]; + _gameRef->getSaveSlotFilename(slot, slotFilename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _gameRef->_debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(slotFilename))) { + _gameRef->_debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + _gameRef->_debugAbsolutePathWarning = true; + + bool res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = STATUS_OK; + } else res = STATUS_FAILED; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return STATUS_FAILED; + + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::seek(uint32 pos, int whence) { + if (!_data) return STATUS_FAILED; + + uint32 newPos = 0; + + switch (whence) { + case SEEK_SET: + newPos = pos; + break; + case SEEK_END: + newPos = _size + pos; + break; + case SEEK_CUR: + newPos = _pos + pos; + break; + } + + if (newPos > _size) return STATUS_FAILED; + else _pos = newPos; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BSaveThumbFile.h b/engines/wintermute/base/file/BSaveThumbFile.h new file mode 100644 index 0000000000..5d33ac2220 --- /dev/null +++ b/engines/wintermute/base/file/BSaveThumbFile.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/BFile.h" + +namespace WinterMute { + +//TODO: Get rid of this +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFont.cpp b/engines/wintermute/base/font/BFont.cpp new file mode 100644 index 0000000000..5d0086c581 --- /dev/null +++ b/engines/wintermute/base/font/BFont.cpp @@ -0,0 +1,206 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/font/BFontBitmap.h" +#include "engines/wintermute/base/font/BFontTT.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +bool CBFont::loadFile(const char * Filename) +{ + BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + if(Buffer==NULL){ + _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); + + if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFont::loadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(_gameRef); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFont::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { + if (isTrueType(gameRef, filename)) { + CBFontTT *font = new CBFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + CBFontBitmap *font = new CBFontBitmap(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; + + byte *WorkBuffer = buffer; + + char *params; + CBParser parser(gameRef); + + bool ret = false; + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + ret = true; + + delete [] buffer; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFont.h b/engines/wintermute/base/font/BFont.h new file mode 100644 index 0000000000..a6ab757b0d --- /dev/null +++ b/engines/wintermute/base/font/BFont.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/base/BObject.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {}; + virtual void afterLoad() {}; + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *createFromFile(CBGame *game, const char *filename); + +private: + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); + static bool isTrueType(CBGame *game, const char *filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp new file mode 100644 index 0000000000..031f075d1b --- /dev/null +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -0,0 +1,540 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFontBitmap.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BFrame.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (size_t i = 0; i < str.size(); i++) { + textWidth += getCharWidth(str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) _gameRef->_renderer->startSpriteBatch(); + + while (!done) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (draw) _gameRef->_renderer->endSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += getCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += getCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) _gameRef->_renderer->endSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; + + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new CBSubFrame(_gameRef); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + _gameRef->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + expandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; + + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; + else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { + + CBFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); + else + persistMgr->getBytes(_widths, sizeof(_widths)); + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::getWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) break; + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + _gameRef->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontBitmap.h b/engines/wintermute/base/font/BFontBitmap.h new file mode 100644 index 0000000000..17bf433f65 --- /dev/null +++ b/engines/wintermute/base/font/BFontBitmap.h @@ -0,0 +1,72 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/base/font/BFont.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const char *filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + bool getWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp new file mode 100644 index 0000000000..a777ac9db8 --- /dev/null +++ b/engines/wintermute/base/font/BFontStorage.cpp @@ -0,0 +1,135 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.getSize(); i++) { + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::initLoop() { + for (int i = 0; i < _fonts.getSize(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::addFont(const char *filename) { + if (!filename) return NULL; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + CBFont *font = CBFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.removeAt(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::persist(CBPersistMgr *persistMgr) { + + if (!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontStorage.h b/engines/wintermute/base/font/BFontStorage.h new file mode 100644 index 0000000000..9759d5d25e --- /dev/null +++ b/engines/wintermute/base/font/BFontStorage.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + bool cleanup(bool warn = false); + bool removeFont(CBFont *font); + CBFont *addFont(const char *filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + bool initLoop(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp new file mode 100644 index 0000000000..2707dbea31 --- /dev/null +++ b/engines/wintermute/base/font/BFontTT.cpp @@ -0,0 +1,762 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/font/BFontTT.h" +#include "engines/wintermute/utils/PathUtil.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BParser.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + clearCache(); + + for (int i = 0; i < _layers.getSize(); i++) { + delete _layers[i]; + } + _layers.removeAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; + +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (_gameRef->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; + + WideString textStr = (char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + debugC(kWinterMuteDebugFont, "Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (int i = 0; i < _layers.getSize(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } + + debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + if (_deletableFont) // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + else // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + uint32 useColor = 0xffffffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + CBSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + _gameRef->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.getSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.add(Layer); + } + + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->_saving) { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + } else { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + if (!file) { + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + } + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + _gameRef->_fileManager->closeFile(file); + return STATUS_FAILED; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return STATUS_FAILED; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontTT.h b/engines/wintermute/base/font/BFontTT.h new file mode 100644 index 0000000000..9b995b293e --- /dev/null +++ b/engines/wintermute/base/font/BFontTT.h @@ -0,0 +1,180 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/base/font/BFontStorage.h" +#include "engines/wintermute/base/font/BFont.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString getText() const { + return _text; + } + int getWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + bool loadBuffer(byte *buffer); + bool loadFile(const char *filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(CBTTFontLayer *layer, byte *buffer); + + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void clearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp new file mode 100644 index 0000000000..f1e27c9622 --- /dev/null +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -0,0 +1,269 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/bmp.h" +#include "graphics/surface.h" +#include "engines/wintermute/graphics/tga.h" +#include "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +#if 0 + _bitmap = bitmap; +#endif + _bitmap = NULL; + _palette = NULL; + _surface = NULL; + _decoder = NULL; + _deletableSurface = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBImage::~CBImage() { + /* delete _bitmap; */ + delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } + delete _deletableSurface; +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); +#endif +} + +bool CBImage::loadFile(const Common::String &filename) { + _filename = filename; + _filename.toLowercase(); + if (StringUtil::startsWith(filename, "savegame:", true)) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".png")) { + _decoder = new Graphics::PNGDecoder(); + } else if (_filename.hasSuffix(".bmp")) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".tga")) { + _decoder = new WinterMute::TGA(); + } else if (_filename.hasSuffix(".jpg")) { + _decoder = new Graphics::JPEGDecoder(); + } else { + error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + _filename = filename; + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); + if (!file) return STATUS_FAILED; + + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); + _gameRef->_fileManager->closeFile(file); + + return STATUS_OK; +} + +byte CBImage::getAlphaAt(int x, int y) { + if (!_surface) return 0xFF; + uint32 color = *(uint32 *)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} + +void CBImage::copyFrom(Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + +////////////////////////////////////////////////////////////////////////// +bool CBImage::saveBMPFile(const char *filename) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; + else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::resize(int newWidth, int newHeight) { +#if 0 + if (!_bitmap) return STATUS_FAILED; + + if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); + if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + + + FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); + if (newImg) { + FreeImage_Unload(_bitmap); + _bitmap = newImg; + return STATUS_OK; + } else return STATUS_FAILED; +#endif + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::writeBMPToStream(Common::WriteStream *stream) { + if (!_surface) return false; + + /* The following is just copied over and inverted to write-ops from the BMP-decoder */ + stream->writeByte('B'); + stream->writeByte('M'); + + /* Since we don't care during reads, we don't care during writes: */ + /* uint32 fileSize = */ + stream->writeUint32LE(54 + _surface->h * _surface->pitch); + /* uint16 res1 = */ + stream->writeUint16LE(0); + /* uint16 res2 = */ + stream->writeUint16LE(0); + const uint32 imageOffset = 54; + stream->writeUint32LE(imageOffset); + + const uint32 infoSize = 40; /* Windows v3 BMP */ + stream->writeUint32LE(infoSize); + + uint32 width = _surface->w; + int32 height = _surface->h; + stream->writeUint32LE(width); + stream->writeUint32LE((uint32)height); + + if (width == 0 || height == 0) + return false; + + if (height < 0) { + warning("Right-side up bitmaps not supported"); + return false; + } + + /* uint16 planes = */ stream->writeUint16LE(1); + const uint16 bitsPerPixel = 24; + stream->writeUint16LE(bitsPerPixel); + + const uint32 compression = 0; + stream->writeUint32LE(compression); + + /* uint32 imageSize = */ + stream->writeUint32LE(_surface->h * _surface->pitch); + /* uint32 pixelsPerMeterX = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ + stream->writeUint32LE(0); + const uint32 paletteColorCount = 0; + stream->writeUint32LE(paletteColorCount); + /* uint32 colorsImportant = */ + stream->writeUint32LE(0); + + // Start us at the beginning of the image (54 bytes in) + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + + // BGRA for 24bpp + if (bitsPerPixel == 24) + format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + + Graphics::Surface *surface = _surface->convertTo(format); + + int srcPitch = width * (bitsPerPixel >> 3); + const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + + for (int32 i = height - 1; i >= 0; i--) { + for (uint32 j = 0; j < width; j++) { + byte b, g, r; + uint32 color = *(uint32 *)surface->getBasePtr(j, i); + surface->format.colorToRGB(color, r, g, b); + stream->writeByte(b); + stream->writeByte(g); + stream->writeByte(r); + } + + for (int k = 0; k < extraDataLength; k++) { + stream->writeByte(0); + } + } + surface->free(); + delete surface; + return true; + + //*BufferSize = 0; +#if 0 + FIMEMORY *fiMem = FreeImage_OpenMemory(); + FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); + uint32 size; + byte *data; + FreeImage_AcquireMemory(fiMem, &data, &size); + + + byte *Buffer = new byte[size]; + memcpy(Buffer, data, size); + + FreeImage_CloseMemory(fiMem); + + if (BufferSize) *BufferSize = size; + + return Buffer; +#endif + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +#if 0 + if (_bitmap) FreeImage_Unload(_bitmap); + + if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + + _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); +#endif + TransparentSurface temp(*origImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale(newWidth, newHeight); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h new file mode 100644 index 0000000000..646a9ddd2d --- /dev/null +++ b/engines/wintermute/base/gfx/base_image.h @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BIMAGE_H +#define WINTERMUTE_BIMAGE_H + +#include "engines/wintermute/base/BBase.h" +#include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/decoders/image_decoder.h" +#include "common/endian.h" +#include "common/str.h" +#include "common/stream.h" + +struct FIBITMAP; + +namespace WinterMute { +class CBSurface; +class CBImage: CBBase { + +public: + CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); + ~CBImage(); + + bool loadFile(const Common::String &filename); + const Graphics::Surface *getSurface() const { + return _surface; + }; + const byte *getPalette() const { + return _palette; + } + byte getAlphaAt(int x, int y); + bool writeBMPToStream(Common::WriteStream *stream); + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename); + bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + void copyFrom(Graphics::Surface *surface); +private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; + FIBITMAP *_bitmap; + const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; + const byte *_palette; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp new file mode 100644 index 0000000000..010aca7141 --- /dev/null +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/BSubFrame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { + _window = 0; + _clipperWindow = 0; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _width = _height = _bPP = 0; + CBPlatform::setRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBRenderer::~CBRenderer() { + deleteRectList(); + unclipCursor(); +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::initLoop() { + deleteRectList(); +} + + +////////////////////////////////////////////////////////////////////// +CBObject *CBRenderer::getObjectAt(int x, int y) { + Point32 point; + point.x = x; + point.y = y; + + for (int i = _rectList.getSize() - 1; i >= 0; i--) { + if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + + if (_rectList[i]->_frame->_mirrorX) { + int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + xx = width - xx; + } + + if (_rectList[i]->_frame->_mirrorY) { + int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + yy = height - yy; + } + + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; + } + // region + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + } + } else return _rectList[i]->_owner; + } + } + + return (CBObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderer::deleteRectList() { + for (int i = 0; i < _rectList.getSize(); i++) { + delete _rectList[i]; + } + _rectList.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +bool CBRenderer::switchFullscreen() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::flip() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +void CBRenderer::onWindowChange() { +} + + +////////////////////////////////////////////////////////////////////// +bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::windowedBlt() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setup2D(bool Force) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setupLines() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { + for (int i = 0; i < width; i++) { + drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up + drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down + + drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left + drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fade(uint16 alpha) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::setViewport(Rect32 *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderer::takeScreenshot() { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::clipCursor() { + /* + if (!_windowed) { + Rect32 rc; + GetWindowRect(_window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; + + ::ClipCursor(&rc); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::unclipCursor() { + /* + if (!_windowed) ::ClipCursor(NULL); + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderer::pointInViewport(Point32 *p) { + if (p->x < _drawOffsetX) return false; + if (p->y < _drawOffsetY) return false; + if (p->x > _drawOffsetX + _width) return false; + if (p->y > _drawOffsetY + _height) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h new file mode 100644 index 0000000000..81c13f8b39 --- /dev/null +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -0,0 +1,128 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_H +#define WINTERMUTE_BRENDERER_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "common/rect.h" + +namespace WinterMute { + +class CBImage; +class CBActiveRect; +class CBObject; +class CBSurface; +class CBRenderer: public CBBase { +public: + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void dumpData(const char *filename) {}; + virtual CBImage *takeScreenshot(); + virtual bool setViewport(int left, int top, int right, int bottom); + virtual bool setViewport(Rect32 *Rect); + virtual bool setScreenViewport(); + virtual bool fade(uint16 Alpha); + virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + CBRenderer(CBGame *inGame = NULL); + virtual ~CBRenderer(); + virtual bool setProjection() { + return STATUS_OK; + }; + + virtual bool windowedBlt(); + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + virtual void onWindowChange(); + virtual bool initRenderer(int width, int height, bool windowed); + virtual bool flip(); + virtual void initLoop(); + virtual bool switchFullscreen(); + virtual bool setup2D(bool force = false); + virtual bool setupLines(); + + virtual const char *getName() { + return ""; + }; + virtual bool displayDebugInfo() { + return STATUS_FAILED; + }; + virtual bool drawShaderQuad() { + return STATUS_FAILED; + } + + virtual float getScaleRatioX() const { + return 1.0f; + } + virtual float getScaleRatioY() const { + return 1.0f; + } + + virtual CBSurface *createSurface() = 0; + + bool clipCursor(); + bool unclipCursor(); + + CBObject *getObjectAt(int x, int y); + void deleteRectList(); + + virtual bool startSpriteBatch() { + return STATUS_OK; + }; + virtual bool endSpriteBatch() { + return STATUS_OK; + }; + bool pointInViewport(Point32 *P); + uint32 _forceAlphaColor; + uint32 _window; + uint32 _clipperWindow; + bool _active; + bool _ready; + bool _windowed; + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; + int _bPP; + int _height; + int _width; + + CBArray _rectList; +}; + +CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp new file mode 100644 index 0000000000..6c0ca40765 --- /dev/null +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -0,0 +1,152 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/base_surface.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = ""; + + _pixelOpReady = false; + + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface::~CBSurface() { + if (_pixelOpReady) endPixelOp(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::restore() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAt(int x, int y) { + return false; +} + +////////////////////////////////////////////////////////////////////// +bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::create(int Width, int Height) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::startPixelOp() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::endPixelOp() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurface::isTransparentAtLite(int x, int y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::invalidate() { + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBSurface::prepareToDraw() { + _lastUsedTime = _gameRef->_liveTimer; + + if (!_valid) { + //_gameRef->LOG(0, "Reviving: %s", _filename); + return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSurface::setSize(int width, int height) { + _width = width; + _height = height; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h new file mode 100644 index 0000000000..f5fbd495aa --- /dev/null +++ b/engines/wintermute/base/gfx/base_surface.h @@ -0,0 +1,99 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACE_H +#define WINTERMUTE_BSURFACE_H + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "graphics/surface.h" + +namespace WinterMute { + +class CBSurface: public CBBase { +public: + virtual bool invalidate(); + virtual bool prepareToDraw(); + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + bool _keepLoaded; + + bool _pixelOpReady; + CBSurface(CBGame *inGame); + virtual ~CBSurface(); + + virtual bool displayHalfTrans(int x, int y, Rect32 rect); + virtual bool isTransparentAt(int x, int y); + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool restore(); + virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(int Width, int Height); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return STATUS_FAILED; + } + virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool startPixelOp(); + virtual bool endPixelOp(); + virtual bool isTransparentAtLite(int x, int y); + void setSize(int width, int height); + + int _referenceCount; + + virtual int getWidth() { + return _width; + } + virtual int getHeight() { + return _height; + } + Common::String getFileNameStr() { return _filename; } + const char* getFileName() { return _filename.c_str(); } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } +protected: + Common::String _filename; + int _height; + int _width; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp new file mode 100644 index 0000000000..fc971357bf --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -0,0 +1,701 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/math/MathUtil.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSprite.h" +#include "common/system.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "common/queue.h" + +namespace WinterMute { + +RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { + _colorMod = 0; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; + if (surf) { + _surface = new Graphics::Surface(); + _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); + assert(_surface->format.bytesPerPixel == 4); + // Get a clipped copy of the surface + for (int i = 0; i < _surface->h; i++) { + memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); + } + // Then scale it if necessary + if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + TransparentSurface src(*_surface, false); + Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); + _surface->free(); + delete _surface; + _surface = temp; + } + } else { + _surface = NULL; + } +} + +RenderTicket::~RenderTicket() { + if (_surface) { + _surface->free(); + delete _surface; + } +} + +bool RenderTicket::operator==(RenderTicket &t) { + if ((t._srcRect != _srcRect) || + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } + return true; +} + +CBRenderer *makeOSystemRenderer(CBGame *inGame) { + return new CBRenderOSystem(inGame); +} + +// TODO: Redo everything here. + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { + _renderSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); + _dirtyRect = NULL; + _disableDirtyRects = true; +} + +////////////////////////////////////////////////////////////////////////// +CBRenderOSystem::~CBRenderOSystem() { + _renderSurface->free(); + delete _renderSurface; +#if 0 + if (_renderer) SDL_DestroyRenderer(_renderer); + if (_win) SDL_DestroyWindow(_win); + SDL_Quit(); +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { + //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; + +#if 0 + SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); + SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); +#endif + _width = width; + _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); + + _realWidth = width; + _realHeight = height; + + + // find suitable resolution +/*#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } +#else*/ + _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); + _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); +//#endif + + /* + _realWidth = 480; + _realHeight = 320; + */ + + + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)_realHeight / (float)_height; + } else { + // wide to normal + ratio = (float)_realWidth / (float)_width; + } + + _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); + _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); + + _borderTop = (int)((_realHeight - (_height * ratio)) / 2); + _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); + + + + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; + +#if 0 + Uint32 flags = SDL_WINDOW_SHOWN; +#endif +#ifdef __IPHONEOS__ + //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; +#endif + + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); +// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + + Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return STATUS_FAILED; + } +#if 0 + _win = SDL_CreateWindow("WME Lite", + SDL_WINDOWPOS_UNDEFINED, + SDL_WINDOWPOS_UNDEFINED, + _realWidth, _realHeight, + flags); + + if (!_win) return STATUS_FAILED; +#endif + + g_system->showMouse(false); + +#ifdef __IPHONEOS__ + // SDL defaults to OGL ES2, which doesn't work on old devices + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); +#else + //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); +#endif +#if 0 + _renderer = SDL_CreateRenderer(_win, -1, 0); + + if (!_renderer) return STATUS_FAILED; +#endif + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _active = true; + + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); + + return STATUS_OK; +} + +void CBRenderOSystem::setAlphaMod(byte alpha) { + byte r = RGBCOLGetR(_colorMod); + byte g = RGBCOLGetB(_colorMod); + byte b = RGBCOLGetB(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { + byte alpha = RGBCOLGetA(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::flip() { + if (!_disableDirtyRects) { + drawTickets(); + } + if (_needsFlip || _disableDirtyRects) { + if (_disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + } + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + delete _dirtyRect; + _dirtyRect = NULL; + g_system->updateScreen(); + _needsFlip = false; + } + _drawNum = 1; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { + //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); + //SDL_RenderClear(_renderer); + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) + return STATUS_OK; + if (!rect) { + rect = &_renderRect; + } + _renderSurface->fillRect(*rect, _clearColor); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fade(uint16 Alpha) { + uint32 dwAlpha = 255 - Alpha; + return fadeToColor(dwAlpha << 24); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); + warning("Implement CBRenderOSystem::FadeToColor"); // TODO. + hasWarned = true; + } + + Common::Rect fillRect; + + if (rect) { + fillRect.left = rect->left; + fillRect.top = rect->top; + fillRect.setWidth(rect->width()); + fillRect.setHeight(rect->height()); + } else { + Rect32 rc; + _gameRef->getCurrentViewportRect(&rc); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); + } + modTargetRect(&fillRect); + + byte r = RGBCOLGetR(Color); + byte g = RGBCOLGetG(Color); + byte b = RGBCOLGetB(Color); + byte a = RGBCOLGetA(Color); + + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + if (_disableDirtyRects) + _renderSurface->fillRect(fillRect, col); + else { + setAlphaMod(a); + setColorMod(r, g, b); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + _clearColor = col; + } + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); + + return STATUS_OK; +} + +void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { + if (_disableDirtyRects) { + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + // HINT: The surface-data contains other info than it should. + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + return; + } + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { + return; + } + + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } + } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + ticket->_colorMod = _colorMod; + drawFromTicket(ticket); +} + +void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} + +void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } + } +} + +void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { + renderTicket->_wantsDraw = true; + // A new item always has _drawNum == 0 + if (renderTicket->_drawNum == 0) { + // In-order + if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { + renderTicket->_drawNum = _drawNum++; + _renderQueue.push_back(renderTicket); + addDirtyRect(renderTicket->_dstRect); + } else { + // Before something + Common::List::iterator pos; + for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { + if ((*pos)->_drawNum >= _drawNum) { + break; + } + } + _renderQueue.insert(pos, renderTicket); + Common::List::iterator it; + renderTicket->_drawNum = _drawNum++; + // Increment the following tickets, so they still are in line + for (it = pos; it != _renderQueue.end(); it++) { + (*it)->_drawNum++; + (*it)->_wantsDraw = false; + } + addDirtyRect(renderTicket->_dstRect); + } + } else { + // Was drawn last round, still in the same order + if (_drawNum == renderTicket->_drawNum) { + _drawNum++; + } else { + // Remove the ticket from the list + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it) == renderTicket) { + it = _renderQueue.erase(it); + break; + } else { + it++; + } + } + // Is not in order, so readd it as if it was a new ticket + renderTicket->_drawNum = 0; + drawFromTicket(renderTicket); + } + } +} + +void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); +} + +void CBRenderOSystem::drawTickets() { + RenderQueueIterator it = _renderQueue.begin(); + // Clean out the old tickets + int decrement = 0; + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { + RenderTicket* ticket = *it; + addDirtyRect((*it)->_dstRect); + //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); + it = _renderQueue.erase(it); + delete ticket; + decrement++; + } else { + (*it)->_drawNum -= decrement; + it++; + } + } + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) + return; + // The color-mods are stored in the RenderTickets on add, since we set that state again during + // draw, we need to keep track of what it was prior to draw. + uint32 oldColorMod = _colorMod; +// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); + + // Apply the clear-color to the dirty rect. + _renderSurface->fillRect(*_dirtyRect, _clearColor); + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + RenderTicket *ticket = *it; + if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { + // dstClip is the area we want redrawn. + Common::Rect dstClip(ticket->_dstRect); + // reduce it to the dirty rect + dstClip.clip(*_dirtyRect); + // we need to keep track of the position to redraw the dirty rect + Common::Rect pos(dstClip); + int16 offsetX = ticket->_dstRect.left; + int16 offsetY = ticket->_dstRect.top; + // convert from screen-coords to surface-coords. + dstClip.translate(-offsetX, -offsetY); + + _colorMod = ticket->_colorMod; + drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + _needsFlip = true; + } + // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) + ticket->_wantsDraw = false; + } + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + + // Revert the colorMod-state. + _colorMod = oldColorMod; +} + +// Replacement for SDL2's SDL_RenderCopy +void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { + TransparentSurface src(*surf, false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(surf->w); + clipRect->setHeight(surf->h); + } + + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) + delete clipRect; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + static bool hasWarned = false; + if (!hasWarned) { + warning("CBRenderOSystem::DrawLine - not fully ported yet"); + hasWarned = true; + } + byte r = RGBCOLGetR(color); + byte g = RGBCOLGetG(color); + byte b = RGBCOLGetB(color); + byte a = RGBCOLGetA(color); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + + Point32 point1, point2; + point1.x = x1; + point1.y = y1; + pointToScreen(&point1); + + point2.x = x2; + point2.y = y2; + pointToScreen(&point2); + + // TODO: This thing is mostly here until I'm sure about the final color-format. + uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBImage *CBRenderOSystem::takeScreenshot() { +// TODO: Fix this + warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); + CBImage *screenshot = new CBImage(_gameRef); + screenshot->copyFrom(_renderSurface); + return screenshot; +#if 0 + SDL_Rect viewport; + + SDL_RenderGetViewport(_renderer, &viewport); + + SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); + if (!surface) return NULL; + + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + + FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); + + int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); + + for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { + byte *bits = FreeImage_GetScanLine(dib, y); + byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; + memcpy(bits, src, bytespp * viewport.w); + } + + return new CBImage(_gameRef, dib); +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::switchFullscreen() { + /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); + else SDL_SetWindowFullscreen(_win, SDL_FALSE); + + _windowed = !_windowed; + */ + _gameRef->_registry->writeBool("Video", "Windowed", _windowed); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBRenderOSystem::getName() { + if (_name.empty()) { +#if 0 + if (_renderer) { + SDL_RendererInfo info; + SDL_GetRendererInfo(_renderer, &info); + _name = AnsiString(info.name); + } +#endif + } + return _name.c_str(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = (int16)(left + _borderLeft); + rect.top = (int16)(top + _borderTop); + rect.right = (int16)((right - left) * _ratioX); + rect.bottom = (int16)((bottom - top) * _ratioY); + + // TODO fix this once viewports work correctly in SDL/landscape +#ifndef __IPHONEOS__ + //SDL_RenderSetViewport(GetSdlRenderer(), &rect); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::modTargetRect(Common::Rect *rect) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); + rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); + rect->w = MathUtil::RoundUp(rect->w * _ratioX); + rect->h = MathUtil::RoundUp(rect->h * _ratioY); +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointFromScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; + point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::pointToScreen(Point32 *point) { +#if 0 + SDL_Rect viewportRect; + SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); + + point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; + point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; +#endif +} + +////////////////////////////////////////////////////////////////////////// +void CBRenderOSystem::dumpData(const char *filename) { + warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO +#if 0 + FILE *f = fopen(filename, "wt"); + if (!f) return; + + CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; + + int TotalKB = 0; + int TotalLoss = 0; + fprintf(f, "Filename;Usage;Size;KBytes\n"); + for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { + CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; + if (!Surf->_filename) continue; + if (!Surf->_valid) continue; + + fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); + fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); + + int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; + + TotalKB += kb; + fprintf(f, "%d;", kb); + fprintf(f, "\n"); + } + fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); + + + fclose(f); + _gameRef->LOG(0, "Texture Stats Dump completed."); + _gameRef->QuickMessage("Texture Stats Dump completed."); +#endif +} + +CBSurface *CBRenderOSystem::createSurface() { + return new CBSurfaceOSystem(_gameRef); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h new file mode 100644 index 0000000000..d41d14ef35 --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -0,0 +1,129 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRENDERER_SDL_H +#define WINTERMUTE_BRENDERER_SDL_H + +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "common/list.h" + +namespace WinterMute { +class CBSurfaceOSystem; +class RenderTicket { +public: + RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + Graphics::Surface *_surface; + Common::Rect _srcRect; + Common::Rect _dstRect; + uint32 _mirror; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + CBSurfaceOSystem *_owner; + bool operator==(RenderTicket &a); +}; + +class CBRenderOSystem : public CBRenderer { +public: + CBRenderOSystem(CBGame *inGame); + ~CBRenderOSystem(); + + const char *getName(); + + bool initRenderer(int width, int height, bool windowed); + bool flip(); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + + bool fade(uint16 alpha); + bool fadeToColor(uint32 color, Common::Rect *rect = NULL); + + bool switchFullscreen(); + + bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + + CBImage *takeScreenshot(); + + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); + void drawFromTicket(RenderTicket *renderTicket); + + bool setViewport(int left, int top, int right, int bottom); + + void modTargetRect(Common::Rect *rect); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); + + void dumpData(const char *filename); + + float getScaleRatioX() const { + return _ratioX; + } + float getScaleRatioY() const { + return _ratioY; + } + + void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + CBSurface *createSurface(); +private: + void addDirtyRect(const Common::Rect &rect); + void drawTickets(); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); + typedef Common::List::iterator RenderQueueIterator; + Common::Rect *_dirtyRect; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; + Common::Rect _renderRect; + Graphics::Surface *_renderSurface; + AnsiString _name; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + bool _disableDirtyRects; + float _ratioX; + float _ratioY; + uint32 _colorMod; + uint32 _clearColor; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp new file mode 100644 index 0000000000..1e4ac9a19e --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -0,0 +1,532 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/PlatformSDL.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/decoders/jpeg.h" +#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/tga.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "common/stream.h" +#include "common/system.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + _hasAlpha = true; + _lockPixels = NULL; + _lockPitch = 0; + _loaded = false; +} + +////////////////////////////////////////////////////////////////////////// +CBSurfaceOSystem::~CBSurfaceOSystem() { + //TODO + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + delete[] _alphaMask; + _alphaMask = NULL; + + _gameRef->addMem(-_width * _height * 4); + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); +} + +bool hasTransparency(Graphics::Surface *surf) { + if (surf->format.bytesPerPixel != 4) { + warning("hasTransparency:: non 32 bpp surface passed as argument"); + return false; + } + uint8 r, g, b, a; + for (int i = 0; i < surf->h; i++) { + for (int j = 0; j < surf->w; j++) { + uint32 pix = *(uint32 *)surf->getBasePtr(j, i); + surf->format.colorToARGB(pix, a, r, g, b); + if (a != 255) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ + _filename = filename; +// const Graphics::Surface *surface = image->getSurface(); + + if (defaultCK) { + ckRed = 255; + ckGreen = 0; + ckBlue = 255; + } + + _ckDefault = defaultCK; + _ckRed = ckRed; + _ckGreen = ckGreen; + _ckBlue = ckBlue; + + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + _lifeTime = lifeTime; + + _keepLoaded = keepLoaded; + if (_keepLoaded) _lifeTime = -1; + + return STATUS_OK; +} + +void CBSurfaceOSystem::finishLoad() { + CBImage *image = new CBImage(_gameRef); + image->loadFile(_filename); + + _width = image->getSurface()->w; + _height = image->getSurface()->h; + + bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); + /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); + if (newImg) { + FreeImage_Unload(img); + img = newImg; + }*/ + } + + // no alpha, set color key + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + delete _surface; + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); + } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*image->getSurface()); + } + + _hasAlpha = hasTransparency(_surface); + //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO + //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("Surface-textures not fully ported yet"); + hasWarned = true; + } + //delete imgDecoder; +#if 0 + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); + if (!_texture) { + SDL_FreeSurface(surf); + delete imgDecoder; + return STATUS_FAILED; + } + + GenAlphaMask(surf); + + SDL_FreeSurface(surf); + delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. +#endif + + _valid = true; + + _gameRef->addMem(_width * _height * 4); + + delete image; + + _loaded = true; +} + +////////////////////////////////////////////////////////////////////////// +void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); + return; + + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) return; +#if 0 + SDL_LockSurface(surface); +#endif + bool hasColorKey; + /* uint32 colorKey; */ + uint8 ckRed, ckGreen, ckBlue; + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ //TODO + _alphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + uint32 pixel = getPixel(surface, x, y); + + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + a = 0; + + _alphaMask[y * surface->w + x] = a; + if (a < 255) hasTransparency = true; + } + } +#if 0 + SDL_UnlockSurface(surface); +#endif + if (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { + warning("CBSurfaceOSystem::GetPixel - Not ported yet"); + int bpp = surface->format.bytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(uint16 *)p; + break; + + case 3: +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + //else + return p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + return *(uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::create(int width, int height) { + warning("CBSurfaceOSystem::Create not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); +#endif + _width = width; + _height = height; + + _gameRef->addMem(_width * _height * 4); + + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { + warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO +#if 0 + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); +#endif + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + _surface = new Graphics::Surface(); + _surface->copyFrom(*surface); + _width = surface->w; + _height = surface->h; +#if 0 + _gameRef->AddMem(_width * _height * 4); +#endif + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAt(int x, int y) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); + hasWarned = true; + } +#if 0 + int access; + int width, height; + //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + + StartPixelOp(); + bool ret = isTransparentAtLite(X, Y); + EndPixelOp(); + + return ret; +#endif + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { + //if (!_lockPixels) return false; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); + hasWarned = true; + } + if (_surface->format.bytesPerPixel == 4) { + uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); + uint8 r, g, b, a; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } +#if 0 + uint32 format; + int access; + int width, height; + + //SDL_QueryTexture(_texture, &format, &access, &width, &height); + //if (access != SDL_TEXTUREACCESS_STREAMING) return false; + if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + + if (!_alphaMask) return false; + else return _alphaMask[Y * width + X] <= 128; +#endif + return false; + /* + Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); + Uint32 pixel = dst[X]; + + SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); + Uint8 r, g, b, a; + SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); + SDL_FreeFormat(pixelFormat); + + return a <= 128; + */ +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::startPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::endPixelOp() { + //SDL_UnlockTexture(_texture); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + if (!_loaded) { + finishLoad(); + } + + if (renderer->_forceAlphaColor != 0) + alpha = renderer->_forceAlphaColor; + + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + static bool hasWarned = false; + if (!hasWarned) { + warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. + hasWarned = true; + } + + byte r = RGBCOLGetR(alpha); + byte g = RGBCOLGetG(alpha); + byte b = RGBCOLGetB(alpha); + byte a = RGBCOLGetA(alpha); + + renderer->setAlphaMod(a); + renderer->setColorMod(r, g, b); +#if 0 + SDL_SetTextureColorMod(_texture, r, g, b); + SDL_SetTextureAlphaMod(_texture, a); + + if (AlphaDisable) + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); + else + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = rect->left; + srcRect.top = rect->top; + srcRect.setWidth(rect->right - rect->left); + srcRect.setHeight(rect->bottom - rect->top); + + Common::Rect position; + position.left = x + offsetX; + position.top = y + offsetY; + // TODO: Scaling... + + if (position.left == -1) { + position.left = 0; // TODO: Something is wrong + } + if (position.top == -1) { + position.top = 0; // TODO: Something is wrong + } + + position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); + position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); + + renderer->modTargetRect(&position); + + /* position.left += offsetX; + position.top += offsetY;*/ + + // TODO: This actually requires us to have the SAME source-offsets every time, + // But no checking is in place for that yet. + + bool hasAlpha; + if (_hasAlpha && !alphaDisable) { + hasAlpha = true; + } else { + hasAlpha = false; + } + if (alphaDisable) { + warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); + } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); +#if 0 + SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); +#endif + + return STATUS_OK; +} + +bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; + _surface->copyFrom(surface); + _hasAlpha = hasAlpha; + CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h new file mode 100644 index 0000000000..091e8ccba8 --- /dev/null +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -0,0 +1,101 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESDL_H +#define WINTERMUTE_BSURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/list.h" + +namespace WinterMute { +struct TransparentSurface; +class CBImage; +class CBSurfaceOSystem : public CBSurface { +public: + CBSurfaceOSystem(CBGame *inGame); + ~CBSurfaceOSystem(); + + bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(int width, int height); + + bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function + + bool isTransparentAt(int x, int y); + bool isTransparentAtLite(int x, int y); + + bool startPixelOp(); + bool endPixelOp(); + + + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + virtual int getWidth() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->w; + } + return _width; + } + virtual int getHeight() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->h; + } + return _height; + } + +private: + Graphics::Surface *_surface; + bool _loaded; + void finishLoad(); + bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + void genAlphaMask(Graphics::Surface *surface); + uint32 getPixel(Graphics::Surface *surface, int x, int y); + + bool _hasAlpha; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace WinterMute + +#endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp new file mode 100644 index 0000000000..81147a5432 --- /dev/null +++ b/engines/wintermute/base/particles/PartEmitter.cpp @@ -0,0 +1,1199 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/PartEmitter.h" +#include "engines/wintermute/base/particles/PartParticle.h" +#include "engines/wintermute/math/Vector2.h" +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include "common/math.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + for (int i = 0; i < _forces.getSize(); i++) { + delete _forces[i]; + } + _forces.removeAll(); + + + for (int i = 0; i < _sprites.getSize(); i++) { + delete [] _sprites[i]; + } + _sprites.removeAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; + + // do we already have the file? + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + } + + // check if file exists + Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else _gameRef->_fileManager->closeFile(File); + + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); + _sprites.add(Str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeSprite(const char *filename) { + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; + + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); + + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::update() { + if (!_running) return STATUS_OK; + else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) numLive++; + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; + else { + particle = new CPartParticle(_gameRef); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + sortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::display(CBRegion *region) { + if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + + for (int i = 0; i < _particles.getSize(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + } + + _particles[i]->display(this); + } + + if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::start() { + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = _gameRef->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::sortParticlesByZ() { + // sort particles by _posY + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; + + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::addForceByName(const char *name) { + CPartForce *force = NULL; + + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new CPartForce(_gameRef); + if (force) { + force->setName(name); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return STATUS_FAILED; + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeForce(const char *name) { + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) numAlive++; + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + int numForces; + if (persistMgr->_saving) { + numForces = _forces.getSize(); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < _forces.getSize(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + int numParticles; + if (persistMgr->_saving) { + numParticles = _particles.getSize(); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(_gameRef); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartEmitter.h b/engines/wintermute/base/particles/PartEmitter.h new file mode 100644 index 0000000000..5156783653 --- /dev/null +++ b/engines/wintermute/base/particles/PartEmitter.h @@ -0,0 +1,139 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/base/BObject.h" +#include "engines/wintermute/base/particles/PartForce.h" + +namespace WinterMute { +class CBRegion; +class CPartParticle; +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(CBRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + CBArray _forces; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + CPartForce *addForceByName(const char *name); + int static compareZ(const void *obj1, const void *obj2); + bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/PartForce.cpp b/engines/wintermute/base/particles/PartForce.cpp new file mode 100644 index 0000000000..b864c05292 --- /dev/null +++ b/engines/wintermute/base/particles/PartForce.cpp @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/particles/PartForce.h" +#include "engines/wintermute/base/BPersistMgr.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartForce::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartForce.h b/engines/wintermute/base/particles/PartForce.h new file mode 100644 index 0000000000..640c8d7f20 --- /dev/null +++ b/engines/wintermute/base/particles/PartForce.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/BNamedObject.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp new file mode 100644 index 0000000000..aa641f0a1c --- /dev/null +++ b/engines/wintermute/base/particles/PartParticle.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/PartParticle.h" +#include "engines/wintermute/base/particles/PartEmitter.h" +#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::getInstance()->_disabled = true; + _sprite = new CBSprite(_gameRef, _gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!CBPlatform::ptInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return STATUS_OK; + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (int i = 0; i < emitter->_forces.getSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = CBUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * elapsedTime; + else + _scale += _growthRate * elapsedTime; + + if (_scale <= 0.0f) + _isDead = true; + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; + + _sprite->GetCurrentFrame(); + return _sprite->display(_pos.x, _pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + CSysClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + CSysClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartParticle.h b/engines/wintermute/base/particles/PartParticle.h new file mode 100644 index 0000000000..ab5730d3c5 --- /dev/null +++ b/engines/wintermute/base/particles/PartParticle.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/math/Vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(CPartEmitter *emitter); + + bool setSprite(const char *filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXArray.cpp b/engines/wintermute/base/scriptables/SXArray.cpp new file mode 100644 index 0000000000..425118a3e7 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXArray.cpp @@ -0,0 +1,238 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/system/SysInstance.h" +#include "engines/wintermute/base/scriptables/SXArray.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { + return new CSXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); + + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) _length = stack->pop()->getInt(0); + else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXArray::scToString() { + static char dummy[32768]; // TODO: Get rid of static. + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + CScValue *val = _values->getProp(propName); + if (val) { + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); + } + } + + if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + } + return dummy; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Push") == 0) { + int numParams = stack->pop()->getInt(0); + char paramName[20]; + + for (int i = 0; i < numParams; i++) { + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); + } + stack->pushInt(_length); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Pop") == 0) { + + stack->correctParams(0); + + if (_length > 0) { + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); + _length--; + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (validNumber(name, ParamName)) { + return _values->getProp(ParamName); + } else return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length") == 0) { + int OrigLength = _length; + _length = MAX(value->getInt(0), 0); + + char PropName[20]; + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + _values->deleteProp(PropName); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + int Index = atoi(paramName); + if (Index >= _length) _length = Index + 1; + return _values->setProp(paramName, value); + } else return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::validNumber(const char *origStr, char *outStr) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::push(CScValue *val) { + char paramName[20]; + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXArray.h b/engines/wintermute/base/scriptables/SXArray.h new file mode 100644 index 0000000000..0f46bd546e --- /dev/null +++ b/engines/wintermute/base/scriptables/SXArray.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + bool push(CScValue *Val); + bool validNumber(const char *origStr, char *outStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + int _length; + CScValue *_values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXDate.cpp b/engines/wintermute/base/scriptables/SXDate.cpp new file mode 100644 index 0000000000..cd705cc9d4 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXDate.cpp @@ -0,0 +1,297 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/SXDate.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { + return new CSXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + CScValue *valYear = stack->pop(); + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { + g_system->getTimeAndDate(_tm); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXDate::scToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); +#if 0 + return asctime(&_tm); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetYear") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMonth") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDate") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHours") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMinutes") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_min); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSeconds") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWeekday") == 0) { + stack->correctParams(0); + warning("GetWeekday returns a wrong value on purpose"); + stack->pushInt(_tm.tm_mday % 7); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetYear") == 0) { + stack->correctParams(1); + _tm.tm_year = stack->pop()->getInt() - 1900; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMonth") == 0) { + stack->correctParams(1); + _tm.tm_mon = stack->pop()->getInt() - 1; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDate") == 0) { + stack->correctParams(1); + _tm.tm_mday = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHours") == 0) { + stack->correctParams(1); + _tm.tm_hour = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMinutes") == 0) { + stack->correctParams(1); + _tm.tm_min = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSeconds") == 0) { + stack->correctParams(1); + _tm.tm_sec = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->correctParams(0); + g_system->getTimeAndDate(_tm); + stack->pushNULL(); + return STATUS_OK; + } + + else + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CSXDate::scCompare(CBScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((CSXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXDate.h b/engines/wintermute/base/scriptables/SXDate.h new file mode 100644 index 0000000000..df0641983f --- /dev/null +++ b/engines/wintermute/base/scriptables/SXDate.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + +#include "common/system.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int scCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + char *_string; + TimeDate _tm; +private: + Common::String _strRep; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp new file mode 100644 index 0000000000..b2a6d24677 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXFile.cpp @@ -0,0 +1,779 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/SysClassRegistry.h" +#include "engines/wintermute/system/SysClass.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/BFile.h" +#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/scriptables/SXFile.h" + +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { + return new CSXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + _filename = NULL; + if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::close() { + if (_readFile) { + _gameRef->_fileManager->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXFile::scToString() { + if (_filename) return _filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + CBUtils::setString(&_filename, filename); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->correctParams(1); + close(); + _mode = stack->pop()->getInt(1); + if (_mode < 1 || _mode > 3) { + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); + _mode = 1; + } + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) { + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + if (strcmp(name, "OpenAsText") == 0) { + if (_mode == 2) _writeFile = openForWrite(_filename, false); + else _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) _writeFile = openForWrite(_filename, true); + else _writeFile = openForAppend(_filename, true); + } + + if (!_writeFile) { + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } + + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + close(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPosition") == 0) { + stack->correctParams(1); + if (_mode == 0) { + script->runtimeError("File.%s: File is not open", name); + stack->pushBool(false); + } else { + int Pos = stack->pop()->getInt(); + stack->pushBool(setPos(Pos)); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(0); + close(); + stack->pushBool(CBPlatform::deleteFile(_filename) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Copy") == 0) { + stack->correctParams(2); + const char *Dest = stack->pop()->getString(); + bool Overwrite = stack->pop()->getBool(true); + + close(); + stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadLine") == 0) { + stack->correctParams(0); + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + bool foundNewLine = false; + bool ret = STATUS_FAILED; + do { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + buf[counter] = '\0'; + foundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } while (DID_SUCCEED(ret)); + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (!foundNewLine && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadText") == 0) { + stack->correctParams(1); + int textLen = stack->pop()->getInt(); + + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + + bool ret = STATUS_FAILED; + while (counter < (uint32)textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (textLen > 0 && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->correctParams(1); + const char *line = stack->pop()->getString(); + if (!_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in text mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadBool") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadByte") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadShort") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadFloat") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + float val; + (*(uint32*)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadString") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); + } + delete [] str; + } else stack->pushNULL(); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteByte") == 0) { + stack->correctParams(1); + byte val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteShort") == 0) { + stack->correctParams(1); + int16 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint16LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->correctParams(1); + int32 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint32LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteFloat") == 0) { + stack->correctParams(1); + float val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + uint32 *ptr = (uint32*)&val; + _writeFile->writeUint32LE(*ptr); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); + stack->correctParams(1); + double val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteString") == 0) { + stack->correctParams(1); + const char *val = stack->pop()->getString(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + + uint32 size = strlen(val); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Position") == 0) { + _scValue->setInt(getPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(getLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextMode") == 0) { + _scValue->setBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccessMode") == 0) { + _scValue->setInt(_mode); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getPos() { + if (_mode == 1 && _readFile) + return _readFile->pos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) + return _readFile->seek(pos, whence); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getLength() { + if (_mode == 1 && _readFile) + return _readFile->size(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - reading length for WriteFile not supported"); + return 0; +/* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->_saving) { + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); + } else { + persistMgr->transfer(TMEMBER(pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) + close(); + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) + _writeFile = openForWrite(_filename, false); + else + _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) + _writeFile = openForWrite(_filename, true); + else + _writeFile = openForAppend(_filename, true); + } + if (_writeFile) + close(); + } + setPos(pos); + } + } + + return STATUS_OK; +} + +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXFile.h b/engines/wintermute/base/scriptables/SXFile.h new file mode 100644 index 0000000000..709d1f4378 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXFile.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/base/BScriptable.h" +#include "common/stream.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + Common::SeekableReadStream *_readFile; + Common::WriteStream *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void close(); + void cleanup(); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 Pos, int whence = SEEK_SET); + char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXMath.cpp b/engines/wintermute/base/scriptables/SXMath.cpp new file mode 100644 index 0000000000..fb2838ee94 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMath.cpp @@ -0,0 +1,295 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/persistent.h" +#include "common/math.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +CBScriptable *makeSXMath(CBGame *inGame) { + return new CSXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Abs") == 0) { + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Acos") == 0) { + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Asin") == 0) { + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan") == 0) { + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan2") == 0) { + stack->correctParams(2); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); + stack->pushFloat(atan2(y, x)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ceil") == 0) { + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cos") == 0) { + stack->correctParams(1); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cosh") == 0) { + stack->correctParams(1); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exp") == 0) { + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Floor") == 0) { + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log") == 0) { + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log10") == 0) { + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pow") == 0) { + stack->correctParams(2); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); + + stack->pushFloat(pow(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sin") == 0) { + stack->correctParams(1); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sinh") == 0) { + stack->correctParams(1); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tan") == 0) { + stack->correctParams(1); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tanh") == 0) { + stack->correctParams(1); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sqrt") == 0) { + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DegToRad") == 0) { + stack->correctParams(1); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RadToDeg") == 0) { + stack->correctParams(1); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PI") == 0) { + _scValue->setFloat(M_PI); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMath.h b/engines/wintermute/base/scriptables/SXMath.h new file mode 100644 index 0000000000..4389de611f --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMath.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + +private: + double degreeToRadian(double value); + double radianToDegree(double value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.cpp b/engines/wintermute/base/scriptables/SXMemBuffer.cpp new file mode 100644 index 0000000000..9ac98ab11d --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMemBuffer.cpp @@ -0,0 +1,508 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BScriptable.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/SXMemBuffer.h" +#include "common/file.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { + return new CSXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int NewSize = stack->pop()->getInt(); + resize(MAX(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + _size = 0; + _buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::cleanup() { + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::resize(int newSize) { + int oldSize = _size; + + if (_size == 0) { + _buffer = malloc(newSize); + if (_buffer) _size = newSize; + } else { + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; + } else return STATUS_FAILED; + } else { + _buffer = newBuf; + _size = newSize; + } + } + + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { + if (_buffer == NULL) { + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) + return true; + + if (start < 0 || length == 0 || start + length > _size) { + script->runtimeError("Set/Get method call is out of bounds"); + return false; + } else + return true; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSize") == 0) { + stack->correctParams(1); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (DID_SUCCEED(resize(newSize))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBool") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushNULL(); + else + stack->pushBool(*(bool *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetByte") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushNULL(); + else + stack->pushInt(*(byte *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetShort") == 0) { + stack->correctParams(1); + int Start = stack->pop()->getInt(); + if (!checkBounds(script, Start, sizeof(short))) + stack->pushNULL(); + else + stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) + stack->pushNULL(); + else + stack->pushInt(*(int *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFloat") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) + stack->pushNULL(); + else + stack->pushFloat(*(float *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDouble") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) + stack->pushNULL(); + else + stack->pushFloat(*(double *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); + + // find end of string + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + length = i - start; + break; + } + } + } + + if (!checkBounds(script, start, length)) + stack->pushNULL(); + else { + char *str = new char[length + 1]; + strncpy(str, (const char *)_buffer + start, length); + str[length] = '\0'; + stack->pushString(str); + delete [] str; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPointer") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushNULL(); + else { + void *pointer = *(void **)((byte *)_buffer + start); + CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + stack->pushNative(buf, false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBool") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); + + if (!checkBounds(script, start, sizeof(bool))) + stack->pushBool(false); + else { + *(bool *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetByte") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(byte))) + stack->pushBool(false); + else { + *(byte *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetShort") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(short))) + stack->pushBool(false); + else { + *(short *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(int))) + stack->pushBool(false); + else { + *(int *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFloat") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(float))) + stack->pushBool(false); + else { + *(float *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDouble") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(double))) + stack->pushBool(false); + else { + *(double *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); + + if (!checkBounds(script, start, strlen(val) + 1)) + stack->pushBool(false); + else { + memcpy((byte *)_buffer + start, val, strlen(val) + 1); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPointer") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + /* CScValue *Val = */ stack->pop(); + + if (!checkBounds(script, start, sizeof(void *))) + stack->pushBool(false); + else { + /* + int Pointer = (int)Val->getMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + stack->pushBool(true); + */ + // TODO fix + stack->pushBool(false); + + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->correctParams(0); + if (_buffer && _size) { + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); + } + stack->pushNULL(); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Size") == 0) { + _scValue->setInt(_size); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->_saving) { + if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + } else { + if (_size > 0) { + _buffer = malloc(_size); + persistMgr->getBytes((byte *)_buffer, _size); + } else _buffer = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::scCompare(CBScriptable *val) { + if (_buffer == val->scToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.h b/engines/wintermute/base/scriptables/SXMemBuffer.h new file mode 100644 index 0000000000..09831bf464 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXMemBuffer.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXMemBuffer(CBGame *inGame, CScStack *stack); + CSXMemBuffer(CBGame *inGame, void *buffer); + virtual ~CSXMemBuffer(); + virtual void *scToMemBuffer(); + int _size; +private: + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(CScScript *script, int start, int length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXString.cpp b/engines/wintermute/base/scriptables/SXString.cpp new file mode 100644 index 0000000000..ed3d243cb0 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXString.cpp @@ -0,0 +1,404 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/SXString.h" +#include "engines/wintermute/base/scriptables/SXArray.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "common/tokenizer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { + return new CSXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + setStringVal(val->getString()); + } + + if (_capacity == 0) setStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXString::scToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Substring") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); + + if (end < start) CBUtils::swap(&start, &end); + + //try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // stack->pushNULL(); + // } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Substr") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + + CScValue *val = stack->pop(); + int len = val->getInt(); + + if (!val->isNULL() && len <= 0) { + stack->pushString(""); + return STATUS_OK; + } + + if (val->isNULL()) len = strlen(_string) - start; + +// try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); +// } catch (std::exception &) { +// stack->pushNULL(); +// } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToUpperCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toUppercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToLowerCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toLowercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IndexOf") == 0) { + stack->correctParams(2); + + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString toFind; + if (_gameRef->_textEncoding == TEXT_UTF8) + toFind = StringUtil::utf8ToWide(strToFind); + else + toFind = StringUtil::ansiToWide(strToFind); + + int indexOf = StringUtil::indexOf(str, toFind, index); + stack->pushInt(indexOf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Split") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) strcpy(separators, val->getString()); + + CSXArray *array = new CSXArray(_gameRef); + if (!array) { + stack->pushNULL(); + return STATUS_OK; + } + + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString delims; + if (_gameRef->_textEncoding == TEXT_UTF8) + delims = StringUtil::utf8ToWide(separators); + else + delims = StringUtil::ansiToWide(separators); + + Common::Array parts; + + + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size());*/ + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (_gameRef->_textEncoding == TEXT_UTF8) + val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + else + val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(_string); + _scValue->setInt(wstr.size()); + } else + _scValue->setInt(strlen(_string)); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Capacity") == 0) { + _scValue->setInt(_capacity); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Capacity") == 0) { + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); + else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); + delete[] _string; + _string = newStr; + _capacity = newCap; + } + } + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->_saving) { + if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + persistMgr->getBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::scCompare(CBScriptable *val) { + return strcmp(_string, ((CSXString *)val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXString.h b/engines/wintermute/base/scriptables/SXString.h new file mode 100644 index 0000000000..348595ad29 --- /dev/null +++ b/engines/wintermute/base/scriptables/SXString.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + void scSetString(const char *val); + const char *scToString(); + void setStringVal(const char *val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScEngine.cpp b/engines/wintermute/base/scriptables/ScEngine.cpp new file mode 100644 index 0000000000..db79a7d0e9 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScEngine.cpp @@ -0,0 +1,712 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/SXMath.h" +#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BSound.h" +#include "engines/wintermute/base/BFileManager.h" + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + _gameRef->LOG(0, "Initializing scripting engine..."); + + if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); + else _gameRef->LOG(0, " Script compiler is NOT available"); + + _globals = new CScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + CScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + CScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); + _globals->setProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + + _currentScript = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + saveBreakpoints(); + + disableProfiling(); + + cleanup(); + + for (int i = 0; i < _breakpoints.getSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; + } + _breakpoints.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::cleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + + _scripts.removeAll(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { + CBGame *gameRef = (CBGame *)data; + return gameRef->_fileManager->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::closeFile(void *data, byte *buffer) { + delete [] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(_gameRef, this); + bool ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { + _gameRef->LOG(ret, "Error running script '%s'...", filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(_gameRef); + if (owner)val.setNative(owner, true); + else val.setNULL(); + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + _gameRef->getDebugMgr()->onScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { + // is script in cache? + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + return NULL; + } + + // needs to be compiled? + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; + } else { + if (!_compilerAvailable) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + delete [] buffer; + return NULL; + } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { + int index = 0; + uint32 MinTime = CBPlatform::getTime(); + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete [] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tick() { + if (_scripts.getSize() == 0) + return STATUS_OK; + + + // resolve waiting scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + { + if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + { + if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + */ + if (_gameRef->validObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); + } else _scripts[i]->finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + } else { + if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->pushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); + _scripts[i]->run(); + _scripts[i]->_waitScript->finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + default: + //warning("CScEngine::Tick - Unhandled enum"); + break; + } // switch + } // for each script + + + // execute scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 StartTime = CBPlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + } + + // normal script + else { + uint32 startTime = 0; + bool isProfiling = _isProfiling; + if (isProfiling) startTime = CBPlatform::getTime(); + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + _scripts[i]->finish(); + _currentScript = NULL; + } + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeFinishedScripts() { + // remove finished scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + numRunning++; + break; + case SCRIPT_WAITING: + numWaiting++; + break; + case SCRIPT_PERSISTENT: + numPersistent++; + break; + default: + warning("CScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) *running = numRunning; + if (waiting) *waiting = numWaiting; + if (persistent) *persistent = numPersistent; + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetScript(CScScript *script) { + // terminate all scripts waiting for this script + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::editorCleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::pauseAll() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->pause(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resumeAll() { + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->resume(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::isValidScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { + // send global variables + _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->dbgSendScript(client); + } + + // and threads later + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->dbgSendScript(client); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + CScBreakpoint *bp = NULL; + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + bp = _breakpoints[i]; + break; + } + } + if (bp == NULL) { + bp = new CScBreakpoint(scriptFilename); + _breakpoints.add(bp); + } + + for (int i = 0; i < bp->_lines.getSize(); i++) { + if (bp->_lines[i] == line) return STATUS_OK; + } + bp->_lines.add(line); + + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + if (_breakpoints[i]->_lines[j] == line) { + _breakpoints[i]->_lines.removeAt(j); + if (_breakpoints[i]->_lines.getSize() == 0) { + delete _breakpoints[i]; + _breakpoints.removeAt(i); + } + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; + } + } + break; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _scripts.getSize(); i++) { + refreshScriptBreakpoints(_scripts[i]); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints(CScScript *script) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + if (!script || !script->_filename) return STATUS_FAILED; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { + script->_breakpoints.copy(_breakpoints[i]->_lines); + return STATUS_OK; + } + } + if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::saveBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + + char text[512]; + char key[100]; + + int count = 0; + for (int i = 0; i < _breakpoints.getSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + count++; + sprintf(key, "Breakpoint%d", count); + sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + + _gameRef->_registry->writeString("Debug", key, text); + } + } + _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::loadBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + char key[100]; + + int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= count; i++) { + /* uint32 BufSize = 512; */ + sprintf(key, "Breakpoint%d", i); + AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + + char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + + if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + delete[] path; + delete[] line; + path = NULL; + line = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) return; + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::enableProfiling() { + if (_isProfiling) return; + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = CBPlatform::getTime(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::disableProfiling() { + if (!_isProfiling) return; + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h new file mode 100644 index 0000000000..df327d800c --- /dev/null +++ b/engines/wintermute/base/scriptables/ScEngine.h @@ -0,0 +1,147 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/PlatformSDL.h" + +namespace WinterMute { + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(const char *filename, byte *buffer, uint32 size) { + _timestamp = CBPlatform::getTime(); + _buffer = new byte[size]; + if (_buffer) memcpy(_buffer, buffer, size); + _size = size; + _filename = filename; + }; + + ~CScCachedScript() { + if (_buffer) delete [] _buffer; + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *filename) { + _filename = filename; + } + + ~CScBreakpoint() { + _lines.removeAll(); + } + + Common::String _filename; + CBArray _lines; + }; + + + + +public: + bool dbgSendScripts(IWmeDebugClient *client); + + CBArray _breakpoints; + bool addBreakpoint(const char *scriptFilename, int line); + bool removeBreakpoint(const char *scriptFilename, int line); + bool refreshScriptBreakpoints(); + bool refreshScriptBreakpoints(CScScript *script); + bool saveBreakpoints(); + bool loadBreakpoints(); + + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(CScScript *script); + + CScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(CBObject *Object); + bool resetScript(CScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + CScValue *_globals; + CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); + + CBArray _scripts; + + void enableProfiling(); + void disableProfiling(); + bool getIsProfiling() { + return _isProfiling; + } + + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScScript.cpp b/engines/wintermute/base/scriptables/ScScript.cpp new file mode 100644 index 0000000000..0b5b3c24bf --- /dev/null +++ b/engines/wintermute/base/scriptables/ScScript.cpp @@ -0,0 +1,1461 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScEngine.h" +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "common/memstream.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _scriptStream = NULL; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = Engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + cleanup(); +} + +void CScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.code_start = _scriptStream->readUint32LE(); + _header.func_table = _scriptStream->readUint32LE(); + _header.symbol_table = _scriptStream->readUint32LE(); + _header.event_table = _scriptStream->readUint32LE(); + _header.externals_table = _scriptStream->readUint32LE(); + _header.method_table = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); + + if (_header.magic != SCRIPT_MAGIC) { + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); + cleanup(); + return STATUS_FAILED; + } + + if (_header.version > SCRIPT_VERSION) { + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + cleanup(); + return STATUS_FAILED; + } + + initTables(); + + // init stacks + _scopeStack = new CScStack(_gameRef); + _callStack = new CScStack(_gameRef); + _thisStack = new CScStack(_gameRef); + _stack = new CScStack(_gameRef); + + _operand = new CScValue(_gameRef); + _reg1 = new CScValue(_gameRef); + + + // skip to the beginning + _iP = _header.code_start; + _scriptStream->seek(_iP); + _currentLine = 0; + + // init breakpoints + _engine->refreshScriptBreakpoints(this); + + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initTables() { + uint32 OrigIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbol_table; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.func_table; + + _numFunctions = getDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (uint32 i = 0; i < _numFunctions; i++) { + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); + } + + + // load events table + _iP = _header.event_table; + + _numEvents = getDWORD(); + _events = new TEventPos[_numEvents]; + for (uint32 i = 0; i < _numEvents; i++) { + _events[i].pos = getDWORD(); + _events[i].name = getString(); + } + + + // load externals + if (_header.version >= 0x0101) { + _iP = _header.externals_table; + + _numExternals = getDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (uint32 i = 0; i < _numExternals; i++) { + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)getDWORD(); + } + } + } + } + + // load method table + _iP = _header.method_table; + + _numMethods = getDWORD(); + _methods = new TMethodPos[_numMethods]; + for (uint32 i = 0; i < _numMethods; i++) { + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); + } + + + _iP = OrigIP; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { + cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); + + _buffer = new byte [size]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, buffer, size); + + _bufferSize = size; + + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // establish global variables table + _globals = new CScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(eventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, eventName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = initIP; + _scriptStream->seek(_iP); + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createMethodThread(CScScript *original, const char *methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) return STATUS_FAILED; + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(methodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, methodName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = ip; + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::cleanup() { + if (_buffer) delete [] _buffer; + _buffer = NULL; + + if (_filename) delete [] _filename; + _filename = NULL; + + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) delete _globals; + _globals = NULL; + + delete _scopeStack; + _scopeStack = NULL; + + delete _callStack; + _callStack = NULL; + + delete _thisStack; + _thisStack = NULL; + + delete _stack; + _stack = NULL; + + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; + + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; + + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (uint32 i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; + } + delete [] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only + + delete _scriptStream; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double CScScript::getFloat() { + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //CScValue* op = new CScValue(_gameRef); + _operand->cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = getDWORD(); + /* char *Temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); + + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = getDWORD(); + + _operand->setInt(_iP); + _callStack->push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->pop()->getString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = _stack->pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + + bool res = STATUS_FAILED; + bool TriedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + TriedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } + + if (DID_FAIL(res)) { + if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (!_unbreakable) { + _waitScript = var->getNative()->invokeMethodThread(MethodName); + if (!_waitScript) { + _stack->correctParams(0); + runtimeError("Error invoking method '%s'.", MethodName); + _stack->pushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->copyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->correctParams(0); + runtimeError("Cannot call method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->getProp(MethodName); + if(val){ + dw = GetFuncPos(val->getString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->getString()); + if(f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); + } + } + else{ + _operand->setInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = STATUS_FAILED; + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + + if (DID_FAIL(res)) { + _stack->correctParams(0); + runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = getDWORD(); + + TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + if (f) { + externalCall(_stack, _thisStack, f); + } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + _operand->setNULL(); + _scopeStack->push(_operand); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + + break; + + case II_CORRECT_STACK: + dw = getDWORD(); // params expected + _stack->correctParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->setObject(); + _stack->push(_operand); + break; + + case II_POP_EMPTY: + _stack->pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = getVar(_symbols[getDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->setReference(var); + _stack->push(_operand); + } else _stack->push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *VarName = _symbols[getDWORD()]; + CScValue *var = getVar(VarName); + if (var) { + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->setValue(val); + else { + var->copy(val); + } + } + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->push(_thisStack->getTop()); + break; + + case II_PUSH_INT: + _stack->pushInt((int)getDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->pushFloat(getFloat()); + break; + + + case II_PUSH_BOOL: + _stack->pushBool(getDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->pushString(getString()); + break; + + case II_PUSH_NULL: + _stack->pushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->setReference(_stack->getTop()); + _thisStack->push(_operand); + break; + + case II_PUSH_THIS: + _operand->setReference(getVar(_symbols[getDWORD()])); + _thisStack->push(_operand); + break; + + case II_POP_THIS: + _thisStack->pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *val = _stack->pop()->getProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); + + if (val == NULL) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else var->setProp(str, val); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + _stack->push(_reg1); + break; + + case II_POP_REG1: + _reg1->copy(_stack->pop()); + break; + + case II_JMP: + _iP = getDWORD(); + break; + + case II_JMP_FALSE: { + dw = getDWORD(); + //if(!_stack->pop()->getBool()) _iP = dw; + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!val->getBool()) _iP = dw; + } + break; + } + + case II_ADD: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); + delete [] tempStr; + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() + op2->getInt()); + else _operand->setFloat(op1->getFloat() + op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_SUB: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() - op2->getInt()); + else _operand->setFloat(op1->getFloat() - op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MUL: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() * op2->getInt()); + else _operand->setFloat(op1->getFloat() * op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_DIV: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getFloat() == 0.0f) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); + else _operand->setFloat(op1->getFloat() / op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MODULO: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getInt() == 0) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + _operand->setNULL(); + else _operand->setInt(op1->getInt() % op2->getInt()); + + _stack->push(_operand); + + break; + + case II_NOT: + op1 = _stack->pop(); + //if(op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) _operand->setBool(true); + else _operand->setBool(!op1->getBool()); + _stack->push(_operand); + + break; + + case II_AND: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() && op2->getBool()); + } + _stack->push(_operand); + break; + + case II_OR: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() || op2->getBool()); + } + _stack->push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() == op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) == 0); + _stack->push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() != op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_CMP_L: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); + } + else _operand->setBool(op1->getInt() < op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) < 0); + _stack->push(_operand); + break; + + case II_CMP_G: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); + } + else _operand->setBool(op1->getInt() > op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) > 0); + _stack->push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); + } + else _operand->setBool(op1->getInt() <= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) <= 0); + _stack->push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); + } + else _operand->setBool(op1->getInt() >= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) >= 0); + _stack->push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _stack->push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (_breakpoints[i] == _currentLine) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + if (_tracingMode) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + } + break; + + } + default: + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = STATUS_FAILED; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getFuncPos(const char *name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (strcmp(name, _functions[i].name) == 0) + return _functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getMethodPos(const char *name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (strcmp(name, _methods[i].name) == 0) + return _methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::getVar(char *name) { + CScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->getTop()->propExists(name)) + ret = _scopeStack->getTop()->getProp(name); + } + + // script globals + if (ret == NULL) { + if (_globals->propExists(name)) + ret = _globals->getProp(name); + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->propExists(name)) + ret = _engine->_globals->getProp(name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + CScValue *val = new CScValue(_gameRef); + CScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); + ret = _scopeStack->getTop()->getProp(name); + } else { + _globals->setProp(name, val); + ret = _globals->getProp(name); + } + delete val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitFor(CBObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitForExclusive(CBObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = CBPlatform::getTime() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else _state = SCRIPT_FINISHED; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::runtimeError(const char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); + + if (!_gameRef->_suppressScriptErrors) + _gameRef->quickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + persistMgr->transfer(TMEMBER(bufferSize)); + } + } else { + persistMgr->transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + initTables(); + } else { + _buffer = NULL; + _scriptStream = NULL; + } + } + + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->_saving) _tracingMode = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { + //if(_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getEventPos(const char *name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleEvent(const char *eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleMethod(const char *methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::pause() { + if (_state == SCRIPT_PAUSED) { + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return STATUS_FAILED; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + + _origState = _state; + _state = SCRIPT_PAUSED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::resume() { + if (_state != SCRIPT_PAUSED) return STATUS_OK; + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) + return &_externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::copyParameters(CScStack *stack) { + int i; + int NumParams = stack->pop()->getInt(); + for (i = NumParams - 1; i >= 0; i--) { + _stack->push(stack->getAt(i)); + } + _stack->pushInt(NumParams); + + for (i = 0; i < NumParams; i++) stack->pop(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finishThreads() { + for (int i = 0; i < _engine->_scripts.getSize(); i++) { + CScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + scr->finish(true); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::dbgGetFilename() { + return _filename; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendScript(IWmeDebugClient *client) { + if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else client->onScriptInit(this); + + return dbgSendVariables(client); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendVariables(IWmeDebugClient *client) { + // send script globals + _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + // CScValue *Scope = _scopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::dbgGetState() { + return _state; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetNumBreakpoints() { + return _breakpoints.getSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetBreakpoint(int index) { + if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSetTracingMode(bool isTracing) { + _tracingMode = isTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgGetTracingMode() { + return _tracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::afterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); + if (!buffer) { + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + + initTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScScript.h b/engines/wintermute/base/scriptables/ScScript.h new file mode 100644 index 0000000000..c031f8186f --- /dev/null +++ b/engines/wintermute/base/scriptables/ScScript.h @@ -0,0 +1,183 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + bool dbgSendScript(IWmeDebugClient *client); + bool dbgSendVariables(IWmeDebugClient *client); + + CBArray _breakpoints; + bool _tracingMode; + + CScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(CScStack *stack); + + void afterLoad(); + + CScValue *_operand; + CScValue *_reg1; + bool _freezable; + bool resume(); + bool pause(); + bool canHandleEvent(const char *eventName); + bool canHandleMethod(const char *methodName); + bool createThread(CScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(CScScript *original, const char *methodName); + CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void runtimeError(const char *fmt, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(CBObject *object); + bool waitFor(CBObject *object); + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + CScValue *getVar(char *name); + uint32 getFuncPos(const char *name); + uint32 getEventPos(const char *name); + uint32 getMethodPos(const char *name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + TScriptHeader _header; + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; + bool executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); + void cleanup(); + bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *_filename; + char **_symbols; + uint32 _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; + CScScript::TExternalFunction *getExternal(char *name); + bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); +private: + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); + virtual TScriptState dbgGetState(); + virtual int dbgGetNumBreakpoints(); + virtual int dbgGetBreakpoint(int Index); + + virtual bool dbgSetTracingMode(bool IsTracing); + virtual bool dbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScStack.cpp b/engines/wintermute/base/scriptables/ScStack.cpp new file mode 100644 index 0000000000..252cd21dda --- /dev/null +++ b/engines/wintermute/base/scriptables/ScStack.cpp @@ -0,0 +1,226 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/ScStack.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/BGame.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); +#endif + + for (int i = 0; i < _values.getSize(); i++) { + delete _values[i]; + } + _values.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::push(CScValue *val) { + _sP++; + + if (_sP < _values.getSize()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + CScValue *copyVal = new CScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getPushValue() { + _sP++; + + if (_sP >= _values.getSize()) { + CScValue *val = new CScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getTop() { + if (_sP < 0 || _sP >= _values.getSize()) return NULL; + else return _values[_sP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= _values.getSize()) return NULL; + else return _values[index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.removeAt(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + CScValue *nullVal = new CScValue(_gameRef); + nullVal->setNULL(); + _values.insertAt(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if (_values.getSize() > _sP + 1) { + delete _values[_values.getSize() - 1]; + _values.removeAt(_values.getSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNULL() { + /* + CScValue* val = new CScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushInt(int val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushFloat(double val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushBool(bool val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushString(const char *val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNative(CBScriptable *val, bool persistent) { + /* + CScValue* val = new CScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScStack::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_sP)); + _values.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScStack.h b/engines/wintermute/base/scriptables/ScStack.h new file mode 100644 index 0000000000..22dae63060 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScStack.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *getAt(int Index); + CScValue *getPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void pushNative(CBScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); + void pushNULL(); + void correctParams(uint32 expectedParams); + CScValue *getTop(); + void push(CScValue *val); + CScValue *pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray _values; + int _sP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp new file mode 100644 index 0000000000..e9d5645682 --- /dev/null +++ b/engines/wintermute/base/scriptables/ScValue.cpp @@ -0,0 +1,1054 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/base/BDynBuffer.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/scriptables/ScValue.h" +#include "engines/wintermute/base/scriptables/ScScript.h" +#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/BScriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::cleanup(bool ignoreNatives) { + deleteProps(); + + if (_valString) delete [] _valString; + + if (!ignoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { + _gameRef->_scValue->_type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (_gameRef->_textEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + CScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + + if (ret == NULL) { + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) ret = _valIter->_value; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) + return _valRef->setProp(name, val); + + bool ret = STATUS_FAILED; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scSetProperty(name, val); + } + + if (DID_FAIL(ret)) { + CScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) + newVal = new CScValue(_gameRef); + else newVal->cleanup(); + + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; + + if (_type != VAL_NATIVE) _type = VAL_OBJECT; + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + CScValue* val = new CScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) + return _valRef->propExists(name); + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNULL(); + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNative(); + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isString(); + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isFloat(); + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isInt() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isInt(); + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isBool() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isBool(); + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isObject() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isObject(); + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getType(); + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setBool(bool val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setBool(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetBool(val); + return; + } + + _valBool = val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setInt(int val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setInt(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetInt(val); + return; + } + + _valInt = val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setFloat(double val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setFloat(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetFloat(val); + return; + } + + _valFloat = val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setString(const char *val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setString(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetString(val); + return; + } + + setStringVal(val); + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; +} + +void CScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void CScValue::setStringVal(const char *val) { + if (_valString) { + delete [] _valString; + _valString = NULL; + } + + if (val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(val) + 1]; + if (_valString) { + strcpy(_valString, val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; + } + _valNative = NULL; + deleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNative(CBScriptable *val, bool persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNative(val, persistent); + return; + } + + if (val == NULL) { + setNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != val) delete _valNative; + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = persistent; + + _valNative = val; + if (_valNative && !_persistent) _valNative->_refCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setReference(CScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getBool(); + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->scToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::getInt(int defaultVal) { + if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->scToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getFloat(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->scToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return defaultVal; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getMemBuffer(); + + if (_type == VAL_NATIVE) + return _valNative->scToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::getString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getString(); + + switch (_type) { + case VAL_OBJECT: + setStringVal("[object]"); + break; + + case VAL_NULL: + setStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; + break; + } + + case VAL_BOOL: + setStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + setStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + setStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + setStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::getNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getNative(); + + if (_type == VAL_NATIVE) return _valNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::copy(CScValue *orig, bool copyWhole) { + _gameRef = orig->_gameRef; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + + cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + setStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setValue(CScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { + case VAL_INT: + _valNative->scSetInt(val->getInt()); + break; + case VAL_FLOAT: + _valNative->scSetFloat(val->getFloat()); + break; + case VAL_BOOL: + _valNative->scSetBool(val->getBool()); + break; + case VAL_STRING: + _valNative->scSetString(val->getString()); + break; + default: + warning("CScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else copy(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (persistMgr->_saving) { + size = _valObject.size(); + persistMgr->transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); + + _valIter++; + } + } else { + CScValue *val; + persistMgr->transfer("", &size); + for (int i = 0; i < size; i++) { + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); + + _valObject[str] = val; + delete [] str; + } + } + + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); + + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::compare(CScValue *val1, CScValue *val2) { + // both natives? + if (val1->isNative() && val2->isNative()) { + // same class? + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else return strcmp(val1->getString(), val2->getString()); + } + + // both objects? + if (val1->isObject() && val2->isObject()) return -1; + + + // null states + if (val1->isNULL() && !val2->isNULL()) return -1; + else if (!val1->isNULL() && val2->isNULL()) return 1; + else if (val1->isNULL() && val2->isNULL()) return 0; + + // one of them is string? convert both to string + if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + + // one of them is float? + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) return -1; + else if (val1->getFloat() > val2->getFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (val1->getInt() < val2->getInt()) return -1; + else if (val1->getInt() > val2->getInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::compareStrict(CScValue *val1, CScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; + else return CScValue::compare(val1, val2); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, int value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, const char *value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, double value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, bool value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName) { + CScValue *val = new CScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::dbgGetType() { + switch (getType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetValInt() { + return getInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::dbgGetValFloat() { + return getFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetValBool() { + return getBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::dbgGetValString() { + return getString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::dbgGetValNative() { + return getNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(int value) { + setInt(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(double value) { + setFloat(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(bool value) { + setBool(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(const char *value) { + setString(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal() { + setNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetNumProperties() { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetNumProperties(); + else return _valObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetProperty(index, name, value); + else { + int count = 0; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (count == index) { + *name = _valIter->_key.c_str(); + *value = _valIter->_value; + return true; + } + _valIter++; + count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) + return _valRef->dbgGetDescription(buf, bufSize); + + if (_type == VAL_NATIVE) { + _valNative->scDebuggerDesc(buf, bufSize); + } else { + strncpy(buf, getString(), bufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScValue.h b/engines/wintermute/base/scriptables/ScValue.h new file mode 100644 index 0000000000..c66a60c22a --- /dev/null +++ b/engines/wintermute/base/scriptables/ScValue.h @@ -0,0 +1,141 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + + static int compare(CScValue *val1, CScValue *val2); + static int compareStrict(CScValue *val1, CScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool _isConstVar; + bool saveAsText(CBDynBuffer *buffer, int indent); + void setValue(CScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(CScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); + const char *getString(); + void *getMemBuffer(); + CBScriptable *getNative(); + bool deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(CBScriptable *val, bool persistent = false); + void setObject(); + void setReference(CScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + CScValue *getProp(const char *name); + CBScriptable *_valNative; + CScValue *_valRef; +protected: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType dbgGetType(); + + // getters + virtual int dbgGetValInt(); + virtual double dbgGetValFloat(); + virtual bool dbgGetValBool(); + virtual const char *dbgGetValString(); + virtual IWmeDebugObject *dbgGetValNative(); + + // setters + virtual bool dbgSetVal(int value); + virtual bool dbgSetVal(double value); + virtual bool dbgSetVal(bool value); + virtual bool dbgSetVal(const char *value); + virtual bool dbgSetVal(); + + // properties + virtual int dbgGetNumProperties(); + virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); + + virtual bool dbgGetDescription(char *buf, int bufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SxObject.cpp b/engines/wintermute/base/scriptables/SxObject.cpp new file mode 100644 index 0000000000..ba961ed2ae --- /dev/null +++ b/engines/wintermute/base/scriptables/SxObject.cpp @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "SxObject.h" +#include "ScValue.h" +#include "ScStack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { + return new CSXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { + addScript(stack->pop()->getString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SxObject.h b/engines/wintermute/base/scriptables/SxObject.h new file mode 100644 index 0000000000..b4ec7c6cde --- /dev/null +++ b/engines/wintermute/base/scriptables/SxObject.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/base/BObject.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 3ad839b32c5e432e93058218db9139dfbe8b8c84 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 00:45:20 +0200 Subject: WINTERMUTE: Rename PlatformSDL->platform_osystem --- engines/wintermute/base/BActiveRect.cpp | 2 +- engines/wintermute/base/BFader.cpp | 2 +- engines/wintermute/base/BFileManager.cpp | 2 +- engines/wintermute/base/BFrame.cpp | 2 +- engines/wintermute/base/BObject.cpp | 2 +- engines/wintermute/base/BParser.cpp | 2 +- engines/wintermute/base/BPersistMgr.cpp | 2 +- engines/wintermute/base/BRegion.cpp | 2 +- engines/wintermute/base/BResources.cpp | 2 +- engines/wintermute/base/BSprite.cpp | 2 +- engines/wintermute/base/BStringTable.cpp | 2 +- engines/wintermute/base/BSubFrame.cpp | 2 +- engines/wintermute/base/BSurfaceStorage.cpp | 2 +- engines/wintermute/base/BTransitionMgr.cpp | 2 +- engines/wintermute/base/BViewport.cpp | 2 +- engines/wintermute/base/file/BSaveThumbFile.cpp | 2 +- engines/wintermute/base/font/BFontBitmap.cpp | 2 +- engines/wintermute/base/font/BFontStorage.cpp | 2 +- engines/wintermute/base/font/BFontTT.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/base/particles/PartEmitter.cpp | 2 +- engines/wintermute/base/particles/PartParticle.cpp | 2 +- engines/wintermute/base/scriptables/SXFile.cpp | 2 +- engines/wintermute/base/scriptables/ScEngine.h | 2 +- engines/wintermute/base/scriptables/ScValue.cpp | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp index 382329087a..836a93ad9a 100644 --- a/engines/wintermute/base/BActiveRect.cpp +++ b/engines/wintermute/base/BActiveRect.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/BActiveRect.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp index 7184c6664c..9dec5e1e12 100644 --- a/engines/wintermute/base/BFader.cpp +++ b/engines/wintermute/base/BFader.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BFader.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/util.h" namespace WinterMute { diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 1cfb3d47d3..80b3d7a8df 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -40,7 +40,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/dcpackage.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/textconsole.h" diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp index 4af9262701..d6d8a3aa5c 100644 --- a/engines/wintermute/base/BFrame.cpp +++ b/engines/wintermute/base/BFrame.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/BSoundMgr.h" #include "engines/wintermute/base/BSound.h" #include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp index 1bb52c0ce6..ed5d6fa5b7 100644 --- a/engines/wintermute/base/BObject.cpp +++ b/engines/wintermute/base/BObject.cpp @@ -36,7 +36,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BStringTable.h" #include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp index f675d0ca50..80d3b58213 100644 --- a/engines/wintermute/base/BParser.cpp +++ b/engines/wintermute/base/BParser.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BParser.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/util.h" diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp index 0f2cc6bc8a..f8faced95f 100644 --- a/engines/wintermute/base/BPersistMgr.cpp +++ b/engines/wintermute/base/BPersistMgr.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BPersistMgr.h" #include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/math/Vector2.h" #include "engines/wintermute/utils/StringUtil.h" #include "engines/wintermute/base/gfx/base_image.h" diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp index 1c38174cb8..c8ec87e04a 100644 --- a/engines/wintermute/base/BRegion.cpp +++ b/engines/wintermute/base/BRegion.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/scriptables/ScStack.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include namespace WinterMute { diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp index b99441b5db..839be570c5 100644 --- a/engines/wintermute/base/BResources.cpp +++ b/engines/wintermute/base/BResources.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BResources.h" #include "common/str.h" #include "common/memstream.h" diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp index c93a40ca75..c4dfaa3f8d 100644 --- a/engines/wintermute/base/BSprite.cpp +++ b/engines/wintermute/base/BSprite.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BSound.h" #include "engines/wintermute/base/BSubFrame.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScScript.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp index 44f26ba7e8..470ae8549c 100644 --- a/engines/wintermute/base/BStringTable.cpp +++ b/engines/wintermute/base/BStringTable.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BStringTable.h" diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp index 60048ac05a..858f2125c6 100644 --- a/engines/wintermute/base/BSubFrame.cpp +++ b/engines/wintermute/base/BSubFrame.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BSurfaceStorage.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/ScValue.h" #include "engines/wintermute/base/scriptables/ScStack.h" diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp index f50d174898..887510b675 100644 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp index 7c9a95368a..1cea7285bf 100644 --- a/engines/wintermute/base/BTransitionMgr.cpp +++ b/engines/wintermute/base/BTransitionMgr.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BTransitionMgr.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp index 0f2a67d3bf..2b237a0d38 100644 --- a/engines/wintermute/base/BViewport.cpp +++ b/engines/wintermute/base/BViewport.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BViewport.h" namespace WinterMute { diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp index b2eebb690b..4a75b7d7ce 100644 --- a/engines/wintermute/base/file/BSaveThumbFile.cpp +++ b/engines/wintermute/base/file/BSaveThumbFile.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp index 031f075d1b..341f90d559 100644 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/BFrame.h" #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp index a777ac9db8..b5605cf2bc 100644 --- a/engines/wintermute/base/font/BFontStorage.cpp +++ b/engines/wintermute/base/font/BFontStorage.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/font/BFontStorage.h" #include "engines/wintermute/base/font/BFont.h" #include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp index 2707dbea31..5f0c9fec1a 100644 --- a/engines/wintermute/base/font/BFontTT.cpp +++ b/engines/wintermute/base/font/BFontTT.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "graphics/fonts/ttf.h" #include "graphics/fontman.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 010aca7141..5c5ebd91b4 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/BSubFrame.h" #include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 1e4ac9a19e..66c6e4a61a 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp index 81147a5432..97de1fe044 100644 --- a/engines/wintermute/base/particles/PartEmitter.cpp +++ b/engines/wintermute/base/particles/PartEmitter.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/BRegion.h" #include "engines/wintermute/base/BFileManager.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/math.h" diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp index aa641f0a1c..1439231993 100644 --- a/engines/wintermute/base/particles/PartParticle.cpp +++ b/engines/wintermute/base/particles/PartParticle.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/BSprite.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp index b2a6d24677..1924a42d72 100644 --- a/engines/wintermute/base/scriptables/SXFile.cpp +++ b/engines/wintermute/base/scriptables/SXFile.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/file/BFile.h" #include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/SXFile.h" // Note: This code is completely untested, as I have yet to find a game that uses SXFile. diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h index df327d800c..0322319b3d 100644 --- a/engines/wintermute/base/scriptables/ScEngine.h +++ b/engines/wintermute/base/scriptables/ScEngine.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/BBase.h" #include "engines/wintermute/wme_debugger.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp index e9d5645682..f38a12fc7a 100644 --- a/engines/wintermute/base/scriptables/ScValue.cpp +++ b/engines/wintermute/base/scriptables/ScValue.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/PlatformSDL.h" +#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/BDynBuffer.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/scriptables/ScValue.h" -- cgit v1.2.3 From c648eb2b5ed80f12222556fd6c8a35b9c99dc0fc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 00:53:38 +0200 Subject: WINTERMUTE: Move BFileEntry and BPackage into base/file --- engines/wintermute/base/BFileEntry.cpp | 50 ------------- engines/wintermute/base/BFileEntry.h | 57 --------------- engines/wintermute/base/BFileManager.cpp | 4 +- engines/wintermute/base/BFileManager.h | 2 +- engines/wintermute/base/BPackage.cpp | 104 ---------------------------- engines/wintermute/base/BPackage.h | 61 ---------------- engines/wintermute/base/file/BFileEntry.cpp | 50 +++++++++++++ engines/wintermute/base/file/BFileEntry.h | 57 +++++++++++++++ engines/wintermute/base/file/BPackage.cpp | 104 ++++++++++++++++++++++++++++ engines/wintermute/base/file/BPackage.h | 61 ++++++++++++++++ engines/wintermute/base/file/BPkgFile.cpp | 2 +- engines/wintermute/base/file/BPkgFile.h | 2 +- 12 files changed, 277 insertions(+), 277 deletions(-) delete mode 100644 engines/wintermute/base/BFileEntry.cpp delete mode 100644 engines/wintermute/base/BFileEntry.h delete mode 100644 engines/wintermute/base/BPackage.cpp delete mode 100644 engines/wintermute/base/BPackage.h create mode 100644 engines/wintermute/base/file/BFileEntry.cpp create mode 100644 engines/wintermute/base/file/BFileEntry.h create mode 100644 engines/wintermute/base/file/BPackage.cpp create mode 100644 engines/wintermute/base/file/BPackage.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/BFileEntry.cpp b/engines/wintermute/base/BFileEntry.cpp deleted file mode 100644 index 39223bfb8e..0000000000 --- a/engines/wintermute/base/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileEntry.h b/engines/wintermute/base/BFileEntry.h deleted file mode 100644 index 5fdf2b6308..0000000000 --- a/engines/wintermute/base/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 80b3d7a8df..35dde203c7 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -32,10 +32,10 @@ #include "engines/wintermute/utils/PathUtil.h" #include "engines/wintermute/base/file/BDiskFile.h" #include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" +#include "engines/wintermute/base/file/BPackage.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/BResources.h" -#include "engines/wintermute/base/BPackage.h" #include "engines/wintermute/base/BRegistry.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/dcpackage.h" diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h index 8e7551480d..7ea9ff5611 100644 --- a/engines/wintermute/base/BFileManager.h +++ b/engines/wintermute/base/BFileManager.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/BPackage.cpp b/engines/wintermute/base/BPackage.cpp deleted file mode 100644 index 020b7b902f..0000000000 --- a/engines/wintermute/base/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPackage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - closeFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { - if (_file) return STATUS_OK; - else { - _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { - delete _file; - _file = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (DID_FAIL(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); - if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPackage.h b/engines/wintermute/base/BPackage.h deleted file mode 100644 index 8c803fddd9..0000000000 --- a/engines/wintermute/base/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "engines/wintermute/base/BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFileEntry.cpp b/engines/wintermute/base/file/BFileEntry.cpp new file mode 100644 index 0000000000..b00ecb6f9d --- /dev/null +++ b/engines/wintermute/base/file/BFileEntry.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BFileEntry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFileEntry.h b/engines/wintermute/base/file/BFileEntry.h new file mode 100644 index 0000000000..5fdf2b6308 --- /dev/null +++ b/engines/wintermute/base/file/BFileEntry.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/BBase.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPackage.cpp b/engines/wintermute/base/file/BPackage.cpp new file mode 100644 index 0000000000..bddf1abc1e --- /dev/null +++ b/engines/wintermute/base/file/BPackage.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/BPackage.h" +#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/BFileManager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPackage.h b/engines/wintermute/base/file/BPackage.h new file mode 100644 index 0000000000..8c803fddd9 --- /dev/null +++ b/engines/wintermute/base/file/BPackage.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/BBase.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 7eafe7919e..b787851290 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPackage.h" +#include "engines/wintermute/base/file/BPackage.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/BGame.h" #include "engines/wintermute/base/BFileManager.h" diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index f8a5831485..dc8b4b684f 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BPKGFILE_H #define WINTERMUTE_BPKGFILE_H -#include "engines/wintermute/base/BFileEntry.h" +#include "engines/wintermute/base/file/BFileEntry.h" namespace Common { class SeekableReadStream; -- cgit v1.2.3 From 958cb16f9e9d0995c71a54bd20d4b8464775a9e6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 02:44:15 +0200 Subject: WINTERMUTE: Silence a few signed/unsigned warnings. --- engines/wintermute/base/BFileManager.cpp | 30 ++++++++++++++-------------- engines/wintermute/base/BSoundMgr.cpp | 10 +++++----- engines/wintermute/base/BSurfaceStorage.cpp | 10 +++++----- engines/wintermute/base/file/BDiskFile.cpp | 2 +- engines/wintermute/base/font/BFontBitmap.cpp | 2 +- 5 files changed, 27 insertions(+), 27 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp index 35dde203c7..34638f55e8 100644 --- a/engines/wintermute/base/BFileManager.cpp +++ b/engines/wintermute/base/BFileManager.cpp @@ -75,11 +75,11 @@ CBFileManager::~CBFileManager() { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::cleanup() { // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) + for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; _singlePaths.clear(); - for (int i = 0; i < _packagePaths.size(); i++) + for (uint32 i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; _packagePaths.clear(); @@ -93,14 +93,14 @@ bool CBFileManager::cleanup() { _files.clear(); // close open files - for (int i = 0; i < _openFiles.size(); i++) { + for (uint32 i = 0; i < _openFiles.size(); i++) { delete _openFiles[i]; } _openFiles.clear(); // delete packages - for (int i = 0; i < _packages.size(); i++) + for (uint32 i = 0; i < _packages.size(); i++) delete _packages[i]; _packages.clear(); @@ -225,7 +225,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 ////////////////////////////////////////////////////////////////////////// bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages - for (int i = 0; i < _packages.size(); i++) { + for (uint32 i = 0; i < _packages.size(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); } @@ -262,11 +262,11 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// bool CBFileManager::reloadPaths() { // delete registered paths - for (int i = 0; i < _singlePaths.size(); i++) + for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; _singlePaths.clear(); - for (int i = 0; i < _packagePaths.size(); i++) + for (uint32 i = 0; i < _packagePaths.size(); i++) delete [] _packagePaths[i]; _packagePaths.clear(); @@ -378,13 +378,13 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search bool boundToExe = false; if (searchSignature) { - uint32 Offset; - if (!findPackageSignature(package, &Offset)) { + uint32 offset; + if (!findPackageSignature(package, &offset)) { delete package; return STATUS_OK; } else { - package->seek(Offset, SEEK_SET); - absoluteOffset = Offset; + package->seek(offset, SEEK_SET); + absoluteOffset = offset; boundToExe = true; } } @@ -511,7 +511,7 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _packagePaths.size(); i++) { + for (uint32 i = 0; i < _packagePaths.size(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { @@ -537,7 +537,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { Common::File *ret = NULL; char filename[MAX_PATH_LENGTH]; - for (int i = 0; i < _singlePaths.size(); i++) { + for (uint32 i = 0; i < _singlePaths.size(); i++) { sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); ret->open(filename); if (ret->isOpen()) @@ -562,7 +562,7 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) Common::File f; bool found = false; - for (int i = 0; i < _singlePaths.size(); i++) { + for (uint32 i = 0; i < _singlePaths.size(); i++) { sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); f.open(fullname); if (f.isOpen()) { @@ -632,7 +632,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (int i = 0; i < _openFiles.size(); i++) { + for (uint32 i = 0; i < _openFiles.size(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; _openFiles.remove_at(i); diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp index 8d9b775c68..66baa633e4 100644 --- a/engines/wintermute/base/BSoundMgr.cpp +++ b/engines/wintermute/base/BSoundMgr.cpp @@ -62,7 +62,7 @@ CBSoundMgr::~CBSoundMgr() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::cleanup() { - for (int i = 0; i < _sounds.size(); i++) + for (uint32 i = 0; i < _sounds.size(); i++) delete _sounds[i]; _sounds.clear(); #if 0 @@ -164,7 +164,7 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; _sounds.remove_at(i); @@ -227,7 +227,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { _sounds[i]->updateVolume(); } return STATUS_OK; @@ -254,7 +254,7 @@ byte CBSoundMgr::getMasterVolume() { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::pauseAll(bool includingMusic) { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { _sounds[i]->pause(); _sounds[i]->_freezePaused = true; @@ -268,7 +268,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// bool CBSoundMgr::resumeAll() { - for (int i = 0; i < _sounds.size(); i++) { + for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->_freezePaused) { _sounds[i]->resume(); _sounds[i]->_freezePaused = false; diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp index 887510b675..406535cf39 100644 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ b/engines/wintermute/base/BSurfaceStorage.cpp @@ -52,7 +52,7 @@ CBSurfaceStorage::~CBSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::cleanup(bool warn) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } @@ -67,7 +67,7 @@ bool CBSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i]->_lifeTime <= 0) break; if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { @@ -82,7 +82,7 @@ bool CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; if (_surfaces[i]->_referenceCount <= 0) { @@ -98,7 +98,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; @@ -132,7 +132,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// bool CBSurfaceStorage::restoreAll() { bool ret; - for (int i = 0; i < _surfaces.size(); i++) { + for (uint32 i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp index f2938cebc9..739eafcc73 100644 --- a/engines/wintermute/base/file/BDiskFile.cpp +++ b/engines/wintermute/base/file/BDiskFile.cpp @@ -50,7 +50,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileM uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (int i = 0; i < fileManager->_singlePaths.size(); i++) { + for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); correctSlashes(fullPath); Common::File *tempFile = new Common::File(); diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp index 341f90d559..62576cdfea 100644 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ b/engines/wintermute/base/font/BFontBitmap.cpp @@ -97,7 +97,7 @@ int CBFontBitmap::getTextWidth(byte *text, int maxLength) { //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; - for (size_t i = 0; i < str.size(); i++) { + for (int i = 0; i < str.size(); i++) { textWidth += getCharWidth(str[i]); } -- cgit v1.2.3 From b618f7985f33cbb24e36eaf6490ddc59cc148a0a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 20 Jul 2012 03:53:13 +0200 Subject: WINTERMUTE: Decrement tickets when reinserting a ticket that has swapped places. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 12 ++++++++++-- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index fc971357bf..ee971ab6c9 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -352,7 +352,7 @@ void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surfa RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket._surface, &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); return; } // Skip rects that are completely outside the screen: @@ -432,6 +432,12 @@ void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { it++; } } + if (it != _renderQueue.end()) { + // Decreement the following tickets. + for (; it != _renderQueue.end(); it++) { + (*it)->_drawNum--; + } + } // Is not in order, so readd it as if it was a new ticket renderTicket->_drawNum = 0; drawFromTicket(renderTicket); @@ -475,8 +481,10 @@ void CBRenderOSystem::drawTickets() { // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); + _drawNum = 1; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { RenderTicket *ticket = *it; + assert(ticket->_drawNum == _drawNum++); if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { // dstClip is the area we want redrawn. Common::Rect dstClip(ticket->_dstRect); @@ -490,7 +498,7 @@ void CBRenderOSystem::drawTickets() { dstClip.translate(-offsetX, -offsetY); _colorMod = ticket->_colorMod; - drawFromSurface(ticket->_surface, &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + drawFromSurface(ticket->getSurface(), &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); _needsFlip = true; } // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index d41d14ef35..8a8eb88ede 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -37,11 +37,12 @@ namespace WinterMute { class CBSurfaceOSystem; class RenderTicket { + Graphics::Surface *_surface; public: RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); - Graphics::Surface *_surface; + const Graphics::Surface *getSurface() { return _surface; } Common::Rect _srcRect; Common::Rect _dstRect; uint32 _mirror; -- cgit v1.2.3 From 5683f076331d2831eb4720b65bb53e8d01ca33ee Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 18:19:07 +0200 Subject: WINTERMUTE: Rename CamelCased filenames to prefixed_under_score-filenames This is mostly a lead-up to namespacing the Ad/Base folders, and then possibly removing the prefixes from the files, it also has the added benefit of getting rid of the odd case-typos that makes for issues on platforms that don't ignore case. --- engines/wintermute/base/BActiveRect.cpp | 107 - engines/wintermute/base/BActiveRect.h | 60 - engines/wintermute/base/BBase.cpp | 178 - engines/wintermute/base/BBase.h | 64 - engines/wintermute/base/BDebugger.cpp | 203 - engines/wintermute/base/BDebugger.h | 95 - engines/wintermute/base/BDynBuffer.cpp | 192 - engines/wintermute/base/BDynBuffer.h | 66 - engines/wintermute/base/BFader.cpp | 176 - engines/wintermute/base/BFader.h | 62 - engines/wintermute/base/BFileManager.cpp | 737 ---- engines/wintermute/base/BFileManager.h | 85 - engines/wintermute/base/BFrame.cpp | 705 --- engines/wintermute/base/BFrame.h | 73 - engines/wintermute/base/BGame.cpp | 4478 -------------------- engines/wintermute/base/BGame.h | 391 -- engines/wintermute/base/BKeyboardState.cpp | 304 -- engines/wintermute/base/BKeyboardState.h | 75 - engines/wintermute/base/BNamedObject.cpp | 65 - engines/wintermute/base/BNamedObject.h | 50 - engines/wintermute/base/BObject.cpp | 1128 ----- engines/wintermute/base/BObject.h | 144 - engines/wintermute/base/BParser.cpp | 436 -- engines/wintermute/base/BParser.h | 89 - engines/wintermute/base/BPersistMgr.cpp | 778 ---- engines/wintermute/base/BPersistMgr.h | 114 - engines/wintermute/base/BPoint.cpp | 64 - engines/wintermute/base/BPoint.h | 50 - engines/wintermute/base/BQuickMsg.cpp | 54 - engines/wintermute/base/BQuickMsg.h | 48 - engines/wintermute/base/BRegion.cpp | 508 --- engines/wintermute/base/BRegion.h | 68 - engines/wintermute/base/BRegistry.cpp | 257 -- engines/wintermute/base/BRegistry.h | 76 - engines/wintermute/base/BResources.cpp | 2820 ------------ engines/wintermute/base/BResources.h | 44 - engines/wintermute/base/BSaveThumbHelper.cpp | 79 - engines/wintermute/base/BSaveThumbHelper.h | 50 - engines/wintermute/base/BScriptHolder.cpp | 473 --- engines/wintermute/base/BScriptHolder.h | 74 - engines/wintermute/base/BScriptable.cpp | 188 - engines/wintermute/base/BScriptable.h | 90 - engines/wintermute/base/BSound.cpp | 288 -- engines/wintermute/base/BSound.h | 88 - engines/wintermute/base/BSoundBuffer.cpp | 383 -- engines/wintermute/base/BSoundBuffer.h | 100 - engines/wintermute/base/BSoundMgr.cpp | 292 -- engines/wintermute/base/BSoundMgr.h | 69 - engines/wintermute/base/BSprite.cpp | 758 ---- engines/wintermute/base/BSprite.h | 90 - engines/wintermute/base/BStringTable.cpp | 229 - engines/wintermute/base/BStringTable.h | 55 - engines/wintermute/base/BSubFrame.cpp | 589 --- engines/wintermute/base/BSubFrame.h | 86 - engines/wintermute/base/BSurfaceStorage.cpp | 189 - engines/wintermute/base/BSurfaceStorage.h | 57 - engines/wintermute/base/BTransitionMgr.cpp | 131 - engines/wintermute/base/BTransitionMgr.h | 54 - engines/wintermute/base/BViewport.cpp | 98 - engines/wintermute/base/BViewport.h | 55 - engines/wintermute/base/base.cpp | 178 + engines/wintermute/base/base.h | 64 + engines/wintermute/base/base_active_rect.cpp | 107 + engines/wintermute/base/base_active_rect.h | 60 + engines/wintermute/base/base_debugger.cpp | 203 + engines/wintermute/base/base_debugger.h | 95 + engines/wintermute/base/base_dynamic_buffer.cpp | 192 + engines/wintermute/base/base_dynamic_buffer.h | 66 + engines/wintermute/base/base_fader.cpp | 176 + engines/wintermute/base/base_fader.h | 62 + engines/wintermute/base/base_file_manager.cpp | 737 ++++ engines/wintermute/base/base_file_manager.h | 85 + engines/wintermute/base/base_frame.cpp | 705 +++ engines/wintermute/base/base_frame.h | 73 + engines/wintermute/base/base_game.cpp | 4477 +++++++++++++++++++ engines/wintermute/base/base_game.h | 391 ++ engines/wintermute/base/base_keyboard_state.cpp | 304 ++ engines/wintermute/base/base_keyboard_state.h | 75 + engines/wintermute/base/base_named_object.cpp | 65 + engines/wintermute/base/base_named_object.h | 50 + engines/wintermute/base/base_object.cpp | 1128 +++++ engines/wintermute/base/base_object.h | 144 + engines/wintermute/base/base_parser.cpp | 436 ++ engines/wintermute/base/base_parser.h | 89 + .../wintermute/base/base_persistence_manager.cpp | 778 ++++ engines/wintermute/base/base_persistence_manager.h | 114 + engines/wintermute/base/base_point.cpp | 64 + engines/wintermute/base/base_point.h | 50 + engines/wintermute/base/base_quick_msg.cpp | 54 + engines/wintermute/base/base_quick_msg.h | 48 + engines/wintermute/base/base_region.cpp | 508 +++ engines/wintermute/base/base_region.h | 68 + engines/wintermute/base/base_registry.cpp | 257 ++ engines/wintermute/base/base_registry.h | 76 + engines/wintermute/base/base_save_thumb_helper.cpp | 79 + engines/wintermute/base/base_save_thumb_helper.h | 50 + engines/wintermute/base/base_script_holder.cpp | 473 +++ engines/wintermute/base/base_script_holder.h | 74 + engines/wintermute/base/base_scriptable.cpp | 188 + engines/wintermute/base/base_scriptable.h | 90 + engines/wintermute/base/base_sprite.cpp | 758 ++++ engines/wintermute/base/base_sprite.h | 90 + engines/wintermute/base/base_string_table.cpp | 229 + engines/wintermute/base/base_string_table.h | 55 + engines/wintermute/base/base_sub_frame.cpp | 589 +++ engines/wintermute/base/base_sub_frame.h | 86 + engines/wintermute/base/base_surface_storage.cpp | 189 + engines/wintermute/base/base_surface_storage.h | 57 + .../wintermute/base/base_transition_manager.cpp | 131 + engines/wintermute/base/base_transition_manager.h | 54 + engines/wintermute/base/base_viewport.cpp | 98 + engines/wintermute/base/base_viewport.h | 55 + engines/wintermute/base/file/BDiskFile.cpp | 131 - engines/wintermute/base/file/BDiskFile.h | 42 - engines/wintermute/base/file/BFile.cpp | 69 - engines/wintermute/base/file/BFile.h | 67 - engines/wintermute/base/file/BFileEntry.cpp | 50 - engines/wintermute/base/file/BFileEntry.h | 57 - engines/wintermute/base/file/BPackage.cpp | 104 - engines/wintermute/base/file/BPackage.h | 61 - engines/wintermute/base/file/BPkgFile.cpp | 6 +- engines/wintermute/base/file/BPkgFile.h | 5 +- engines/wintermute/base/file/BSaveThumbFile.cpp | 146 - engines/wintermute/base/file/BSaveThumbFile.h | 52 - engines/wintermute/base/file/base_disk_file.cpp | 131 + engines/wintermute/base/file/base_disk_file.h | 42 + engines/wintermute/base/file/base_file.cpp | 69 + engines/wintermute/base/file/base_file.h | 67 + engines/wintermute/base/file/base_file_entry.cpp | 50 + engines/wintermute/base/file/base_file_entry.h | 57 + engines/wintermute/base/file/base_package.cpp | 104 + engines/wintermute/base/file/base_package.h | 61 + engines/wintermute/base/file/base_resources.cpp | 2820 ++++++++++++ engines/wintermute/base/file/base_resources.h | 44 + .../wintermute/base/file/base_save_thumb_file.cpp | 146 + .../wintermute/base/file/base_save_thumb_file.h | 52 + engines/wintermute/base/font/BFont.cpp | 206 - engines/wintermute/base/font/BFont.h | 61 - engines/wintermute/base/font/BFontBitmap.cpp | 540 --- engines/wintermute/base/font/BFontBitmap.h | 72 - engines/wintermute/base/font/BFontStorage.cpp | 135 - engines/wintermute/base/font/BFontStorage.h | 55 - engines/wintermute/base/font/BFontTT.cpp | 762 ---- engines/wintermute/base/font/BFontTT.h | 180 - engines/wintermute/base/font/base_font.cpp | 206 + engines/wintermute/base/font/base_font.h | 61 + engines/wintermute/base/font/base_font_bitmap.cpp | 540 +++ engines/wintermute/base/font/base_font_bitmap.h | 72 + engines/wintermute/base/font/base_font_storage.cpp | 135 + engines/wintermute/base/font/base_font_storage.h | 55 + .../wintermute/base/font/base_font_truetype.cpp | 762 ++++ engines/wintermute/base/font/base_font_truetype.h | 180 + engines/wintermute/base/gfx/base_image.cpp | 8 +- engines/wintermute/base/gfx/base_image.h | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 6 +- engines/wintermute/base/gfx/base_renderer.h | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/gfx/base_surface.h | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 12 +- .../base/gfx/osystem/base_surface_osystem.cpp | 8 +- engines/wintermute/base/particles/PartEmitter.cpp | 1199 ------ engines/wintermute/base/particles/PartEmitter.h | 139 - engines/wintermute/base/particles/PartForce.cpp | 59 - engines/wintermute/base/particles/PartForce.h | 57 - engines/wintermute/base/particles/PartParticle.cpp | 257 -- engines/wintermute/base/particles/PartParticle.h | 90 - engines/wintermute/base/particles/part_emitter.cpp | 1199 ++++++ engines/wintermute/base/particles/part_emitter.h | 139 + engines/wintermute/base/particles/part_force.cpp | 59 + engines/wintermute/base/particles/part_force.h | 57 + .../wintermute/base/particles/part_particle.cpp | 257 ++ engines/wintermute/base/particles/part_particle.h | 90 + engines/wintermute/base/scriptables/SXArray.cpp | 238 -- engines/wintermute/base/scriptables/SXArray.h | 54 - engines/wintermute/base/scriptables/SXDate.cpp | 297 -- engines/wintermute/base/scriptables/SXDate.h | 55 - engines/wintermute/base/scriptables/SXFile.cpp | 779 ---- engines/wintermute/base/scriptables/SXFile.h | 66 - engines/wintermute/base/scriptables/SXMath.cpp | 295 -- engines/wintermute/base/scriptables/SXMath.h | 53 - .../wintermute/base/scriptables/SXMemBuffer.cpp | 508 --- engines/wintermute/base/scriptables/SXMemBuffer.h | 59 - engines/wintermute/base/scriptables/SXString.cpp | 404 -- engines/wintermute/base/scriptables/SXString.h | 58 - engines/wintermute/base/scriptables/ScEngine.cpp | 712 ---- engines/wintermute/base/scriptables/ScEngine.h | 147 - engines/wintermute/base/scriptables/ScScript.cpp | 1461 ------- engines/wintermute/base/scriptables/ScScript.h | 183 - engines/wintermute/base/scriptables/ScStack.cpp | 226 - engines/wintermute/base/scriptables/ScStack.h | 66 - engines/wintermute/base/scriptables/ScValue.cpp | 1054 ----- engines/wintermute/base/scriptables/ScValue.h | 141 - engines/wintermute/base/scriptables/SxObject.cpp | 67 - engines/wintermute/base/scriptables/SxObject.h | 47 - engines/wintermute/base/scriptables/script.cpp | 1461 +++++++ engines/wintermute/base/scriptables/script.h | 183 + .../wintermute/base/scriptables/script_engine.cpp | 712 ++++ .../wintermute/base/scriptables/script_engine.h | 147 + .../base/scriptables/script_ext_array.cpp | 238 ++ .../wintermute/base/scriptables/script_ext_array.h | 54 + .../base/scriptables/script_ext_date.cpp | 297 ++ .../wintermute/base/scriptables/script_ext_date.h | 55 + .../base/scriptables/script_ext_file.cpp | 779 ++++ .../wintermute/base/scriptables/script_ext_file.h | 66 + .../base/scriptables/script_ext_math.cpp | 295 ++ .../wintermute/base/scriptables/script_ext_math.h | 53 + .../base/scriptables/script_ext_mem_buffer.cpp | 508 +++ .../base/scriptables/script_ext_mem_buffer.h | 59 + .../base/scriptables/script_ext_object.cpp | 67 + .../base/scriptables/script_ext_object.h | 47 + .../base/scriptables/script_ext_string.cpp | 404 ++ .../base/scriptables/script_ext_string.h | 58 + .../wintermute/base/scriptables/script_stack.cpp | 226 + engines/wintermute/base/scriptables/script_stack.h | 66 + .../wintermute/base/scriptables/script_value.cpp | 1054 +++++ engines/wintermute/base/scriptables/script_value.h | 141 + engines/wintermute/base/sound/base_sound.cpp | 288 ++ engines/wintermute/base/sound/base_sound.h | 88 + .../wintermute/base/sound/base_sound_buffer.cpp | 383 ++ engines/wintermute/base/sound/base_sound_buffer.h | 100 + .../wintermute/base/sound/base_sound_manager.cpp | 292 ++ engines/wintermute/base/sound/base_sound_manager.h | 69 + 222 files changed, 30998 insertions(+), 30996 deletions(-) delete mode 100644 engines/wintermute/base/BActiveRect.cpp delete mode 100644 engines/wintermute/base/BActiveRect.h delete mode 100644 engines/wintermute/base/BBase.cpp delete mode 100644 engines/wintermute/base/BBase.h delete mode 100644 engines/wintermute/base/BDebugger.cpp delete mode 100644 engines/wintermute/base/BDebugger.h delete mode 100644 engines/wintermute/base/BDynBuffer.cpp delete mode 100644 engines/wintermute/base/BDynBuffer.h delete mode 100644 engines/wintermute/base/BFader.cpp delete mode 100644 engines/wintermute/base/BFader.h delete mode 100644 engines/wintermute/base/BFileManager.cpp delete mode 100644 engines/wintermute/base/BFileManager.h delete mode 100644 engines/wintermute/base/BFrame.cpp delete mode 100644 engines/wintermute/base/BFrame.h delete mode 100644 engines/wintermute/base/BGame.cpp delete mode 100644 engines/wintermute/base/BGame.h delete mode 100644 engines/wintermute/base/BKeyboardState.cpp delete mode 100644 engines/wintermute/base/BKeyboardState.h delete mode 100644 engines/wintermute/base/BNamedObject.cpp delete mode 100644 engines/wintermute/base/BNamedObject.h delete mode 100644 engines/wintermute/base/BObject.cpp delete mode 100644 engines/wintermute/base/BObject.h delete mode 100644 engines/wintermute/base/BParser.cpp delete mode 100644 engines/wintermute/base/BParser.h delete mode 100644 engines/wintermute/base/BPersistMgr.cpp delete mode 100644 engines/wintermute/base/BPersistMgr.h delete mode 100644 engines/wintermute/base/BPoint.cpp delete mode 100644 engines/wintermute/base/BPoint.h delete mode 100644 engines/wintermute/base/BQuickMsg.cpp delete mode 100644 engines/wintermute/base/BQuickMsg.h delete mode 100644 engines/wintermute/base/BRegion.cpp delete mode 100644 engines/wintermute/base/BRegion.h delete mode 100644 engines/wintermute/base/BRegistry.cpp delete mode 100644 engines/wintermute/base/BRegistry.h delete mode 100644 engines/wintermute/base/BResources.cpp delete mode 100644 engines/wintermute/base/BResources.h delete mode 100644 engines/wintermute/base/BSaveThumbHelper.cpp delete mode 100644 engines/wintermute/base/BSaveThumbHelper.h delete mode 100644 engines/wintermute/base/BScriptHolder.cpp delete mode 100644 engines/wintermute/base/BScriptHolder.h delete mode 100644 engines/wintermute/base/BScriptable.cpp delete mode 100644 engines/wintermute/base/BScriptable.h delete mode 100644 engines/wintermute/base/BSound.cpp delete mode 100644 engines/wintermute/base/BSound.h delete mode 100644 engines/wintermute/base/BSoundBuffer.cpp delete mode 100644 engines/wintermute/base/BSoundBuffer.h delete mode 100644 engines/wintermute/base/BSoundMgr.cpp delete mode 100644 engines/wintermute/base/BSoundMgr.h delete mode 100644 engines/wintermute/base/BSprite.cpp delete mode 100644 engines/wintermute/base/BSprite.h delete mode 100644 engines/wintermute/base/BStringTable.cpp delete mode 100644 engines/wintermute/base/BStringTable.h delete mode 100644 engines/wintermute/base/BSubFrame.cpp delete mode 100644 engines/wintermute/base/BSubFrame.h delete mode 100644 engines/wintermute/base/BSurfaceStorage.cpp delete mode 100644 engines/wintermute/base/BSurfaceStorage.h delete mode 100644 engines/wintermute/base/BTransitionMgr.cpp delete mode 100644 engines/wintermute/base/BTransitionMgr.h delete mode 100644 engines/wintermute/base/BViewport.cpp delete mode 100644 engines/wintermute/base/BViewport.h create mode 100644 engines/wintermute/base/base.cpp create mode 100644 engines/wintermute/base/base.h create mode 100644 engines/wintermute/base/base_active_rect.cpp create mode 100644 engines/wintermute/base/base_active_rect.h create mode 100644 engines/wintermute/base/base_debugger.cpp create mode 100644 engines/wintermute/base/base_debugger.h create mode 100644 engines/wintermute/base/base_dynamic_buffer.cpp create mode 100644 engines/wintermute/base/base_dynamic_buffer.h create mode 100644 engines/wintermute/base/base_fader.cpp create mode 100644 engines/wintermute/base/base_fader.h create mode 100644 engines/wintermute/base/base_file_manager.cpp create mode 100644 engines/wintermute/base/base_file_manager.h create mode 100644 engines/wintermute/base/base_frame.cpp create mode 100644 engines/wintermute/base/base_frame.h create mode 100644 engines/wintermute/base/base_game.cpp create mode 100644 engines/wintermute/base/base_game.h create mode 100644 engines/wintermute/base/base_keyboard_state.cpp create mode 100644 engines/wintermute/base/base_keyboard_state.h create mode 100644 engines/wintermute/base/base_named_object.cpp create mode 100644 engines/wintermute/base/base_named_object.h create mode 100644 engines/wintermute/base/base_object.cpp create mode 100644 engines/wintermute/base/base_object.h create mode 100644 engines/wintermute/base/base_parser.cpp create mode 100644 engines/wintermute/base/base_parser.h create mode 100644 engines/wintermute/base/base_persistence_manager.cpp create mode 100644 engines/wintermute/base/base_persistence_manager.h create mode 100644 engines/wintermute/base/base_point.cpp create mode 100644 engines/wintermute/base/base_point.h create mode 100644 engines/wintermute/base/base_quick_msg.cpp create mode 100644 engines/wintermute/base/base_quick_msg.h create mode 100644 engines/wintermute/base/base_region.cpp create mode 100644 engines/wintermute/base/base_region.h create mode 100644 engines/wintermute/base/base_registry.cpp create mode 100644 engines/wintermute/base/base_registry.h create mode 100644 engines/wintermute/base/base_save_thumb_helper.cpp create mode 100644 engines/wintermute/base/base_save_thumb_helper.h create mode 100644 engines/wintermute/base/base_script_holder.cpp create mode 100644 engines/wintermute/base/base_script_holder.h create mode 100644 engines/wintermute/base/base_scriptable.cpp create mode 100644 engines/wintermute/base/base_scriptable.h create mode 100644 engines/wintermute/base/base_sprite.cpp create mode 100644 engines/wintermute/base/base_sprite.h create mode 100644 engines/wintermute/base/base_string_table.cpp create mode 100644 engines/wintermute/base/base_string_table.h create mode 100644 engines/wintermute/base/base_sub_frame.cpp create mode 100644 engines/wintermute/base/base_sub_frame.h create mode 100644 engines/wintermute/base/base_surface_storage.cpp create mode 100644 engines/wintermute/base/base_surface_storage.h create mode 100644 engines/wintermute/base/base_transition_manager.cpp create mode 100644 engines/wintermute/base/base_transition_manager.h create mode 100644 engines/wintermute/base/base_viewport.cpp create mode 100644 engines/wintermute/base/base_viewport.h delete mode 100644 engines/wintermute/base/file/BDiskFile.cpp delete mode 100644 engines/wintermute/base/file/BDiskFile.h delete mode 100644 engines/wintermute/base/file/BFile.cpp delete mode 100644 engines/wintermute/base/file/BFile.h delete mode 100644 engines/wintermute/base/file/BFileEntry.cpp delete mode 100644 engines/wintermute/base/file/BFileEntry.h delete mode 100644 engines/wintermute/base/file/BPackage.cpp delete mode 100644 engines/wintermute/base/file/BPackage.h delete mode 100644 engines/wintermute/base/file/BSaveThumbFile.cpp delete mode 100644 engines/wintermute/base/file/BSaveThumbFile.h create mode 100644 engines/wintermute/base/file/base_disk_file.cpp create mode 100644 engines/wintermute/base/file/base_disk_file.h create mode 100644 engines/wintermute/base/file/base_file.cpp create mode 100644 engines/wintermute/base/file/base_file.h create mode 100644 engines/wintermute/base/file/base_file_entry.cpp create mode 100644 engines/wintermute/base/file/base_file_entry.h create mode 100644 engines/wintermute/base/file/base_package.cpp create mode 100644 engines/wintermute/base/file/base_package.h create mode 100644 engines/wintermute/base/file/base_resources.cpp create mode 100644 engines/wintermute/base/file/base_resources.h create mode 100644 engines/wintermute/base/file/base_save_thumb_file.cpp create mode 100644 engines/wintermute/base/file/base_save_thumb_file.h delete mode 100644 engines/wintermute/base/font/BFont.cpp delete mode 100644 engines/wintermute/base/font/BFont.h delete mode 100644 engines/wintermute/base/font/BFontBitmap.cpp delete mode 100644 engines/wintermute/base/font/BFontBitmap.h delete mode 100644 engines/wintermute/base/font/BFontStorage.cpp delete mode 100644 engines/wintermute/base/font/BFontStorage.h delete mode 100644 engines/wintermute/base/font/BFontTT.cpp delete mode 100644 engines/wintermute/base/font/BFontTT.h create mode 100644 engines/wintermute/base/font/base_font.cpp create mode 100644 engines/wintermute/base/font/base_font.h create mode 100644 engines/wintermute/base/font/base_font_bitmap.cpp create mode 100644 engines/wintermute/base/font/base_font_bitmap.h create mode 100644 engines/wintermute/base/font/base_font_storage.cpp create mode 100644 engines/wintermute/base/font/base_font_storage.h create mode 100644 engines/wintermute/base/font/base_font_truetype.cpp create mode 100644 engines/wintermute/base/font/base_font_truetype.h delete mode 100644 engines/wintermute/base/particles/PartEmitter.cpp delete mode 100644 engines/wintermute/base/particles/PartEmitter.h delete mode 100644 engines/wintermute/base/particles/PartForce.cpp delete mode 100644 engines/wintermute/base/particles/PartForce.h delete mode 100644 engines/wintermute/base/particles/PartParticle.cpp delete mode 100644 engines/wintermute/base/particles/PartParticle.h create mode 100644 engines/wintermute/base/particles/part_emitter.cpp create mode 100644 engines/wintermute/base/particles/part_emitter.h create mode 100644 engines/wintermute/base/particles/part_force.cpp create mode 100644 engines/wintermute/base/particles/part_force.h create mode 100644 engines/wintermute/base/particles/part_particle.cpp create mode 100644 engines/wintermute/base/particles/part_particle.h delete mode 100644 engines/wintermute/base/scriptables/SXArray.cpp delete mode 100644 engines/wintermute/base/scriptables/SXArray.h delete mode 100644 engines/wintermute/base/scriptables/SXDate.cpp delete mode 100644 engines/wintermute/base/scriptables/SXDate.h delete mode 100644 engines/wintermute/base/scriptables/SXFile.cpp delete mode 100644 engines/wintermute/base/scriptables/SXFile.h delete mode 100644 engines/wintermute/base/scriptables/SXMath.cpp delete mode 100644 engines/wintermute/base/scriptables/SXMath.h delete mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.cpp delete mode 100644 engines/wintermute/base/scriptables/SXMemBuffer.h delete mode 100644 engines/wintermute/base/scriptables/SXString.cpp delete mode 100644 engines/wintermute/base/scriptables/SXString.h delete mode 100644 engines/wintermute/base/scriptables/ScEngine.cpp delete mode 100644 engines/wintermute/base/scriptables/ScEngine.h delete mode 100644 engines/wintermute/base/scriptables/ScScript.cpp delete mode 100644 engines/wintermute/base/scriptables/ScScript.h delete mode 100644 engines/wintermute/base/scriptables/ScStack.cpp delete mode 100644 engines/wintermute/base/scriptables/ScStack.h delete mode 100644 engines/wintermute/base/scriptables/ScValue.cpp delete mode 100644 engines/wintermute/base/scriptables/ScValue.h delete mode 100644 engines/wintermute/base/scriptables/SxObject.cpp delete mode 100644 engines/wintermute/base/scriptables/SxObject.h create mode 100644 engines/wintermute/base/scriptables/script.cpp create mode 100644 engines/wintermute/base/scriptables/script.h create mode 100644 engines/wintermute/base/scriptables/script_engine.cpp create mode 100644 engines/wintermute/base/scriptables/script_engine.h create mode 100644 engines/wintermute/base/scriptables/script_ext_array.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_array.h create mode 100644 engines/wintermute/base/scriptables/script_ext_date.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_date.h create mode 100644 engines/wintermute/base/scriptables/script_ext_file.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_file.h create mode 100644 engines/wintermute/base/scriptables/script_ext_math.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_math.h create mode 100644 engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_mem_buffer.h create mode 100644 engines/wintermute/base/scriptables/script_ext_object.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_object.h create mode 100644 engines/wintermute/base/scriptables/script_ext_string.cpp create mode 100644 engines/wintermute/base/scriptables/script_ext_string.h create mode 100644 engines/wintermute/base/scriptables/script_stack.cpp create mode 100644 engines/wintermute/base/scriptables/script_stack.h create mode 100644 engines/wintermute/base/scriptables/script_value.cpp create mode 100644 engines/wintermute/base/scriptables/script_value.h create mode 100644 engines/wintermute/base/sound/base_sound.cpp create mode 100644 engines/wintermute/base/sound/base_sound.h create mode 100644 engines/wintermute/base/sound/base_sound_buffer.cpp create mode 100644 engines/wintermute/base/sound/base_sound_buffer.h create mode 100644 engines/wintermute/base/sound/base_sound_manager.cpp create mode 100644 engines/wintermute/base/sound/base_sound_manager.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/BActiveRect.cpp b/engines/wintermute/base/BActiveRect.cpp deleted file mode 100644 index 836a93ad9a..0000000000 --- a/engines/wintermute/base/BActiveRect.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - clipRect(); -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { - _owner = owner; - _frame = frame; - CBPlatform::setRect(&_rect, x, y, x + width, y + height); - _zoomX = zoomX; - _zoomY = zoomY; - _precise = precise; - _region = NULL; - _offsetX = _offsetY = 0; - clipRect(); -} - -////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { - _owner = owner; - _region = region; - CBPlatform::copyRect(&_rect, ®ion->_rect); - CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - clipRect(); - _offsetX = offsetX; - _offsetY = offsetY; -} - - -////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBActiveRect::clipRect() { - Rect32 rc; - bool customViewport; - _gameRef->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = _gameRef->_renderer; - - if (!customViewport) { - rc.left -= Rend->_drawOffsetX; - rc.right -= Rend->_drawOffsetX; - rc.top -= Rend->_drawOffsetY; - rc.bottom -= Rend->_drawOffsetY; - } - - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - - CBPlatform::intersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BActiveRect.h b/engines/wintermute/base/BActiveRect.h deleted file mode 100644 index 935b91eaeb..0000000000 --- a/engines/wintermute/base/BActiveRect.h +++ /dev/null @@ -1,60 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H - -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { -public: - void clipRect(); - bool _precise; - float _zoomX; - float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; - int _offsetX; - int _offsetY; - Rect32 _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); - virtual ~CBActiveRect(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BBase.cpp b/engines/wintermute/base/BBase.cpp deleted file mode 100644 index 76e1150925..0000000000 --- a/engines/wintermute/base/BBase.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *gameOwner) { - _gameRef = gameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { - _gameRef = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *propName, const char *initVal) { - _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) - return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return initVal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return STATUS_FAILED; - - if (propValue == NULL) { - _editorProps.erase(propName); - } else { - _editorProps[propName] = propValue; - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBBase::parseEditorProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - - if (!_gameRef->_editorMode) - return STATUS_OK; - - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - - - setEditorProp(propName, propValue); - - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { - _editorPropsIter = _editorProps.begin(); - while (_editorPropsIter != _editorProps.end()) { - buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); - buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove - buffer->putTextIndent(indent, "}\n\n"); - - _editorPropsIter++; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BBase.h b/engines/wintermute/base/BBase.h deleted file mode 100644 index e8c87f1f9e..0000000000 --- a/engines/wintermute/base/BBase.h +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace WinterMute { - -class CBGame; -class CBDynBuffer; - -class CBBase { -public: - bool _persistable; - bool setEditorProp(const char *propName, const char *propValue); - const char *getEditorProp(const char *propName, const char *initVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; - bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBBase(); - CBGame *_gameRef; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); - - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BDebugger.cpp b/engines/wintermute/base/BDebugger.cpp deleted file mode 100644 index 92f282b6d1..0000000000 --- a/engines/wintermute/base/BDebugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BDebugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::initialize() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::shutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameInit() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameShutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameTick() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onLog(unsigned int errorCode, const char *text) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptInit(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool CBDebugger::attachClient(IWmeDebugClient *client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::detachClient(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::queryData(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int CBDebugger::getPropInt(const char *propName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double CBDebugger::getPropFloat(const char *propName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::getPropString(const char *propName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::getPropBool(const char *propName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, int propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, double propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, const char *propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, bool propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBDebugger::continueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDebugger.h b/engines/wintermute/base/BDebugger.h deleted file mode 100644 index cea432f7a8..0000000000 --- a/engines/wintermute/base/BDebugger.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/wme_debugger.h" - -// TODO: The entire debugger should possibly be removed - -namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { -public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); - - // initialization - bool _enabled; - bool initialize(); - bool shutdown(); - - // internal interface - bool onGameInit(); - bool onGameShutdown(); - bool onGameTick(); - bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(CScScript *script); - bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - bool onScriptShutdown(CScScript *script); - bool onScriptChangeLine(CScScript *script, int line); - bool onScriptChangeScope(CScScript *script, CScValue *scope); - bool onScriptShutdownScope(CScScript *script, CScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - bool onVariableChangeValue(CScValue *var, CScValue *value); - - bool onScriptHitBreakpoint(CScScript *script); - - // IWmeDebugServer interface - virtual bool attachClient(IWmeDebugClient *client); - virtual bool detachClient(IWmeDebugClient *client); - virtual bool queryData(IWmeDebugClient *client); - - virtual int getPropInt(const char *propName); - virtual double getPropFloat(const char *propName); - virtual const char *getPropString(const char *propName); - virtual bool getPropBool(const char *propName); - - virtual bool setProp(const char *propName, int propValue); - virtual bool setProp(const char *propName, double propValue); - virtual bool setProp(const char *propName, const char *propValue); - virtual bool setProp(const char *propName, bool propValue); - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - - virtual bool addBreakpoint(const char *scriptFilename, int line); - virtual bool removeBreakpoint(const char *scriptFilename, int line); - - virtual bool continueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BDynBuffer.cpp b/engines/wintermute/base/BDynBuffer.cpp deleted file mode 100644 index 9a2e071287..0000000000 --- a/engines/wintermute/base/BDynBuffer.cpp +++ /dev/null @@ -1,192 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BDynBuffer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = initSize; - _growBy = growBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::cleanup() { - if (_buffer) free(_buffer); - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::init(uint32 initSize) { - cleanup(); - - if (initSize == 0) initSize = _initSize; - - _buffer = (byte *)malloc(initSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); - return STATUS_FAILED; - } - - _realSize = initSize; - _initialized = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - while (_offset + size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return STATUS_FAILED; - } - } - - memcpy(_buffer + _offset, buffer, size); - _offset += size; - _size += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); - - if (_offset + size > _size) { - _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); - return STATUS_FAILED; - } - - memcpy(buffer, _buffer + _offset, size); - _offset += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putDWORD(uint32 val) { - putBytes((byte *)&val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getDWORD() { - uint32 ret; - getBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putString(const char *val) { - if (!val) putString("(null)"); - else { - putDWORD(strlen(val) + 1); - putBytes((byte *)val, strlen(val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::getString() { - uint32 len = getDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) return NULL; - else return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(const char *fmt, ...) { - va_list va; - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { - va_list va; - - putText("%*s", indent, ""); - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - putBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BDynBuffer.h b/engines/wintermute/base/BDynBuffer.h deleted file mode 100644 index 66e8182c68..0000000000 --- a/engines/wintermute/base/BDynBuffer.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBDynBuffer : public CBBase { -public: - bool _initialized; - void putText(const char *fmt, ...); - void putTextIndent(int indent, const char *fmt, ...); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - void putString(const char *val); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 getSize(); - bool init(uint32 initSize = 0); - void cleanup(); - uint32 _size; - byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~CBDynBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void putTextForm(const char *format, va_list argptr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFader.cpp b/engines/wintermute/base/BFader.cpp deleted file mode 100644 index 9dec5e1e12..0000000000 --- a/engines/wintermute/base/BFader.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFader.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/util.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFader, false) - -////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::update() { - if (!_active) return STATUS_OK; - - int alphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) time = CBPlatform::getTime() - _startTime; - else time = _gameRef->_timer - _startTime; - - if (time >= _duration) _currentAlpha = _targetAlpha; - else { - _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); - } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean - - _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::display() { - if (!_active) return STATUS_OK; - - if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::deactivate() { - _active = false; - _ready = true; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(sourceColor); - _green = RGBCOLGetG(sourceColor); - _blue = RGBCOLGetB(sourceColor); - - _sourceAlpha = RGBCOLGetA(sourceColor); - _targetAlpha = 0; - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(targetColor); - _green = RGBCOLGetG(targetColor); - _blue = RGBCOLGetB(targetColor); - - //_sourceAlpha = 0; - _sourceAlpha = _currentAlpha; - _targetAlpha = RGBCOLGetA(targetColor); - - _duration = duration; - _system = system; - - if (_system) _startTime = CBPlatform::getTime(); - else _startTime = _gameRef->_timer; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBFader::getCurrentColor() { - return BYTETORGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFader::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blue)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_green)); - persistMgr->transfer(TMEMBER(_red)); - persistMgr->transfer(TMEMBER(_sourceAlpha)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_targetAlpha)); - persistMgr->transfer(TMEMBER(_system)); - - if (_system && !persistMgr->_saving) _startTime = 0; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFader.h b/engines/wintermute/base/BFader.h deleted file mode 100644 index cc90d4603d..0000000000 --- a/engines/wintermute/base/BFader.h +++ /dev/null @@ -1,62 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CBFader : public CBObject { -public: - bool _system; - uint32 getCurrentColor(); - bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); - bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - bool deactivate(); - bool display(); - bool update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFileManager.cpp b/engines/wintermute/base/BFileManager.cpp deleted file mode 100644 index 34638f55e8..0000000000 --- a/engines/wintermute/base/BFileManager.cpp +++ /dev/null @@ -1,737 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/base/file/BDiskFile.h" -#include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/base/file/BFileEntry.h" -#include "engines/wintermute/base/file/BPackage.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/BResources.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/dcpackage.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "common/str.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/config-manager.h" -#include "common/system.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/savefile.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { - _basePath = NULL; - - initPaths(); - registerPackages(); -} - - -////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::cleanup() { - // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - - // close open files - for (uint32 i = 0; i < _openFiles.size(); i++) { - delete _openFiles[i]; - } - _openFiles.clear(); - - - // delete packages - for (uint32 i = 0; i < _packages.size(); i++) - delete _packages[i]; - _packages.clear(); - - delete[] _basePath; - _basePath = NULL; - - return STATUS_OK; -} - - - -#define MAX_FILE_SIZE 10000000 -////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; - - Common::SeekableReadStream *file = openFile(filename); - if (!file) { - if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); - return NULL; - } - - /* - if (File->GetSize() > MAX_FILE_SIZE) { - _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - - buffer = new byte[file->size() + 1]; - if (buffer == NULL) { - _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); - closeFile(file); - return NULL; - } - - if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); - closeFile(file); - delete [] buffer; - return NULL; - }; - - buffer[file->size()] = '\0'; - if (size != NULL) *size = file->size(); - closeFile(file); - - return buffer; -} - -Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::InSaveFile *file = saveMan->openForLoading(filename); - return file; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { - // TODO - warning("Implement SaveFile"); - - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - file->finalize(); - delete file; -#if 0 - RestoreCurrentDir(); - - CBUtils::CreatePath(filename, false); - - FILE *f = fopen(filename, "wb"); - if (!f) { - _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); - return STATUS_FAILED; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { - // unmount all non-local packages - for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->close(); - } - - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; - - bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - - char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return STATUS_FAILED; - - strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); - - switch (type) { - case PATH_SINGLE: - _singlePaths.push_back(buffer); - break; - case PATH_PACKAGE: - _packagePaths.push_back(buffer); - break; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::reloadPaths() { - // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; - _packagePaths.clear(); - - return initPaths(); -} - - -#define TEMP_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::initPaths() { - restoreCurrentDir(); - - AnsiString pathList; - int numPaths; - - // single files paths - pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_SINGLE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_SINGLE, ".\\"); - - - // package files paths - addPath(PATH_PACKAGE, "./"); - - pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - addPath(PATH_PACKAGE, path); - } - delete[] path; - path = NULL; - } - addPath(PATH_PACKAGE, "data"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackages() { - restoreCurrentDir(); - - _gameRef->LOG(0, "Scanning packages..."); - debugC(kWinterMuteDebugFileAccess, "Scanning packages"); - - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, "*.dcp"); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - registerPackage((*it)->getName().c_str()); - } -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.getSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } -#endif - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { -// FILE *f = fopen(filename, "rb"); - Common::File *package = new Common::File(); - package->open(filename); - if (!package->isOpen()) { - _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return STATUS_OK; - } - - uint32 absoluteOffset = 0; - bool boundToExe = false; - - if (searchSignature) { - uint32 offset; - if (!findPackageSignature(package, &offset)) { - delete package; - return STATUS_OK; - } else { - package->seek(offset, SEEK_SET); - absoluteOffset = offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { - _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete package; - return STATUS_OK; - } - - if (hdr.PackageVersion != PACKAGE_VERSION) { - _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); - } - - // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = package->readUint32LE(); - dirOffset += absoluteOffset; - package->seek(dirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(_gameRef); - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = package->readByte(); - pkg->_name = new char[nameLength]; - package->read(pkg->_name, nameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; - - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk - _packages.push_back(pkg); - - - // read file entries - uint32 NumFiles = package->readUint32LE(); - - for (uint32 j = 0; j < NumFiles; j++) { - char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; - - nameLength = package->readByte(); - name = new char[nameLength]; - package->read(name, nameLength); - - // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - - CBPlatform::strupr(name); - - offset = package->readUint32LE(); - offset += absoluteOffset; - length = package->readUint32LE(); - compLength = package->readUint32LE(); - flags = package->readUint32LE(); - - if (hdr.PackageVersion == PACKAGE_VERSION) { - timeDate1 = package->readUint32LE(); - timeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(name); - if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(_gameRef); - file->_package = pkg; - file->_offset = offset; - file->_length = length; - file->_compressedLength = compLength; - file->_flags = flags; - - _files[name] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = offset; - _filesIter->_value->_length = length; - _filesIter->_value->_compressedLength = compLength; - _filesIter->_value->_flags = flags; - } - } - delete [] name; - } - } - - - delete package; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - - Common::File *ret = new Common::File(); - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _packagePaths.size(); i++) { - sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - } - - sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &name) { - restoreCurrentDir(); - - Common::File *ret = NULL; - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { - restoreCurrentDir(); - - Common::File f; - bool found = false; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(filename.c_str()); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(fullname, filename.c_str()); - } - } - - return found; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { - char *upc_name = new char[strlen(filename.c_str()) + 1]; - strcpy(upc_name, filename.c_str()); - CBPlatform::strupr(upc_name); - - CBFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - delete [] upc_name; - - return ret; -} - -bool CBFileManager::hasFile(const Common::String &filename) { - //TODO: Do this in a much simpler fashion - Common::SeekableReadStream *stream = openFile(filename, true, false); - if (!stream) { - return false; - } - delete stream; - return true; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) return NULL; - //_gameRef->LOG(0, "open file: %s", filename); - /*#ifdef __WIN32__ - if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); - } - } - #endif*/ - - Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.push_back(file); - return file; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::closeFile(Common::SeekableReadStream *File) { - for (uint32 i = 0; i < _openFiles.size(); i++) { - if (_openFiles[i] == File) { - delete _openFiles[i]; - _openFiles.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { - restoreCurrentDir(); - - Common::SeekableReadStream *ret = NULL; - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); - } - delete SaveThumbFile; - return ret; - } - - - - ret = openDiskFile(filename, this); - if (ret) return ret; - - ret = openPkgFile(filename, this); - if (ret) return ret; - - ret = CBResources::getFile(filename); - if (ret) return ret; - - warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::restoreCurrentDir() { - if (!_basePath) return STATUS_OK; - else { - /*if (!chdir(_basePath)) return STATUS_OK; - else return STATUS_FAILED;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::setBasePath(const Common::String &path) { - cleanup(); - - if (path.c_str()) { - _basePath = new char[path.size() + 1]; - strcpy(_basePath, path.c_str()); - } - - initPaths(); - registerPackages(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFileManager.h b/engines/wintermute/base/BFileManager.h deleted file mode 100644 index 7ea9ff5611..0000000000 --- a/engines/wintermute/base/BFileManager.h +++ /dev/null @@ -1,85 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H - -#include "engines/wintermute/base/file/BFileEntry.h" -#include "common/archive.h" -#include "common/str.h" - -namespace Common { -class File; -} - -namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { -public: - bool findPackageSignature(Common::File *f, uint32 *offset); - bool cleanup(); - bool setBasePath(const Common::String &path); - bool restoreCurrentDir(); - char *_basePath; - bool getFullPath(const Common::String &filename, char *fullname); - Common::SeekableReadStream *openFileRaw(const Common::String &filename); - bool closeFile(Common::SeekableReadStream *File); - bool hasFile(const Common::String &filename); - Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openSingleFile(const Common::String &name); - Common::File *openPackage(const Common::String &name); - bool registerPackages(); - bool initPaths(); - bool reloadPaths(); - typedef enum { - PATH_PACKAGE, PATH_SINGLE - } TPathType; - bool addPath(TPathType type, const Common::String &path); - bool requestCD(int cd, char *packageFile, const char *filename); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); - Common::Array _singlePaths; - Common::Array _packagePaths; - Common::Array _packages; - Common::Array _openFiles; - - Common::HashMap _files; -private: - bool registerPackage(const Common::String &filename, bool searchSignature = false); - Common::HashMap::iterator _filesIter; - bool isValidPackage(const AnsiString &fileName) const; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BFrame.cpp b/engines/wintermute/base/BFrame.cpp deleted file mode 100644 index d6d8a3aa5c..0000000000 --- a/engines/wintermute/base/BFrame.cpp +++ /dev/null @@ -1,705 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/str.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFrame, false) - -////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { - delete _sound; - _sound = NULL; - - for (int i = 0; i < _subframes.getSize(); i++) - delete _subframes[i]; - _subframes.removeAll(); - - for (int i = 0; i < _applyEvent.getSize(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.removeAll(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - bool res; - - for (int i = 0; i < _subframes.getSize(); i++) { - res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) return res; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { - if (_sound && !muted) { - if (owner) owner->updateOneSound(_sound); - _sound->play(); - /* - if (_gameRef->_state == GAME_FROZEN) { - _sound->Pause(true); - } - */ - } - if (owner) { - for (int i = 0; i < _applyEvent.getSize(); i++) { - owner->applyEvent(_applyEvent[i]); - } - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(DELAY) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(MOVE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(SUBFRAME) -TOKEN_DEF(SOUND) -TOKEN_DEF(KEYFRAME) -TOKEN_DEF(DECORATION) -TOKEN_DEF(APPLY_EVENT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_EXPANDED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(KILL_SOUND) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(DELAY) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(MOVE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(SUBFRAME) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(KEYFRAME) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(APPLY_EVENT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_EXPANDED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(KILL_SOUND) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - int hotspotX = 0, hotspotY = 0; - bool custoTrans = false; - bool editorSelected = false; - bool is2DOnly = false; - bool is3DOnly = false; - bool decoration = false; - bool mirrorX = false; - bool mirrorY = false; - CBPlatform::setRectEmpty(&rect); - char *surface_file = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_DELAY: - parser.scanStr(params, "%d", &_delay); - break; - - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); - break; - - case TOKEN_MOVE: - parser.scanStr(params, "%d,%d", &_moveX, &_moveY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &is2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &is3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &mirrorY); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &editorSelected); - break; - - case TOKEN_EDITOR_EXPANDED: - parser.scanStr(params, "%b", &_editorExpanded); - break; - - case TOKEN_KILL_SOUND: - parser.scanStr(params, "%b", &_killSound); - break; - - case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(_gameRef); - if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { - delete subframe; - cmd = PARSERR_GENERIC; - } else _subframes.add(subframe); - } - break; - - case TOKEN_SOUND: { - if (_sound) { - delete _sound; - _sound = NULL; - } - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); - delete _sound; - _sound = NULL; - } - } - break; - - case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.add(Event); - } - break; - - case TOKEN_KEYFRAME: - parser.scanStr(params, "%b", &_keyframe); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &decoration); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FRAME definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading FRAME definition"); - return STATUS_FAILED; - } - - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (surface_file != NULL) { - if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); - - if (!sub->_surface) { - delete sub; - _gameRef->LOG(0, "Error loading SUBFRAME"); - return STATUS_FAILED; - } - - sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); - } - - if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); - else sub->_rect = rect; - - sub->_hotspotX = hotspotX; - sub->_hotspotY = hotspotY; - sub->_2DOnly = is2DOnly; - sub->_3DOnly = is3DOnly; - sub->_decoration = decoration; - sub->_mirrorX = mirrorX; - sub->_mirrorY = mirrorY; - - - sub->_editorSelected = editorSelected; - _subframes.insertAt(0, sub); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - CBPlatform::setRectEmpty(rect); - - Rect32 subRect; - - for (int i = 0; i < _subframes.getSize(); i++) { - _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, rect, &subRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "FRAME {\n"); - buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - - if (_moveX != 0 || _moveY != 0) - buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - - if (_sound && _sound->_soundFilename) - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); - - buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - - if (_killSound) - buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - - if (_editorExpanded) - buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - - if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); - - for (int i = 1; i < _subframes.getSize(); i++) { - _subframes[i]->saveAsText(buffer, indent + 2); - } - - for (int i = 0; i < _applyEvent.getSize(); i++) { - buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - CBBase::saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - _applyEvent.persist(persistMgr); - persistMgr->transfer(TMEMBER(_delay)); - persistMgr->transfer(TMEMBER(_editorExpanded)); - persistMgr->transfer(TMEMBER(_keyframe)); - persistMgr->transfer(TMEMBER(_killSound)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_sound)); - _subframes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSound") == 0) { - stack->correctParams(0); - - if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); - else stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSound") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - delete _sound; - _sound = NULL; - - if (!val->isNULL()) { - _sound = new CBSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { - stack->pushBool(false); - delete _sound; - _sound = NULL; - } else stack->pushBool(true); - } else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSubframe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushNative(_subframes[index], true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { - script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); - } - } else { - CBSubFrame *sub = (CBSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.getSize(); i++) { - if (_subframes[i] == sub) { - delete _subframes[i]; - _subframes.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSubframe") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - sub->setDefaultRect(); - } - _subframes.add(sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertSubframe") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - } - - if (index >= _subframes.getSize()) _subframes.add(sub); - else _subframes.insertAt(index, sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.getSize()) { - script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); - stack->pushNULL(); - } else stack->pushString(_applyEvent[index]); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - stack->pushNULL(); - return STATUS_OK; - } - } - _applyEvent.add(event); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete [] _applyEvent[i]; - _applyEvent.removeAt(i); - break; - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return CBScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("frame"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { - _scValue->setInt(_delay); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _scValue->setBool(_keyframe); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _scValue->setBool(_killSound); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _scValue->setInt(_moveX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _scValue->setInt(_moveY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumSubframes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return CBScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _keyframe = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _killSound = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _moveX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _moveY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return CBScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBFrame::scToString() { - return "[frame]"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BFrame.h b/engines/wintermute/base/BFrame.h deleted file mode 100644 index 3d487b4ebc..0000000000 --- a/engines/wintermute/base/BFrame.h +++ /dev/null @@ -1,73 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H - -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { -public: - bool _killSound; - bool _keyframe; - bool oneTimeDisplay(CBObject *owner, bool muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; - bool _editorExpanded; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(CBDynBuffer *buffer, int indent); - int _moveY; - int _moveX; - uint32 _delay; - CBArray _subframes; - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - - CBFrame(CBGame *inGame); - virtual ~CBFrame(); - - CBArray _applyEvent; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BGame.cpp b/engines/wintermute/base/BGame.cpp deleted file mode 100644 index 3e577541b7..0000000000 --- a/engines/wintermute/base/BGame.cpp +++ /dev/null @@ -1,4478 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFader.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BQuickMsg.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BSubFrame.h" - -#include "engines/wintermute/base/BTransitionMgr.h" -#include "engines/wintermute/base/BViewport.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/ui/UIWindow.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/video/VidPlayer.h" -#include "engines/wintermute/video/VidTheoraPlayer.h" -#include "engines/wintermute/wintermute.h" -#include "common/savefile.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/keyboard.h" -#include "common/system.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBGame, true) - - -////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _fileManager = NULL; - _transMgr = NULL; - _debugMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _debugLogFile = NULL; - _debugDebugMode = false; - _debugAbsolutePathWarning = true; - _debugShowFPS = false; - - _systemFont = NULL; - _videoFont = NULL; - - _videoPlayer = NULL; - _theoraPlayer = NULL; - - _mainObject = NULL; - _activeObject = NULL; - - _fader = NULL; - - _offsetX = _offsetY = 0; - _offsetPercentX = _offsetPercentY = 0.0f; - - _subtitles = true; - _videoSubtitles = true; - - _timer = 0; - _timerDelta = 0; - _timerLast = 0; - - _liveTimer = 0; - _liveTimerDelta = 0; - _liveTimerLast = 0; - - _sequence = 0; - - _mousePos.x = _mousePos.y = 0; - _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; - _capturedObject = NULL; - - // FPS counters - _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - - _cursorNoninteractive = NULL; - - _useD3D = false; - - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - _settingsResWidth = 800; - _settingsResHeight = 600; - _settingsRequireAcceleration = false; - _settingsRequireSound = false; - _settingsTLMode = 0; - _settingsAllowWindowed = true; - _settingsGameFile = NULL; - _settingsAllowAdvanced = false; - _settingsAllowAccessTab = true; - _settingsAllowAboutTab = true; - _settingsAllowDesktopRes = false; - - _editorForceScripts = false; - _editorAlwaysRegister = false; - - _focusedWindow = NULL; - - _loadInProgress = false; - - _quitting = false; - _loading = false; - _scheduledLoadSlot = -1; - - _personalizedSave = false; - _compressedSavegames = true; - - _editorMode = false; - _doNotExpandStrings = false; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - _smartCache = false; - _surfaceGCCycleTime = 10000; - - _reportTextureFormat = false; - - _viewportSP = -1; - - _subtitlesSpeed = 70; - - _forceNonStreamedSounds = false; - - _thumbnailWidth = _thumbnailHeight = 0; - - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _richSavedGames = false; - _savedGameExt = NULL; - CBUtils::setString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _localSaveDir = NULL; - CBUtils::setString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - CBPlatform::setRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _autoSaveSlot = 999; - _cursorHidden = false; - -/*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else*/ - _touchInterface = false; - _constrainedMemory = false; -//#endif - -} - - -////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - getDebugMgr()->onGameShutdown(); - - _registry->writeBool("System", "LastRun", true); - - cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _saveLoadImage; - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _videoPlayer; - delete _theoraPlayer; - delete _soundMgr; - delete _debugMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _fileManager; - delete _registry; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _saveLoadImage = NULL; - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _videoPlayer = NULL; - _theoraPlayer = NULL; - _soundMgr = NULL; - _debugMgr = NULL; - - _renderer = NULL; - _fileManager = NULL; - _registry = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - CBPlatform::outputDebugString("--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::cleanup() { - delete _loadingIcon; - _loadingIcon = NULL; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete _music[i]; - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - unregisterObject(_fader); - _fader = NULL; - - for (int i = 0; i < _regObjects.getSize(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.removeAll(); - - _windows.removeAll(); // refs only - _focusedWindow = NULL; // ref only - - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (int i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->finish(); - } - _scripts.removeAll(); - - _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; - _quickMessages.removeAll(); - - _viewportStack.removeAll(); - _viewportSP = -1; - - delete[] _name; - delete[] _filename; - _name = NULL; - _filename = NULL; - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize1() { - bool loaded = false; // Not really a loop, but a goto-replacement. - while (!loaded) { - _surfaceStorage = new CBSurfaceStorage(this); - if (_surfaceStorage == NULL) - break; - - _fontStorage = new CBFontStorage(this); - if (_fontStorage == NULL) - break; - - _fileManager = new CBFileManager(this); - if (_fileManager == NULL) - break; - - _soundMgr = new CBSoundMgr(this); - if (_soundMgr == NULL) - break; - - _debugMgr = new CBDebugger(this); - if (_debugMgr == NULL) - break; - - _mathClass = new CSXMath(this); - if (_mathClass == NULL) - break; - - _scEngine = new CScEngine(this); - if (_scEngine == NULL) - break; - - _videoPlayer = new CVidPlayer(this); - if (_videoPlayer == NULL) - break; - - _transMgr = new CBTransitionMgr(this); - if (_transMgr == NULL) - break; - - _keyboardState = new CBKeyboardState(this); - if (_keyboardState == NULL) - break; - - _fader = new CBFader(this); - if (_fader == NULL) - break; - registerObject(_fader); - - loaded = true; - } - if (loaded == true) { - return STATUS_OK; - } else { - delete _mathClass; - delete _keyboardState; - delete _transMgr; - delete _debugMgr; - delete _surfaceStorage; - delete _fontStorage; - delete _soundMgr; - delete _fileManager; - delete _scEngine; - delete _videoPlayer; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) return STATUS_FAILED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *filename) { - _debugDebugMode = true; - - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - #ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #endif*/ - int secs = g_system->getMillis() / 1000; - int hours = secs / 3600; - secs = secs % 3600; - int mins = secs / 60; - secs = secs % 60; - -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); -#endif - - LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - - AnsiString platform = CBPlatform::getPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { - if (_debugLogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_debugLogFile); - _debugLogFile = NULL; - } - _debugDebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void CBGame::LOG(bool res, const char *fmt, ...) { - uint32 secs = g_system->getMillis() / 1000; - uint32 hours = secs / 3600; - secs = secs % 3600; - uint32 mins = secs / 60; - secs = secs % 60; - - char buff[512]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - // redirect to an engine's own callback - if (_engineLogCallback) { - _engineLogCallback(buff, res, _engineLogCallbackData); - } - if (_debugMgr) _debugMgr->onLog(res, buff); - - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - - //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fflush((FILE *)_debugLogFile); - - //QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { - _engineLogCallback = callback; - _engineLogCallbackData = data; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initLoop() { - _viewportSP = -1; - - _currentTime = CBPlatform::getTime(); - - getDebugMgr()->onGameTick(); - _renderer->initLoop(); - _soundMgr->initLoop(); - updateMusicCrossfade(); - - _surfaceStorage->initLoop(); - _fontStorage->initLoop(); - - - //_activeObject = NULL; - - // count FPS - _deltaTime = _currentTime - _lastTime; - _lastTime = _currentTime; - _fpsTime += _deltaTime; - - _liveTimerDelta = _liveTimer - _liveTimerLast; - _liveTimerLast = _liveTimer; - _liveTimer += MIN((uint32)1000, _deltaTime); - - if (_state != GAME_FROZEN) { - _timerDelta = _timer - _timerLast; - _timerLast = _timer; - _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; - - _framesRendered++; - if (_fpsTime > 1000) { - _fps = _framesRendered; - _framesRendered = 0; - _fpsTime = 0; - } - //_gameRef->LOG(0, "%d", _fps); - - getMousePos(&_mousePos); - - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - updateSounds(); - - if (_fader) _fader->update(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBGame::initInput() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBGame::getSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setOffset(int offsetX, int offsetY) { - _offsetX = offsetX; - _offsetY = offsetY; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) *offsetX = _offsetX; - if (offsetY != NULL) *offsetY = _offsetY; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SYSTEM_FONT) -TOKEN_DEF(VIDEO_FONT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(ACTIVE_CURSOR) -TOKEN_DEF(NONINTERACTIVE_CURSOR) -TOKEN_DEF(STRING_TABLE) -TOKEN_DEF(RESOLUTION) -TOKEN_DEF(SETTINGS) -TOKEN_DEF(REQUIRE_3D_ACCELERATION) -TOKEN_DEF(REQUIRE_SOUND) -TOKEN_DEF(HWTL_MODE) -TOKEN_DEF(ALLOW_WINDOWED_MODE) -TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) -TOKEN_DEF(ALLOW_ABOUT_TAB) -TOKEN_DEF(ALLOW_ADVANCED) -TOKEN_DEF(ALLOW_DESKTOP_RES) -TOKEN_DEF(REGISTRY_PATH) -TOKEN_DEF(PERSONAL_SAVEGAMES) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(SUBTITLES_SPEED) -TOKEN_DEF(SUBTITLES) -TOKEN_DEF(VIDEO_SUBTITLES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(THUMBNAIL_WIDTH) -TOKEN_DEF(THUMBNAIL_HEIGHT) -TOKEN_DEF(INDICATOR_X) -TOKEN_DEF(INDICATOR_Y) -TOKEN_DEF(INDICATOR_WIDTH) -TOKEN_DEF(INDICATOR_HEIGHT) -TOKEN_DEF(INDICATOR_COLOR) -TOKEN_DEF(SAVE_IMAGE_X) -TOKEN_DEF(SAVE_IMAGE_Y) -TOKEN_DEF(SAVE_IMAGE) -TOKEN_DEF(LOAD_IMAGE_X) -TOKEN_DEF(LOAD_IMAGE_Y) -TOKEN_DEF(LOAD_IMAGE) -TOKEN_DEF(LOCAL_SAVE_DIR) -TOKEN_DEF(RICH_SAVED_GAMES) -TOKEN_DEF(SAVED_GAME_EXT) -TOKEN_DEF(GUID) -TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SYSTEM_FONT) - TOKEN_TABLE(VIDEO_FONT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(ACTIVE_CURSOR) - TOKEN_TABLE(NONINTERACTIVE_CURSOR) - TOKEN_TABLE(PERSONAL_SAVEGAMES) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(SUBTITLES_SPEED) - TOKEN_TABLE(SUBTITLES) - TOKEN_TABLE(VIDEO_SUBTITLES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(THUMBNAIL_WIDTH) - TOKEN_TABLE(THUMBNAIL_HEIGHT) - TOKEN_TABLE(INDICATOR_X) - TOKEN_TABLE(INDICATOR_Y) - TOKEN_TABLE(INDICATOR_WIDTH) - TOKEN_TABLE(INDICATOR_HEIGHT) - TOKEN_TABLE(INDICATOR_COLOR) - TOKEN_TABLE(SAVE_IMAGE_X) - TOKEN_TABLE(SAVE_IMAGE_Y) - TOKEN_TABLE(SAVE_IMAGE) - TOKEN_TABLE(LOAD_IMAGE_X) - TOKEN_TABLE(LOAD_IMAGE_Y) - TOKEN_TABLE(LOAD_IMAGE) - TOKEN_TABLE(LOCAL_SAVE_DIR) - TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { - _gameRef->LOG(0, "'GAME' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _systemFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - _videoFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ACTIVE_CURSOR: - delete _activeCursor; - _activeCursor = NULL; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { - delete _activeCursor; - _activeCursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NONINTERACTIVE_CURSOR: - delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PERSONAL_SAVEGAMES: - parser.scanStr((char *)params, "%b", &_personalizedSave); - break; - - case TOKEN_SUBTITLES: - parser.scanStr((char *)params, "%b", &_subtitles); - break; - - case TOKEN_SUBTITLES_SPEED: - parser.scanStr((char *)params, "%d", &_subtitlesSpeed); - break; - - case TOKEN_VIDEO_SUBTITLES: - parser.scanStr((char *)params, "%b", &_videoSubtitles); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_THUMBNAIL_WIDTH: - parser.scanStr((char *)params, "%d", &_thumbnailWidth); - break; - - case TOKEN_THUMBNAIL_HEIGHT: - parser.scanStr((char *)params, "%d", &_thumbnailHeight); - break; - - case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &_indicatorX); - break; - - case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &_indicatorY); - break; - - case TOKEN_INDICATOR_COLOR: { - int r, g, b, a; - parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = BYTETORGBA(r, g, b, a); - } - break; - - case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &_indicatorWidth); - break; - - case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &_indicatorHeight); - break; - - case TOKEN_SAVE_IMAGE: - CBUtils::setString(&_saveImageName, (char *)params); - break; - - case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &_saveImageX); - break; - - case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_saveImageY); - break; - - case TOKEN_LOAD_IMAGE: - CBUtils::setString(&_loadImageName, (char *)params); - break; - - case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &_loadImageX); - break; - - case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_loadImageY); - break; - - case TOKEN_LOCAL_SAVE_DIR: - CBUtils::setString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); - - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - LOG(0, stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - bool res = CBObject::scCallMethod(script, stack, thisStack, name); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // Msg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Msg") == 0) { - stack->correctParams(1); - quickMessage(stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RunScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RunScript") == 0) { - _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadStringTable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadStringTable") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - CScValue *Val = stack->pop(); - - bool ClearOld; - if (Val->isNULL()) ClearOld = true; - else ClearOld = Val->getBool(); - - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) - stack->pushBool(false); - else - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ValidObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidObject") == 0) { - stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *) obj)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - resetContent(); - stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->getNative(); - unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadWindow") == 0) { - stack->correctParams(1); - CUIWindow *win = new CUIWindow(_gameRef); - if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { - _windows.add(win); - registerObject(win); - stack->pushNative(win, true); - } else { - delete win; - win = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ExpandString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExpandString") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char *str = new char[strlen(val->getString()) + 1]; - strcpy(str, val->getString()); - _stringTable->expand(&str); - stack->pushString(str); - delete [] str; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayMusic / PlayMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); - else { - stack->correctParams(4); - channel = stack->pop()->getInt(); - } - - const char *filename = stack->pop()->getString(); - CScValue *valLooping = stack->pop(); - bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - - CScValue *valLoopStart = stack->pop(); - uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - - - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopMusic / StopMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic / PauseMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeMusic / ResumeMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusic / GetMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); - else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); - else stack->pushString(_music[channel]->_soundFilename); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicPosition / SetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - uint32 time = stack->pop()->getInt(); - - if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); - else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicPosition / GetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsMusicPlaying / IsMusicChannelPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { - int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else stack->pushBool(_music[channel]->isPlaying()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicVolume / SetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); - else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); - else stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicVolume / GetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); - else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolumePercent()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicCrossfade - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicCrossfade") == 0) { - stack->correctParams(4); - int channel1 = stack->pop()->getInt(0); - int channel2 = stack->pop()->getInt(0); - uint32 fadeLength = (uint32)stack->pop()->getInt(0); - bool swap = stack->pop()->getBool(true); - - if (_musicCrossfadeRunning) { - script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - stack->pushBool(false); - return STATUS_OK; - } - - _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = channel1; - _musicCrossfadeChannel2 = channel2; - _musicCrossfadeLength = fadeLength; - _musicCrossfadeSwap = swap; - - _musicCrossfadeRunning = true; - - stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundLength") == 0) { - stack->correctParams(1); - - int length = 0; - const char *filename = stack->pop()->getString(); - - CBSound *sound = new CBSound(_gameRef); - if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - length = sound->getLength(); - delete sound; - sound = NULL; - } - stack->pushInt(length); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMousePos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMousePos") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - x = MAX(x, 0); - x = MIN(x, _renderer->_width); - y = MAX(y, 0); - y = MIN(y, _renderer->_height); - Point32 p; - p.x = x + _renderer->_drawOffsetX; - p.y = y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LockMouseRect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LockMouseRect") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - if (right < left) CBUtils::swap(&left, &right); - if (bottom < top) CBUtils::swap(&top, &bottom); - - CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayVideo") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK; - // TODO: ADDVIDEO - */ - - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - - stack->correctParams(6); - const char *filename = stack->pop()->getString(); - warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->pop(); - int Type; - if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) - Type = (int)VID_PLAY_STRETCH; - - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK;*/ - // TODO: ADDVIDEO - - stack->correctParams(7); - const char *filename = stack->pop()->getString(); - CScValue *valType = stack->pop(); - int type; - if (valType->isNULL()) - type = (int)VID_PLAY_STRETCH; - else type = valType->getInt(); - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool freezeMusic = stack->pop()->getBool(true); - bool dropFrames = stack->pop()->getBool(true); - - CScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; - - delete _theoraPlayer; - _theoraPlayer = new CVidTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { - _theoraPlayer->_dontDropFrames = !dropFrames; - if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else stack->pushBool(false); - } else { - stack->pushBool(false); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QuitGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QuitGame") == 0) { - stack->correctParams(0); - stack->pushNULL(); - _quitting = true; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int val = stack->pop()->getInt(); - _registry->writeInt("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *val = stack->pop()->getString(); - _registry->writeString("PrivateSettings", key, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->readString("PrivateSettings", key, initVal); - stack->pushString(val.c_str()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveGame") == 0) { - stack->correctParams(3); - int slot = stack->pop()->getInt(); - const char *xdesc = stack->pop()->getString(); - bool quick = stack->pop()->getBool(false); - - char *desc = new char[strlen(xdesc) + 1]; - strcpy(desc, xdesc); - stack->pushBool(true); - if (DID_FAIL(SaveGame(slot, desc, quick))) { - stack->pop(); - stack->pushBool(false); - } - delete [] desc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadGame") == 0) { - stack->correctParams(1); - _scheduledLoadSlot = stack->pop()->getInt(); - _loading = true; - stack->pushBool(false); - script->sleep(0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSaveSlotUsed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSaveSlotUsed") == 0) { - stack->correctParams(1); - int Slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(Slot)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSaveSlotDescription - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSaveSlotDescription") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - char desc[512]; - desc[0] = '\0'; - getSaveSlotDescription(slot, desc); - stack->pushString(desc); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - emptySaveSlot(slot); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSFXVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMusicVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMasterVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSFXVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMusicVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMasterVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getMasterVolumePercent()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetActiveCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursor") == 0) { - stack->correctParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); - else stack->pushString(_activeCursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursorObject") == 0) { - stack->correctParams(0); - if (!_activeCursor) stack->pushNULL(); - else stack->pushNative(_activeCursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveActiveCursor") == 0) { - stack->correctParams(0); - delete _activeCursor; - _activeCursor = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasActiveCursor") == 0) { - stack->correctParams(0); - - if (_activeCursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FileExists - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FileExists") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - // TODO: Replace with fileExists - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) stack->pushBool(false); - else { - _fileManager->closeFile(file); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Screenshot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Screenshot") == 0) { - stack->correctParams(1); - char filename[MAX_PATH_LENGTH]; - - CScValue *Val = stack->pop(); - - warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO - int fileNum = 0; - - while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); - if (!Common::File::exists(filename)) - break; - fileNum++; - } - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenshotEx - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenshotEx") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - int sizeX = stack->pop()->getInt(_renderer->_width); - int sizeY = stack->pop()->getInt(_renderer->_height); - - bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else ret = false; - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - - CUIWindow *win = new CUIWindow(_gameRef); - _windows.add(win); - registerObject(win); - if (!val->isNULL()) win->setName(val->getString()); - stack->pushNative(win, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - CBObject *obj = (CBObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == obj) { - unregisterObject(_windows[i]); - stack->pushBool(true); - return STATUS_OK; - } - } - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenDocument - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenDocument") == 0) { - stack->correctParams(0); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_DumpClassRegistry - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { - stack->correctParams(0); - DEBUG_DumpClassRegistry(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetLoadingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetLoadingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _loadImageX = stack->pop()->getInt(); - _loadImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; - } else { - CBUtils::setString(&_loadImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSavingScreen") == 0) { - stack->correctParams(3); - CScValue *val = stack->pop(); - _saveImageX = stack->pop()->getInt(); - _saveImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; - } else { - CBUtils::setString(&_saveImageName, val->getString()); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetWaitCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveWaitCursor") == 0) { - stack->correctParams(0); - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursor") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursorObject") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive) stack->pushNULL(); - else stack->pushNative(_cursorNoninteractive, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearScriptCache - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearScriptCache") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayLoadingIcon") == 0) { - stack->correctParams(4); - - const char *filename = stack->pop()->getString(); - _loadingIconX = stack->pop()->getInt(); - _loadingIconY = stack->pop()->getInt(); - _loadingIconPersistent = stack->pop()->getBool(); - - delete _loadingIcon; - _loadingIcon = new CBSprite(this); - if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { - delete _loadingIcon; - _loadingIcon = NULL; - } else { - displayContent(false, true); - _gameRef->_renderer->flip(); - _gameRef->_renderer->initLoop(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideLoadingIcon") == 0) { - stack->correctParams(0); - delete _loadingIcon; - _loadingIcon = NULL; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DumpTextureStats - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DumpTextureStats") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _renderer->dumpData(filename); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccOutputText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccOutputText") == 0) { - stack->correctParams(2); - /* const char *Str = */ - stack->pop()->getString(); - /* int Type = */ - stack->pop()->getInt(); - // do nothing - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StoreSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StoreSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); - if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushBool(false); - } else stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFileChecksum - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFileChecksum") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool asHex = stack->pop()->getBool(false); - - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (file) { - crc remainder = crc_initialize(); - byte buf[1024]; - int bytesRead = 0; - - while (bytesRead < file->size()) { - int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); - bytesRead += file->read(buf, bufSize); - - for (int i = 0; i < bufSize; i++) { - remainder = crc_process_byte(buf[i], remainder); - } - } - crc checksum = crc_finalize(remainder); - - if (asHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - stack->pushString(Hex); - } else - stack->pushInt(checksum); - - _fileManager->closeFile(file); - file = NULL; - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EnableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EnableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->enableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->disableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ShowStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ShowStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideStatusLine") == 0) { - stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Hwnd (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { - _scValue->setInt((int)_renderer->_window); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { - _scValue->setInt((int)_timer); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowsTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::getTime()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowedMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { - _scValue->setBool(_renderer->_windowed); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _scValue->setInt(_mousePos.x); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _scValue->setInt(_mousePos.y); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - _scValue->setNative(_mainObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ActiveObject (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { - _scValue->setNative(_activeObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenWidth (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { - _scValue->setInt(_renderer->_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenHeight (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { - _scValue->setInt(_renderer->_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - _scValue->setBool(_interactive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DebugMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { - _scValue->setBool(_debugDebugMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundAvailable (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { - _scValue->setBool(_soundMgr->_soundAvailable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getMasterVolumePercent()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyboard (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->setNative(_keyboardState, true); - else _scValue->setNULL(); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _scValue->setBool(_subtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _scValue->setInt(_subtitlesSpeed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _scValue->setBool(_videoSubtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FPS (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { - _scValue->setInt(_fps); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AcceleratedMode / Accelerated (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { - _scValue->setBool(_useD3D); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - _scValue->setInt(_textEncoding); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _scValue->setBool(_textRTL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _scValue->setInt(_soundBufferSizeSec); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _scValue->setBool(_suspendedRendering); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _scValue->setBool(_suppressScriptErrors); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // Frozen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { - _scValue->setBool(_state == GAME_FROZEN); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSTalk - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSCaptions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSKeypress - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardCursorSkip - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardPause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _scValue->setBool(_autorunDisabled); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveDirectory (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = getDataDir(); - _scValue->setString(dataDir.c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _scValue->setBool(_autoSaveOnExit); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _scValue->setInt(_autoSaveSlot); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _scValue->setBool(_cursorHidden); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Platform (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::getPlatformName().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DeviceType (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { - _scValue->setString(getDeviceType().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MostRecentSaveSlot (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Store (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { - _scValue->setNULL(); - error("Request for a SXStore-object, which is not supported by ScummVM"); - - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - bool res = CBObject::scSetProperty(name, value); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->getNative(); - if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - setInteractive(value->getBool()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _subtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->getInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _textRTL = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = value->getInt(); - _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBGame::scToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; - - // update - for (int i = 0; i < _quickMessages.getSize(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.removeAt(i); - i--; - } - } - - int posY = 20; - - // display - for (int i = 0; i < _quickMessages.getSize(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); - posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); - } - return STATUS_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessage(const char *text) { - if (_quickMessages.getSize() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.removeAt(0); - } - _quickMessages.add(new CBQuickMsg(_gameRef, text)); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - quickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::registerObject(CBObject *object) { - _regObjects.add(object); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unregisterObject(CBObject *object) { - if (!object) return STATUS_OK; - - // is it a window? - for (int i = 0; i < _windows.getSize(); i++) { - if ((CBObject *)_windows[i] == object) { - _windows.removeAt(i); - - // get new focused window - if (_focusedWindow == object) _focusedWindow = NULL; - - break; - } - } - - // is it active object? - if (_activeObject == object) _activeObject = NULL; - - // is it main object? - if (_mainObject == object) _mainObject = NULL; - - // destroy object - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) { - _regObjects.removeAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); - delete object; - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::invalidateValues(void *value, void *data) { - CScValue *val = (CScValue *)value; - if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { - ((CBScriptable *)data)->_refCount++; - } - val->setNative(NULL); - val->setNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::validObject(CBObject *object) { - if (!object) return false; - if (object == this) return true; - - for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *thisObj; - - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // String - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "String") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXString(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MemBuffer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MemBuffer") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // File - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "File") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXFile(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Date - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Date") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXDate(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Array - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Array") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXArray(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Object - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Object") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXObject(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Sleep - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sleep") == 0) { - stack->correctParams(1); - - script->sleep((uint32)stack->pop()->getInt()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // WaitFor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WaitFor") == 0) { - stack->correctParams(1); - - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Random - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Random") == 0) { - stack->correctParams(2); - - int from = stack->pop()->getInt(); - int to = stack->pop()->getInt(); - - stack->pushInt(CBUtils::randomInt(from, to)); - } - - ////////////////////////////////////////////////////////////////////////// - // SetScriptTimeSlice - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetScriptTimeSlice") == 0) { - stack->correctParams(1); - - script->_timeSlice = (uint32)stack->pop()->getInt(); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeRGBA / MakeRGB / RGB - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { - stack->correctParams(4); - int r = stack->pop()->getInt(); - int g = stack->pop()->getInt(); - int b = stack->pop()->getInt(); - int a; - CScValue *val = stack->pop(); - if (val->isNULL()) a = 255; - else a = val->getInt(); - - stack->pushInt(BYTETORGBA(r, g, b, a)); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeHSL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeHSL") == 0) { - stack->correctParams(3); - int h = stack->pop()->getInt(); - int s = stack->pop()->getInt(); - int l = stack->pop()->getInt(); - - stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetRValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetR(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetGValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetG(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetBValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetB(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetAValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetA(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetHValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(H); - } - - ////////////////////////////////////////////////////////////////////////// - // GetSValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(S); - } - - ////////////////////////////////////////////////////////////////////////// - // GetLValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Debug") == 0) { - stack->correctParams(0); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); - script->sleep(0); - } - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // ToString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToString") == 0) { - stack->correctParams(1); - const char *str = stack->pop()->getString(); - char *str2 = new char[strlen(str) + 1]; - strcpy(str2, str); - stack->pushString(str2); - delete [] str2; - } - - ////////////////////////////////////////////////////////////////////////// - // ToInt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToInt") == 0) { - stack->correctParams(1); - int val = stack->pop()->getInt(); - stack->pushInt(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToFloat") == 0) { - stack->correctParams(1); - double val = stack->pop()->getFloat(); - stack->pushFloat(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - stack->pushBool(val); - } - - ////////////////////////////////////////////////////////////////////////// - // failure - else { - script->runtimeError("Call to undefined function '%s'. Ignored.", name); - stack->correctParams(0); - stack->pushNULL(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::showCursor() { - if (_cursorHidden) return STATUS_OK; - - if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); - } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; - else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); - else if (_cursor) return drawCursor(_cursor); - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - LOG(0, "Saving game '%s'...", filename); - - _gameRef->applyEvent("BeforeSave", true); - - bool ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; - - _registry->writeInt("System", "MostRecentSaveSlot", slot); - -save_finish: // TODO: Remove gotos - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - return loadGame(filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(const char *filename) { - LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->onGameShutdown(); - - bool ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - _debugAbsolutePathWarning = false; - if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - - //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; - - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - - getDebugMgr()->onGameInit(); - -load_finish: - _debugAbsolutePathWarning = true; - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::initAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); - - _scEngine->refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->createRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSubFrame(void *subframe, void *data) { - ((CBSubFrame *)subframe)->setSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSound(void *sound, void *data) { - ((CBSound *)sound)->setSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadFont(void *font, void *data) { - ((CBFont *)font)->afterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadScript(void *script, void *data) { - ((CScScript *)script)->afterLoad(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayWindows(bool inGame) { - bool res; - - // did we lose focus? focus topmost window - if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { - _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { - - res = _windows[i]->display(); - if (DID_FAIL(res)) return res; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - delete _music[channel]; - _music[channel] = NULL; - - _music[channel] = new CBSound(_gameRef); - if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - if (_musicStartTime[channel]) { - _music[channel]->setPositionTime(_musicStartTime[channel]); - _musicStartTime[channel] = 0; - } - if (loopStart) _music[channel]->setLoopStart(loopStart); - return _music[channel]->play(looping); - } else { - delete _music[channel]; - _music[channel] = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - _music[channel]->stop(); - delete _music[channel]; - _music[channel] = NULL; - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pauseMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resumeMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) return _music[channel]->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setMusicStartTime(int channel, uint32 time) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::loadSettings(const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SETTINGS) - TOKEN_TABLE(GAME) - TOKEN_TABLE(STRING_TABLE) - TOKEN_TABLE(RESOLUTION) - TOKEN_TABLE(REQUIRE_3D_ACCELERATION) - TOKEN_TABLE(REQUIRE_SOUND) - TOKEN_TABLE(HWTL_MODE) - TOKEN_TABLE(ALLOW_WINDOWED_MODE) - TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) - TOKEN_TABLE(ALLOW_ABOUT_TAB) - TOKEN_TABLE(ALLOW_ADVANCED) - TOKEN_TABLE(ALLOW_DESKTOP_RES) - TOKEN_TABLE(REGISTRY_PATH) - TOKEN_TABLE(RICH_SAVED_GAMES) - TOKEN_TABLE(SAVED_GAME_EXT) - TOKEN_TABLE(GUID) - TOKEN_TABLE_END - - - byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); - if (origBuffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret = STATUS_OK; - - byte *buffer = origBuffer; - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return STATUS_FAILED; - } - buffer = params; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - delete[] _settingsGameFile; - _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); - break; - - case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_RESOLUTION: - parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); - break; - - case TOKEN_REQUIRE_3D_ACCELERATION: - parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); - break; - - case TOKEN_REQUIRE_SOUND: - parser.scanStr((char *)params, "%b", &_settingsRequireSound); - break; - - case TOKEN_HWTL_MODE: - parser.scanStr((char *)params, "%d", &_settingsTLMode); - break; - - case TOKEN_ALLOW_WINDOWED_MODE: - parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); - break; - - case TOKEN_ALLOW_DESKTOP_RES: - parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); - break; - - case TOKEN_ALLOW_ADVANCED: - parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); - break; - - case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); - break; - - case TOKEN_ALLOW_ABOUT_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); - break; - - case TOKEN_REGISTRY_PATH: - _registry->setBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - CBUtils::setString(&_savedGameExt, (char *)params); - break; - - case TOKEN_GUID: - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); - ret = STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading game settings '%s'", filename); - ret = STATUS_FAILED; - } - - _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; - - delete [] origBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) - cleanup(); - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_activeObject)); - persistMgr->transfer(TMEMBER(_capturedObject)); - persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_doNotExpandStrings)); - persistMgr->transfer(TMEMBER(_editorMode)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_freezeLevel)); - persistMgr->transfer(TMEMBER(_focusedWindow)); - persistMgr->transfer(TMEMBER(_fontStorage)); - persistMgr->transfer(TMEMBER(_interactive)); - persistMgr->transfer(TMEMBER(_keyboardState)); - persistMgr->transfer(TMEMBER(_lastTime)); - persistMgr->transfer(TMEMBER(_mainObject)); - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - persistMgr->transfer(TMEMBER(_music[i])); - persistMgr->transfer(TMEMBER(_musicStartTime[i])); - } - - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_offsetPercentX)); - persistMgr->transfer(TMEMBER(_offsetPercentY)); - - persistMgr->transfer(TMEMBER(_origInteractive)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_personalizedSave)); - persistMgr->transfer(TMEMBER(_quitting)); - - _regObjects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scEngine)); - //persistMgr->transfer(TMEMBER(_soundMgr)); - persistMgr->transfer(TMEMBER_INT(_state)); - //persistMgr->transfer(TMEMBER(_surfaceStorage)); - persistMgr->transfer(TMEMBER(_subtitles)); - persistMgr->transfer(TMEMBER(_subtitlesSpeed)); - persistMgr->transfer(TMEMBER(_systemFont)); - persistMgr->transfer(TMEMBER(_videoFont)); - persistMgr->transfer(TMEMBER(_videoSubtitles)); - - persistMgr->transfer(TMEMBER(_timer)); - persistMgr->transfer(TMEMBER(_timerDelta)); - persistMgr->transfer(TMEMBER(_timerLast)); - - persistMgr->transfer(TMEMBER(_liveTimer)); - persistMgr->transfer(TMEMBER(_liveTimerDelta)); - persistMgr->transfer(TMEMBER(_liveTimerLast)); - - persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); - persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); - persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); - persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); - - persistMgr->transfer(TMEMBER_INT(_textEncoding)); - persistMgr->transfer(TMEMBER(_textRTL)); - - persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); - persistMgr->transfer(TMEMBER(_suspendedRendering)); - - persistMgr->transfer(TMEMBER(_mouseLockRect)); - - _windows.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_suppressScriptErrors)); - persistMgr->transfer(TMEMBER(_autorunDisabled)); - - persistMgr->transfer(TMEMBER(_autoSaveOnExit)); - persistMgr->transfer(TMEMBER(_autoSaveSlot)); - persistMgr->transfer(TMEMBER(_cursorHidden)); - - if (!persistMgr->_saving) - _quitting = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::focusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; - - for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == Window) { - if (i < _windows.getSize() - 1) { - _windows.removeAt(i); - _windows.add(Window); - - _gameRef->_focusedWindow = Window; - } - - if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return focusWindow(Prev); - else return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::freeze(bool includingMusic) { - if (_freezeLevel == 0) { - _scEngine->pauseAll(); - _soundMgr->pauseAll(includingMusic); - _origState = _state; - _origInteractive = _interactive; - _interactive = true; - } - _state = GAME_FROZEN; - _freezeLevel++; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::unfreeze() { - if (_freezeLevel == 0) return STATUS_OK; - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->resumeAll(); - _soundMgr->resumeAll(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleKeypress(Common::Event *event, bool printable) { - if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) - stopVideo(); - return true; - } - - if (event->type == Common::EVENT_QUIT) { - onWindowClose(); - return true; - } - - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->switchFullscreen(); - return true; - } - - - _keyboardState->handleKeyPress(event); - _keyboardState->readKey(event); -// TODO - - if (_focusedWindow) { - if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { - /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) - _gameRef->_focusedWindow->applyEvent("Keypress"); - else - applyEvent("Keypress"); - /*}*/ - } - return true; - } else { /*if (event->type != SDL_TEXTINPUT)*/ - applyEvent("Keypress"); - return true; - } //else return true; - - return false; -} - -void CBGame::handleKeyRelease(Common::Event *event) { - _keyboardState->handleKeyRelease(event); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::handleMouseWheel(int Delta) { - bool handled = false; - if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); - - if (!handled) { - if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); - handled = true; - } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); - handled = true; - } - - } - } - - if (!handled) { - if (Delta < 0) { - applyEvent("MouseWheelDown"); - } else { - applyEvent("MouseWheelUp"); - } - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) *verMajor = DCGF_VER_MAJOR; - if (verMinor) *verMinor = DCGF_VER_MINOR; - - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setWindowTitle() { - if (_renderer) { - char title[512]; - strcpy(title, _caption[0]); - if (title[0] != '\0') strcat(title, " - "); - strcat(title, "WME Lite"); - - - Utf8String utf8Title; - if (_textEncoding == TEXT_UTF8) { - utf8Title = Utf8String(title); - } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); - utf8Title = Utf8String(title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } -#if 0 - CBRenderOSystem *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - Common::String filename = pm->getFilenameForSlot(slot); - delete pm; - strcpy(buffer, filename.c_str()); - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDataDir() { - AnsiString userDir = PathUtil::getUserDirectory(); - AnsiString baseDir = _registry->getBasePath(); - return PathUtil::combine(userDir, baseDir); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotDescription(int slot, char *buffer) { - buffer[0] = '\0'; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(filename))) { - _debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - - _debugAbsolutePathWarning = true; - strcpy(buffer, pm->_savedDescription); - delete pm; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!File) return false; - delete File; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::emptySaveSlot(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(this); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); - delete pm; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setActiveObject(CBObject *obj) { - // not-active when game is frozen - if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { - obj = NULL; - } - - if (obj == _activeObject) return STATUS_OK; - - if (_activeObject) _activeObject->applyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); - _activeObject = obj; - if (_activeObject) { - _activeObject->applyEvent("MouseEntry"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::pushViewport(CBViewport *viewport) { - _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); - else _viewportStack[_viewportSP] = viewport; - - _renderer->setViewport(viewport->getRect()); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::popViewport() { - _viewportSP--; - if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); - - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) return STATUS_FAILED; - else { - if (_viewportSP >= 0) { - CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) *custom = true; - } else { - CBPlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (custom) *custom = false; - } - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { - if (_viewportSP >= 0) { - if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; - if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; - } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::setInteractive(bool state) { - _interactive = state; - if (_transMgr) _transMgr->_origInteractive = state; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::resetMousePos() { - Common::Point p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContent(bool doUpdate, bool displayAll) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContentSimple() { - // fill black - _renderer->fill(0, 0, 0); - if (_indicatorDisplay) displayIndicator(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayIndicator() { - if (_saveLoadImage) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; - _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) - _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - - _renderer->setup2D(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::updateMusicCrossfade() { - /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - - if (!_musicCrossfadeRunning) return STATUS_OK; - if (_state == GAME_FROZEN) return STATUS_OK; - - if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - - if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); - if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); - - uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; - - if (currentTime >= _musicCrossfadeLength) { - _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->setVolumePercent(100); - - _music[_musicCrossfadeChannel1]->stop(); - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent(100); - - - if (_musicCrossfadeSwap) { - // swap channels - CBSound *dummy = _music[_musicCrossfadeChannel1]; - int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; - - _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; - _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - - _music[_musicCrossfadeChannel2] = dummy; - _musicStartTime[_musicCrossfadeChannel2] = dummyInt; - } - } else { - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - - //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::resetContent() { - _scEngine->clearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { - warning("DEBUG_DumpClassRegistry - untested"); - Common::DumpFile *f = new Common::DumpFile; - f->open("zz_class_reg_dump.log"); - - CSysClassRegistry::getInstance()->dumpClasses(f); - - f->close(); - delete f; - _gameRef->quickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->invalidateDeviceObjects(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { - _regObjects[i]->restoreDeviceObjects(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::setWaitCursor(const char *filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new CBSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) return true; - if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::stopVideo() { - if (_videoPlayer->isPlaying()) _videoPlayer->stop(); - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - _theoraPlayer->stop(); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBGame::drawCursor(CBSprite *cursor) { - if (!cursor) return STATUS_FAILED; - if (cursor != _lastCursor) { - cursor->reset(); - _lastCursor = cursor; - } - return cursor->draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -bool CBGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return STATUS_OK; - - _renderer->_active = activate; - - if (refreshMouse) { - Point32 p; - getMousePos(&p); - setActiveObject(_renderer->getObjectAt(p.x, p.y)); - } - - if (activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) _capturedObject = _activeObject; - _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - - CBPlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; - - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->initLoop(); - displayContent(false, true); - displayDebugInfo(); - _renderer->windowedBlt(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onWindowClose() { - if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); - return STATUS_OK; - } else return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::displayDebugInfo() { - char str[100]; - - if (_debugShowFPS) { - sprintf(str, "FPS: %d", _gameRef->_fps); - _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); - } - - if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) - sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else - sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); - - strcat(str, " ("); - strcat(str, _renderer->getName()); - strcat(str, ")"); - _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - - _renderer->displayDebugInfo(); - - int scrTotal, scrRunning, scrWaiting, scrPersistent; - scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); - _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - - - sprintf(str, "Timer: %d", _timer); - _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); - - sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); - - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); - return _debugMgr; -} - - -////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Point32 *pos) { - CBPlatform::getCursorPos(pos); - - pos->x -= _renderer->_drawOffsetX; - pos->y -= _renderer->_drawOffsetY; - - /* - // Windows can squish maximized window if it's larger than desktop - // so we need to modify mouse position appropriately (tnx mRax) - if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { - Common::Rect rc; - ::GetClientRect(_renderer->_window, &rc); - Pos->x *= _gameRef->_renderer->_realWidth; - Pos->x /= (rc.right - rc.left); - Pos->y *= _gameRef->_renderer->_realHeight; - Pos->y /= (rc.bottom - rc.top); - } - */ - - if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { - pos->x = MAX(_mouseLockRect.left, pos->x); - pos->y = MAX(_mouseLockRect.top, pos->y); - - pos->x = MIN(_mouseLockRect.right, pos->x); - pos->y = MIN(_mouseLockRect.bottom, pos->y); - - Point32 newPos = *pos; - - newPos.x += _renderer->_drawOffsetX; - newPos.y += _renderer->_drawOffsetY; - - CBPlatform::setCursorPos(newPos.x, newPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::miniUpdate() { - if (!_miniUpdateEnabled) return STATUS_OK; - - if (CBPlatform::getTime() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::getTime(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::onScriptShutdown(CScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isLeftDoubleClick() { - return isDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isRightDoubleClick() { - return isDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool CBGame::isDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - - Point32 pos; - CBPlatform::getCursorPos(&pos); - - int moveX = abs(pos.x - _lastClick[buttonIndex].posX); - int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - - - if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = CBPlatform::getTime(); - _lastClick[buttonIndex].posX = pos.x; - _lastClick[buttonIndex].posY = pos.y; - return false; - } else { - _lastClick[buttonIndex].time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::autoSaveOnExit() { - _soundMgr->saveSettings(); - _registry->saveValues(); - - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; - - SaveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void CBGame::addMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDeviceType() const { - return "computer"; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BGame.h b/engines/wintermute/base/BGame.h deleted file mode 100644 index 7441d81b07..0000000000 --- a/engines/wintermute/base/BGame.h +++ /dev/null @@ -1,391 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H - -#include "engines/wintermute/base/BDebugger.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/math/Rect32.h" -#include "common/events.h" - -namespace WinterMute { - -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); - -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXMath; -class CBKeyboardState; -class CVidPlayer; -class CVidTheoraPlayer; - -#define NUM_MUSIC_CHANNELS 5 - -class CBGame: public CBObject { -public: - DECLARE_PERSISTENT(CBGame, CBObject) - - virtual bool onScriptShutdown(CScScript *script); - - virtual bool onActivate(bool activate, bool refreshMouse); - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - virtual bool onMouseMiddleDown(); - virtual bool onMouseMiddleUp(); - virtual bool onPaint(); - virtual bool onWindowClose(); - - bool isLeftDoubleClick(); - bool isRightDoubleClick(); - - bool _autorunDisabled; - - uint32 _lastMiniUpdate; - bool _miniUpdateEnabled; - - virtual bool miniUpdate(); - - void getMousePos(Point32 *Pos); - Rect32 _mouseLockRect; - - bool _shuttingDown; - - virtual bool displayDebugInfo(); - bool _debugShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - CBSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - virtual bool resetContent(); - - void DEBUG_DumpClassRegistry(); - bool setWaitCursor(const char *filename); - char *_localSaveDir; - bool _saveDirChecked; - - int _indicatorProgress; -protected: - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - CBSurface *_saveLoadImage; - bool displayIndicator(); - - bool _reportTextureFormat; -public: - int _thumbnailWidth; - int _thumbnailHeight; - - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; - bool _editorMode; - - bool _doNotExpandStrings; - void getOffset(int *offsetX, int *offsetY); - void setOffset(int offsetX, int offsetY); - int getSequence(); - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - CBObject *_mainObject; - - bool initInput(); - bool initLoop(); - uint32 _currentTime; - uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; - bool initialize1(); - bool initialize2(); - bool initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *getDebugMgr(); - - void LOG(bool res, const char *fmt, ...); - - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); - - virtual ~CBGame(); - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *filename = NULL); - bool _debugDebugMode; - bool _debugAbsolutePathWarning; - - void *_debugLogFile; - int _sequence; - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; - - int _viewportSP; - - CBStringTable *_stringTable; - int _settingsResWidth; - int _settingsResHeight; - char *_settingsGameFile; - bool _suppressScriptErrors; - bool _mouseLeftDown; -protected: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - CBFader *_fader; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); -public: - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - // compatibility bits - bool _compatKillMethodThreads; - -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; -public: - const char* getGameId() { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } - uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; - int _scheduledLoadSlot; - bool _loading; - bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); - void setWindowTitle(); - virtual bool handleMouseWheel(int delta); - bool _quitting; - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual void handleKeyRelease(Common::Event *event); -protected: - int _freezeLevel; -public: - bool unfreeze(); - bool freeze(bool includingMusic = true); - bool focusWindow(CUIWindow *window); - CVidPlayer *_videoPlayer; - CVidTheoraPlayer *_theoraPlayer; - bool _loadInProgress; - CUIWindow *_focusedWindow; - bool _editorForceScripts; -protected: - static void afterLoadRegion(void *region, void *data); - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); -public: - static void invalidateValues(void *value, void *data); - - bool loadSettings(const char *filename); - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; - bool displayWindows(bool inGame = false); - CBRegistry *_registry; - bool _useD3D; - virtual bool cleanup(); - virtual bool loadGame(int slot); - virtual bool loadGame(const char *filename); - virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); - virtual bool showCursor(); - - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - CBObject *_capturedObject; - Point32 _mousePos; - bool validObject(CBObject *object); - bool unregisterObject(CBObject *object); - bool registerObject(CBObject *object); - void quickMessage(const char *text); - void quickMessageForm(char *fmt, ...); - bool displayQuickMsg(); - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - - CBArray _regObjects; -public: - virtual bool displayContent(bool update = true, bool displayAll = false); - virtual bool displayContentSimple(); - bool _forceNonStreamedSounds; - void resetMousePos(); - int _subtitlesSpeed; - void setInteractive(bool state); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); - bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); - bool popViewport(); - bool pushViewport(CBViewport *Viewport); - bool setActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - bool drawCursor(CBSprite *Cursor); - - virtual bool initAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; - AnsiString getDataDir(); - void addMem(int bytes); - - bool _touchInterface; - bool _constrainedMemory; - AnsiString getDeviceType() const; - -private: - CBDebugger *_debugMgr; - - struct LastClickInfo { - LastClickInfo() { - posX = posY = 0; - time = 0; - } - - int posX; - int posY; - uint32 time; - }; - - LastClickInfo _lastClick[2]; - bool isDoubleClick(int buttonIndex); - uint32 _usedMem; - - - -protected: - // WME Lite specific - bool _autoSaveOnExit; - int _autoSaveSlot; - bool _cursorHidden; - -public: - void autoSaveOnExit(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BKeyboardState.cpp b/engines/wintermute/base/BKeyboardState.cpp deleted file mode 100644 index 85ab15f58e..0000000000 --- a/engines/wintermute/base/BKeyboardState.cpp +++ /dev/null @@ -1,304 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BKeyboardState.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/system.h" -#include "common/keyboard.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { - _currentPrintable = false; - _currentCharCode = 0; - _currentKeyData = 0; - - _currentShift = false; - _currentAlt = false; - _currentControl = false; - - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { - delete[] _keyStates; -} - -void CBKeyboardState::handleKeyPress(Common::Event *event) { - if (event->type == Common::EVENT_KEYDOWN) { - _keyStates[event->kbd.keycode] = true; - } -} - -void CBKeyboardState::handleKeyRelease(Common::Event *event) { - if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "IsKeyDown") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - int vKey; - - if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { - const char *str = val->getString(); - char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); - vKey = (int)temp; - } else vKey = val->getInt(); - - warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); - bool isDown = _keyStates[vKeyToKeyCode(vKey)]; - - stack->pushBool(isDown); - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("keyboard"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Key - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { - if (_currentPrintable) { - char key[2]; - key[0] = (char)_currentCharCode; - key[1] = '\0'; - _scValue->setString(key); - } else _scValue->setString(""); - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Printable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { - _scValue->setBool(_currentPrintable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KeyCode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { - _scValue->setInt(_currentCharCode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsShift - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { - _scValue->setBool(_currentShift); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsAlt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { - _scValue->setBool(_currentAlt); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsControl - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { - _scValue->setBool(_currentControl); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - if (_renderer) SetWindowText(_renderer->_window, _name); - return STATUS_OK; - } - - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::scToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::readKey(Common::Event *event) { - //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = keyCodeToVKey(event); - if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { - _currentPrintable = true; - } else { - _currentPrintable = false; - } - //_currentKeyData = KeyData; - - _currentControl = isControlDown(); - _currentAlt = isAltDown(); - _currentShift = isShiftDown(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { - //if(!persistMgr->_saving) cleanup(); - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_currentAlt)); - persistMgr->transfer(TMEMBER(_currentCharCode)); - persistMgr->transfer(TMEMBER(_currentControl)); - persistMgr->transfer(TMEMBER(_currentKeyData)); - persistMgr->transfer(TMEMBER(_currentPrintable)); - persistMgr->transfer(TMEMBER(_currentShift)); - - if (!persistMgr->_saving) { - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; - - switch (event->kbd.keycode) { - case Common::KEYCODE_KP_ENTER: - return Common::KEYCODE_RETURN; - default: - return (uint32)event->kbd.keycode; - } -} - -enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 -}; - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { - // todo - switch (vkey) { - case VK_SPACE: - return Common::KEYCODE_SPACE; - break; - case VK_LEFT: - return Common::KEYCODE_LEFT; - break; - case VK_RIGHT: - return Common::KEYCODE_RIGHT; - break; - case VK_UP: - return Common::KEYCODE_UP; - break; - case VK_DOWN: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; - } - -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BKeyboardState.h b/engines/wintermute/base/BKeyboardState.h deleted file mode 100644 index e3a4a903f7..0000000000 --- a/engines/wintermute/base/BKeyboardState.h +++ /dev/null @@ -1,75 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BScriptable.h" -#include "common/keyboard.h" -#include "common/events.h" - -namespace WinterMute { - -class CBKeyboardState : public CBScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); - bool readKey(Common::Event *event); - - void handleKeyPress(Common::Event *event); - void handleKeyRelease(Common::Event *event); - static bool isShiftDown(); - static bool isControlDown(); - static bool isAltDown(); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - uint8 *_keyStates; - uint32 keyCodeToVKey(Common::Event *event); - Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BNamedObject.cpp b/engines/wintermute/base/BNamedObject.cpp deleted file mode 100644 index 9587da45e8..0000000000 --- a/engines/wintermute/base/BNamedObject.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BNamedObject.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBNamedObject::setName(const char *name) { - delete[] _name; - - _name = new char [strlen(name) + 1]; - if (_name != NULL) strcpy(_name, name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BNamedObject.h b/engines/wintermute/base/BNamedObject.h deleted file mode 100644 index 4d5fdb0c0e..0000000000 --- a/engines/wintermute/base/BNamedObject.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBNamedObject : public CBBase { -public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); - - char *_name; - void setName(const char *name); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BObject.cpp b/engines/wintermute/base/BObject.cpp deleted file mode 100644 index ed5d6fa5b7..0000000000 --- a/engines/wintermute/base/BObject.cpp +++ /dev/null @@ -1,1128 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBObject, false) - -////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { - _posX = _posY = 0; - _movable = true; - _zoomable = true; - _registrable = true; - _shadowable = true; - _rotatable = false; - _is3D = false; - - _alphaColor = 0; - _scale = -1; - _relativeScale = 0; - - _scaleX = -1; - _scaleY = -1; - - _ready = true; - - _soundEvent = NULL; - - _iD = _gameRef->getSequence(); - - CBPlatform::setRectEmpty(&_rect); - _rectSet = false; - - _cursor = NULL; - _activeCursor = NULL; - _sharedCursors = false; - - _sFX = NULL; - _sFXStart = 0; - _sFXVolume = 100; - _autoSoundPanning = true; - - _editorAlwaysRegister = false; - _editorSelected = false; - - _editorOnly = false; - - _rotate = 0.0f; - _rotateValid = false; - _relativeRotate = 0.0f; - - for (int i = 0; i < 7; i++) - _caption[i] = NULL; - _saveState = true; - - _nonIntMouseEvents = false; - - // sound FX - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - _blendMode = BLEND_NORMAL; -} - - -////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) - _gameRef->_activeObject = NULL; - - CBScriptHolder::cleanup(); - delete[] _soundEvent; - _soundEvent = NULL; - - if (!_sharedCursors) { - delete _cursor; - delete _activeCursor; - _cursor = NULL; - _activeCursor = NULL; - } - delete _sFX; - _sFX = NULL; - - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7) - return; - - delete[] _caption[caseVal - 1]; - _caption[caseVal - 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal - 1]) { - strcpy(_caption[caseVal - 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) - return ""; - else return _caption[caseVal - 1]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - afterMove(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - stack->correctParams(1); - stack->pushString(getCaption(stack->pop()->getInt())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveCursor") == 0) { - stack->correctParams(0); - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } else { - _cursor = NULL; - - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursor") == 0) { - stack->correctParams(0); - if (!_cursor || !_cursor->_filename) stack->pushNULL(); - else stack->pushString(_cursor->_filename); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursorObject") == 0) { - stack->correctParams(0); - if (!_cursor) stack->pushNULL(); - else stack->pushNative(_cursor, true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasCursor") == 0) { - stack->correctParams(0); - - if (_cursor) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCaption") == 0) { - stack->correctParams(2); - setCaption(stack->pop()->getString(), stack->pop()->getInt()); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadSound") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySound") == 0) { - stack->correctParams(3); - - const char *filename; - bool looping; - uint32 loopStart; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); - - if (val1->_type == VAL_BOOL) { - filename = NULL; - looping = val1->getBool(); - loopStart = val2->getInt(); - } else { - if (val1->isNULL()) filename = NULL; - else filename = val1->getString(); - looping = val2->isNULL() ? false : val2->getBool(); - loopStart = val3->getInt(); - } - - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) - stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySoundEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySoundEvent") == 0) { - stack->correctParams(2); - - const char *filename; - const char *eventName; - - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - - if (val2->isNULL()) { - filename = NULL; - eventName = val1->getString(); - } else { - filename = val1->getString(); - eventName = val2->getString(); - } - - if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(pauseSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(resumeSFX())) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSoundPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSoundPlaying") == 0) { - stack->correctParams(0); - - if (_sFX && _sFX->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundPosition") == 0) { - stack->correctParams(1); - - uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundPosition") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(0); - else stack->pushInt(_sFX->getPositionTime()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundVolume") == 0) { - stack->correctParams(1); - - int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); - else stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundVolume") == 0) { - stack->correctParams(0); - - if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolumePercent()); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SoundFXNone - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXNone") == 0) { - stack->correctParams(0); - _sFXType = SFX_NONE; - _sFXParam1 = 0; - _sFXParam2 = 0; - _sFXParam3 = 0; - _sFXParam4 = 0; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXEcho - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXEcho") == 0) { - stack->correctParams(4); - _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXReverb - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXReverb") == 0) { - stack->correctParams(4); - _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - stack->pushNULL(); - - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - _scValue->setString(getCaption(1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(getHeight()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Ready (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { - _scValue->setBool(_ready); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _scValue->setBool(_movable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _scValue->setBool(_registrable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _scValue->setBool(_zoomable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _scValue->setBool(_rotatable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alphaColor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - _scValue->setInt((int)_blendMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _scValue->setFloat((double)_relativeScale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->setNULL(); - else _scValue->setFloat((double)_rotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _scValue->setFloat((double)_relativeRotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _scValue->setBool(_shadowable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _scValue->setBool(_autoSoundPanning); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _scValue->setBool(_saveState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _scValue->setBool(_nonIntMouseEvents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - _scValue->setNULL(); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Caption") == 0) { - setCaption(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _movable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _rotatable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; - _blendMode = (TSpriteBlendMode)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) _scale = -1; - else _scale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) _scaleX = -1; - else _scaleX = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) _scaleY = -1; - else _scaleY = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (value->isNULL()) { - _rotate = 0.0f; - _rotateValid = false; - } else { - _rotate = (float)value->getFloat(); - _rotateValid = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _shadowable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) resetSoundPan(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _saveState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBObject::scToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::showCursor() { - if (_cursor) return _gameRef->drawCursor(_cursor); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - for (int i = 0; i < 7; i++) - persistMgr->transfer(TMEMBER(_caption[i])); - persistMgr->transfer(TMEMBER(_activeCursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - persistMgr->transfer(TMEMBER(_autoSoundPanning)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_sharedCursors)); - persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); - persistMgr->transfer(TMEMBER(_editorOnly)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_is3D)); - persistMgr->transfer(TMEMBER(_movable)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); - persistMgr->transfer(TMEMBER(_relativeScale)); - persistMgr->transfer(TMEMBER(_rotatable)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_sFX)); - persistMgr->transfer(TMEMBER(_sFXStart)); - persistMgr->transfer(TMEMBER(_sFXVolume)); - persistMgr->transfer(TMEMBER(_ready)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_rectSet)); - persistMgr->transfer(TMEMBER(_registrable)); - persistMgr->transfer(TMEMBER(_shadowable)); - persistMgr->transfer(TMEMBER(_soundEvent)); - persistMgr->transfer(TMEMBER(_zoomable)); - - persistMgr->transfer(TMEMBER(_scaleX)); - persistMgr->transfer(TMEMBER(_scaleY)); - - persistMgr->transfer(TMEMBER(_rotate)); - persistMgr->transfer(TMEMBER(_rotateValid)); - persistMgr->transfer(TMEMBER(_relativeRotate)); - - persistMgr->transfer(TMEMBER(_saveState)); - persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); - - persistMgr->transfer(TMEMBER_INT(_sFXType)); - persistMgr->transfer(TMEMBER(_sFXParam1)); - persistMgr->transfer(TMEMBER(_sFXParam2)); - persistMgr->transfer(TMEMBER(_sFXParam3)); - persistMgr->transfer(TMEMBER(_sFXParam4)); - - - persistMgr->transfer(TMEMBER_INT(_blendMode)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setCursor(const char *filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new CBSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { - delete _cursor; - _cursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setActiveCursor(const char *filename) { - delete _activeCursor; - _activeCursor = new CBSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { - delete _activeCursor; - _activeCursor = NULL; - return STATUS_FAILED; - } else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBObject::getHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleKeypress(Common::Event *event, bool printable) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouseWheel(int delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { - // just play loaded sound - if (filename == NULL && _sFX) { - if (_gameRef->_editorMode || _sFXStart) { - _sFX->setVolumePercent(_sFXVolume); - _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) _sFXStart = 0; - } - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } - - if (filename == NULL) return STATUS_FAILED; - - // create new sound - delete _sFX; - - _sFX = new CBSound(_gameRef); - if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { - _sFX->setVolumePercent(_sFXVolume); - if (_sFXStart) { - _sFX->setPositionTime(_sFXStart); - _sFXStart = 0; - } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (playNow) { - setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); - return _sFX->play(looping); - } else return STATUS_OK; - } else { - delete _sFX; - _sFX = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::stopSFX(bool deleteSound) { - if (_sFX) { - _sFX->stop(); - if (deleteSound) { - delete _sFX; - _sFX = NULL; - } - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::pauseSFX() { - if (_sFX) return _sFX->pause(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resumeSFX() { - if (_sFX) return _sFX->resume(); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXTime(uint32 time) { - _sFXStart = time; - if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXVolume(int volume) { - _sFXVolume = volume; - if (_sFX) return _sFX->setVolumePercent(volume); - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->isPlaying()) { - applyEvent(_soundEvent); - setSoundEvent(NULL); - } - } - - if (_sFX) updateOneSound(_sFX); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::updateOneSound(CBSound *sound) { - bool Ret = STATUS_OK; - - if (sound) { - if (_autoSoundPanning) - Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); - - Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - } - return Ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::resetSoundPan() { - if (!_sFX) return STATUS_OK; - else { - return _sFX->setPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::getExtendedFlag(const char *flagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBObject::isReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void CBObject::setSoundEvent(const char *eventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (eventName) { - _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, eventName); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBObject::afterMove() { - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BObject.h b/engines/wintermute/base/BObject.h deleted file mode 100644 index c855c770b7..0000000000 --- a/engines/wintermute/base/BObject.h +++ /dev/null @@ -1,144 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H - - -#include "engines/wintermute/base/BScriptHolder.h" -#include "engines/wintermute/persistent.h" -#include "common/events.h" - -namespace WinterMute { - -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(CBSound *sound); - bool _autoSoundPanning; - uint32 _sFXStart; - int _sFXVolume; - bool setSFXTime(uint32 time); - bool setSFXVolume(int volume); - bool resumeSFX(); - bool pauseSFX(); - bool stopSFX(bool deleteSound = true); - bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - CBSound *_sFX; - - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - - virtual bool handleMouseWheel(int delta); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual int getHeight(); - bool setCursor(const char *filename); - bool setActiveCursor(const char *filename); - bool cleanup(); - const char *getCaption(int caseVal = 1); - void setCaption(const char *caption, int caseVal = 1); - bool _editorSelected; - bool _editorAlwaysRegister; - bool _editorOnly; - bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) - virtual bool showCursor(); - CBSprite *_cursor; - bool _sharedCursors; - CBSprite *_activeCursor; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; - bool _zoomable; - bool _shadowable; - Rect32 _rect; - bool _rectSet; - int _iD; - bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); - char *_caption[7]; - char *_soundEvent; - int _posY; - int _posX; - bool _saveState; - - // base - virtual bool update() { - return STATUS_FAILED; - }; - virtual bool display() { - return STATUS_FAILED; - }; - virtual bool invalidateDeviceObjects() { - return STATUS_OK; - }; - virtual bool restoreDeviceObjects() { - return STATUS_OK; - }; - bool _nonIntMouseEvents; - - -public: - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BParser.cpp b/engines/wintermute/base/BParser.cpp deleted file mode 100644 index 80d3b58213..0000000000 --- a/engines/wintermute/base/BParser.cpp +++ /dev/null @@ -1,436 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/util.h" - -#define WHITESPACE " \t\n\r" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { - skipCharacters(buf, _whiteSpace); - - // skip comment lines. - while (**buf == ';') { - *buf = strchr(*buf, '\n'); - _parserLine++; - skipCharacters(buf, _whiteSpace); - } - - if (! **buf) // at end of file - return PARSERR_EOF; - - // find the token. - // for now just use brute force. Improve later. - while (tokens->id != 0) { - if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { - // here we could be matching PART of a string - // we could detect this here or the token list - // could just have the longer tokens first in the list - break; - } - ++tokens; - } - if (tokens->id == 0) { - char *p = strchr(*buf, '\n'); - if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); - - return PARSERR_TOKENNOTFOUND; - } - // skip the token - *buf += strlen(tokens->token); - skipCharacters(buf, _whiteSpace); - - // get optional name - *name = getSubText(buf, '\'', '\''); // single quotes - skipCharacters(buf, _whiteSpace); - - // get optional data - if (**buf == '=') // An assignment rather than a command/object. - *data = getAssignmentText(buf); - else - *data = getSubText(buf, '{', '}'); - - return tokens->id; -} - - -////////////////////////////////////////////////////////////////////// -int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; - _gameRef->miniUpdate(); - char *name; - return getObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipCharacters(char **buf, const char *toSkip) { - char ch; - while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) - return; - ++*buf; // skip this character - } - // we must be at the end of the buffer if we get here -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) - return 0; - ++*buf; // skip opening delimiter - char *result = *buf; - - // now find the closing delimiter - char theChar; - long skip = 1; - - if (open == close) // we cant nest identical delimiters - open = 0; - while ((theChar = **buf) != 0) { - if (theChar == open) - ++skip; - if (theChar == close) { - if (--skip == 0) { - **buf = 0; // null terminate the result string - ++*buf; // move past the closing delimiter - break; - } - } - ++*buf; // try next character - } - return result; -} - - -////////////////////////////////////////////////////////////////////// -char *CBParser::getAssignmentText(char **buf) { - ++*buf; // skip the '=' - skipCharacters(buf, _whiteSpace); - char *result = *buf; - - - if (*result == '"') { - result = getSubText(buf, '"', '"'); - } else { - // now, we need to find the next whitespace to end the data - char theChar; - - while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars - break; - ++*buf; - } - **buf = 0; // null terminate it - if (theChar) // skip the terminator - ++*buf; - } - - return result; -} - - -////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -char *CBParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; - while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; - if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; - } - - if (*b == '\'') { - b++; - while (*b && *b != '\'') { - *t++ = *b++; - } - *t++ = 0; - if (*b == '\'') b++; - } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || - *b == '%' || *b == ':' || *b == '{' || *b == '}') { - *t++ = *b++; - *t++ = 0; - } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { - *t++ = *b++; - *t++ = 0; - } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { - while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { - *t++ = *b++; - } - *t++ = 0; - } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { - while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { - *t++ = *b++; - } - *t++ = 0; - } else if (*b == 0) { - *buf = b; - return NULL; - } else { - // Error. - return NULL; - } - - *buf = b; - return token; -} - - -////////////////////////////////////////////////////////////////////// -float CBParser::getTokenFloat(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { - // Error situation. We handle this by return 0. - return 0.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::getTokenInt(char **buf) { - char *t = getToken(buf); - if (!((*t >= '0' && *t <= '9') || *t == '-')) { - // Error situation. We handle this by return 0. - return 0; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); - if (strcmp(t, tok)) return; // Error -} - - -////////////////////////////////////////////////////////////////////// -int CBParser::scanStr(const char *in, const char *format, ...) { - va_list arg; - va_start(arg, format); - - int num = 0; - in += strspn(in, " \t\n\f"); - - while (*format && *in) { - if (*format == '%') { - format++; - switch (*format) { - case 'd': { - int *a = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - *a = atoi(in); - in += strspn(in, "0123456789+- \t\n\f"); - num++; - break; - } - case 'D': { - int i; - int *list = va_arg(arg, int *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { - list[i++] = atoi(in); - in += strspn(in, "0123456789+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 'b': { - bool *a = va_arg(arg, bool *); - in += strspn(in, " \t\n\f"); - const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - int l = (int)(in2 - in); - - *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || - !scumm_strnicmp(in, "1", l)); - - - in = in2 + strspn(in2, " \t\n\f"); - num++; - break; - } - case 'f': { - float *a = va_arg(arg, float *); - in += strspn(in, " \t\n\f"); - *a = (float)atof(in); - in += strspn(in, "0123456789.eE+- \t\n\f"); - num++; - break; - } - case 'F': { - int i; - float *list = va_arg(arg, float *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { - list[i++] = (float)atof(in); - in += strspn(in, "0123456789.eE+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') break; - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 's': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\'') { - in++; - const char *in2 = strchr(in, '\''); - if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; - in = in2; - } - in += strspn(in, " \t\n\f"); - num++; - break; - } - case 'S': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\"') { - in++; - while (*in != '\"') { - if (*in == '\\') { - in++; - switch (*in) { - case '\\': - *a++ = '\\'; - break; - case 'n': - *a++ = '\n'; - break; - case 'r': - *a++ = '\r'; - break; - case 't': - *a++ = '\t'; - break; - case '"': - *a++ = '"'; - break; - default: - *a++ = '\\'; - *a++ = *in; - break; - } //switch - in++; - } else { - *a++ = *in++; - } - } //while in string - in++; - num++; - } //if string started - - //terminate string - *a = '\0'; - break; - } - } - if (*format) format++; - } else if (*format == ' ') { - format++; - in += strspn(in, " \t\n\f"); - } else if (*in == *format) { - in++; - format++; - } else { - num = -1; - break; - } - } - - va_end(arg); - - return num; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BParser.h b/engines/wintermute/base/BParser.h deleted file mode 100644 index ae886953a9..0000000000 --- a/engines/wintermute/base/BParser.h +++ /dev/null @@ -1,89 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H - - -#define TOKEN_DEF_START \ - enum \ - { \ - TOKEN_NONE = 0, -#define TOKEN_DEF(name) \ - TOKEN_ ## name, -#define TOKEN_DEF_END \ - TOKEN_TOTAL_COUNT \ - }; -#define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ - { -#define TOKEN_TABLE(name) \ - { TOKEN_ ## name, #name }, -#define TOKEN_TABLE_END \ - { 0, 0 } \ - }; - -#define PARSERR_GENERIC -3 -#define PARSERR_EOF -2 -#define PARSERR_TOKENNOTFOUND -1 - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBParser : public CBBase { -public: - struct TokenDesc { - int32 id; - const char *token; - }; - -public: - int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); -private: - char *getLastOffender(); - void skipToken(char **buf, char *tok, char *msg = NULL); - int getTokenInt(char **buf); - float getTokenFloat(char **buf); - char *getToken(char **buf); - char *getAssignmentText(char **buf); - char *getSubText(char **buf, char open, char close); - void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - char *_whiteSpace; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BPersistMgr.cpp b/engines/wintermute/base/BPersistMgr.cpp deleted file mode 100644 index f8faced95f..0000000000 --- a/engines/wintermute/base/BPersistMgr.cpp +++ /dev/null @@ -1,778 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BPersistMgr.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BSound.h" -#include "graphics/decoders/bmp.h" -#include "common/memstream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/savefile.h" - -namespace WinterMute { - -#define SAVE_BUFFER_INIT_SIZE 100000 -#define SAVE_BUFFER_GROW_BY 50000 - -#define SAVE_MAGIC 0x45564153 -#define SAVE_MAGIC_2 0x32564153 - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { - _saving = false; -// _buffer = NULL; -// _bufferSize = 0; - _offset = 0; - _saveStream = NULL; - _loadStream = NULL; - - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - _thumbnailData = NULL; - if (savePrefix) { - _savePrefix = savePrefix; - } else if (_gameRef) { - _savePrefix = _gameRef->getGameId(); - } else { - _savePrefix = "wmesav"; - } -} - - -////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::cleanup() { - /* if (_buffer) { - if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0;*/ - _offset = 0; - - delete[] _richBuffer; - _richBuffer = NULL; - _richBufferSize = 0; - - delete[] _savedDescription; - _savedDescription = NULL; // ref to buffer -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - if (_thumbnailData) { - delete [] _thumbnailData; - _thumbnailData = NULL; - } - - delete _loadStream; - delete _saveStream; - _loadStream = NULL; - _saveStream = NULL; -} - -Common::String CBPersistMgr::getFilenameForSlot(int slot) const { - // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) - return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); -} - -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); - return; - } - desc.setSaveSlot(slot); - desc.setDescription(_savedDescription); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - - if (_thumbnailDataSize > 0) { - Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); - Graphics::BitmapDecoder bmpDecoder; - if (bmpDecoder.loadStream(thumbStream)) { - Graphics::Surface *surf = new Graphics::Surface; - surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); - desc.setThumbnail(surf); - } - } - - desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); - desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); - desc.setPlayTime(0); -} - -void CBPersistMgr::deleteSaveSlot(int slot) { - Common::String filename = getFilenameForSlot(slot); - g_system->getSavefileManager()->removeSavefile(filename); -} - -uint32 CBPersistMgr::getMaxUsedSlot() { - Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); - Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); - Common::StringArray::iterator it = saves.begin(); - int ret = -1; - for (; it != saves.end(); it++) { - int num = -1; - sscanf(it->c_str(), "save%d", &num); - ret = MAX(ret, num); - } - return ret; -} - -bool CBPersistMgr::getSaveExists(int slot) { - Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initSave(const char *desc) { - if (!desc) return STATUS_FAILED; - - cleanup(); - _saving = true; - - _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - - if (_saveStream) { - // get thumbnails - if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); - if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - } - } - - uint32 magic = DCGF_MAGIC; - putDWORD(magic); - - magic = SAVE_MAGIC_2; - putDWORD(magic); - - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(VerMajor); - _saveStream->writeByte(VerMinor); - _saveStream->writeByte(ExtMajor); - _saveStream->writeByte(ExtMinor); - - // new in ver 2 - putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->_name); - - // thumbnail data size - bool thumbnailOK = false; - - if (_gameRef->_cachedThumbnail) { - if (_gameRef->_cachedThumbnail->_thumbnail) { - Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); - if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { - _saveStream->writeUint32LE(thumbStream.size()); - _saveStream->write(thumbStream.getData(), thumbStream.size()); - } else { - _saveStream->writeUint32LE(0); - } - - thumbnailOK = true; - } - } - if (!thumbnailOK) putDWORD(0); - - // in any case, destroy the cached thumbnail once used - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - - uint32 dataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(desc) + 1 + // description - sizeof(uint32); // timestamp - - putDWORD(dataOffset); - putString(desc); - - g_system->getTimeAndDate(_savedTimestamp); - putTimeDate(_savedTimestamp); - _savedPlayTime = g_system->getMillis(); - _saveStream->writeUint32LE(_savedPlayTime); - } - return STATUS_OK; -} - -bool CBPersistMgr::readHeader(const Common::String &filename) { - cleanup(); - - _saving = false; - - _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); - if (_loadStream) { - uint32 magic; - magic = getDWORD(); - - if (magic != DCGF_MAGIC) { - cleanup(); - return STATUS_FAILED; - } - - magic = getDWORD(); - - if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { - _savedVerMajor = _loadStream->readByte(); - _savedVerMinor = _loadStream->readByte(); - _savedExtMajor = _loadStream->readByte(); - _savedExtMinor = _loadStream->readByte(); - - if (magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)getDWORD(); - _savedName = getStringObj(); - - // load thumbnail - _thumbnailDataSize = getDWORD(); - if (_thumbnailDataSize > 0) { - _thumbnailData = new byte[_thumbnailDataSize]; - if (_thumbnailData) { - getBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; - } - } else _savedVerBuild = 35; // last build with ver1 savegames - - uint32 dataOffset = getDWORD(); - - _savedDescription = getString(); - _savedTimestamp = getTimeDate(); - _savedPlayTime = _loadStream->readUint32LE(); - - _offset = dataOffset; - - return STATUS_OK; - } - } - - cleanup(); - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initLoad(const char *filename) { - if (DID_FAIL(readHeader(filename))) { - cleanup(); - return STATUS_FAILED; - } - _saving = false; - - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { - _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); - cleanup(); - return STATUS_FAILED; - } - - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - } - - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - - } - - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::saveFile(const char *filename) { - return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { - _saveStream->write(buffer, size); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { - _loadStream->read(buffer, size); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putDWORD(uint32 val) { - _saveStream->writeUint32LE(val); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::getDWORD() { - uint32 ret = _loadStream->readUint32LE(); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putString(const Common::String &val) { - if (!val.size()) putString("(null)"); - else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); - } -} - -Common::String CBPersistMgr::getStringObj() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - Common::String retString = ret; - delete[] ret; - - if (retString == "(null)") { - retString = ""; - } - - return retString; -} - -////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::getString() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - if (!strcmp(ret, "(null)")) { - delete[] ret; - return NULL; - } else return ret; -} - -bool CBPersistMgr::putTimeDate(const TimeDate &t) { - _saveStream->writeSint32LE(t.tm_sec); - _saveStream->writeSint32LE(t.tm_min); - _saveStream->writeSint32LE(t.tm_hour); - _saveStream->writeSint32LE(t.tm_mday); - _saveStream->writeSint32LE(t.tm_mon); - _saveStream->writeSint32LE(t.tm_year); - // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next - - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -TimeDate CBPersistMgr::getTimeDate() { - TimeDate t; - t.tm_sec = _loadStream->readSint32LE(); - t.tm_min = _loadStream->readSint32LE(); - t.tm_hour = _loadStream->readSint32LE(); - t.tm_mday = _loadStream->readSint32LE(); - t.tm_mon = _loadStream->readSint32LE(); - t.tm_year = _loadStream->readSint32LE(); - // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next - return t; -} - -void CBPersistMgr::putFloat(float val) { - Common::String str = Common::String::format("F%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -float CBPersistMgr::getFloat() { - char *str = getString(); - float value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -void CBPersistMgr::putDouble(double val) { - Common::String str = Common::String::format("F%f", val); - str.format("D%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -double CBPersistMgr::getDouble() { - char *str = getString(); - double value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -////////////////////////////////////////////////////////////////////////// -// bool -bool CBPersistMgr::transfer(const char *name, bool *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// int -bool CBPersistMgr::transfer(const char *name, int *val) { - if (_saving) { - _saveStream->writeSint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// DWORD -bool CBPersistMgr::transfer(const char *name, uint32 *val) { - if (_saving) { - _saveStream->writeUint32LE(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readUint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// float -bool CBPersistMgr::transfer(const char *name, float *val) { - if (_saving) { - putFloat(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// double -bool CBPersistMgr::transfer(const char *name, double *val) { - if (_saving) { - putDouble(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = getDouble(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// char* -bool CBPersistMgr::transfer(const char *name, char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// const char* -bool CBPersistMgr::transfer(const char *name, const char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// Common::String -bool CBPersistMgr::transfer(const char *name, Common::String *val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - *val = str; - delete[] str; - } else { - *val = ""; - } - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { - size_t size; - - if (_saving) { - size = val.size(); - _saveStream->writeUint32LE(size); - - for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { - putString((*it).c_str()); - } - } else { - val.clear(); - size = _loadStream->readUint32LE(); - - for (size_t i = 0; i < size; i++) { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) val.push_back(str); - delete[] str; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// BYTE -bool CBPersistMgr::transfer(const char *name, byte *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// RECT -bool CBPersistMgr::transfer(const char *name, Rect32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->left); - _saveStream->writeSint32LE(val->top); - _saveStream->writeSint32LE(val->right); - _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->left = _loadStream->readSint32LE(); - val->top = _loadStream->readSint32LE(); - val->right = _loadStream->readSint32LE(); - val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// POINT -bool CBPersistMgr::transfer(const char *name, Point32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->x); - _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = _loadStream->readSint32LE(); - val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// Vector2 -bool CBPersistMgr::transfer(const char *name, Vector2 *val) { - if (_saving) { - putFloat(val->x); - putFloat(val->y); - if (_saveStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } else { - val->x = getFloat(); - val->y = getFloat(); - if (_loadStream->err()) - return STATUS_FAILED; - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// generic pointer -bool CBPersistMgr::transfer(const char *name, void *val) { - int classID = -1, instanceID = -1; - - if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); - if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - _gameRef->LOG(0, "Warning: invalid instance '%s'", name); - } - - _saveStream->writeUint32LE(classID); - _saveStream->writeUint32LE(instanceID); - } else { - classID = _loadStream->readUint32LE(); - instanceID = _loadStream->readUint32LE(); - - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) return true; - - // it's ok if we are same or newer than the saved game - if (verMajor > _savedVerMajor || - (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || - (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) return false; - - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPersistMgr.h b/engines/wintermute/base/BPersistMgr.h deleted file mode 100644 index 2e6ee8058c..0000000000 --- a/engines/wintermute/base/BPersistMgr.h +++ /dev/null @@ -1,114 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/savestate.h" -#include "common/stream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/rect.h" - -namespace WinterMute { - -class Vector2; - -class CBPersistMgr : public CBBase { -public: - char *_savedDescription; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; - Common::String _savePrefix; - Common::String _savedName; - bool saveFile(const char *filename); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - Common::String getStringObj(); - void putString(const Common::String &val); - float getFloat(); - void putFloat(float val); - double getDouble(); - void putDouble(double val); - void cleanup(); - void getSaveStateDesc(int slot, SaveStateDescriptor &desc); - void deleteSaveSlot(int slot); - uint32 getMaxUsedSlot(); - bool getSaveExists(int slot); - bool initLoad(const char *filename); - bool initSave(const char *desc); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 _offset; - - bool _saving; - - uint32 _richBufferSize; - byte *_richBuffer; - - bool transfer(const char *name, void *val); - bool transfer(const char *name, int *val); - bool transfer(const char *name, uint32 *val); - bool transfer(const char *name, float *val); - bool transfer(const char *name, double *val); - bool transfer(const char *name, bool *val); - bool transfer(const char *name, byte *val); - bool transfer(const char *name, Rect32 *val); - bool transfer(const char *name, Point32 *val); - bool transfer(const char *name, const char **val); - bool transfer(const char *name, char **val); - bool transfer(const char *name, Common::String *val); - bool transfer(const char *name, Vector2 *val); - bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); - virtual ~CBPersistMgr(); - bool checkVersion(byte verMajor, byte verMinor, byte verBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - Common::String getFilenameForSlot(int slot) const; -private: - bool readHeader(const Common::String &filename); - TimeDate getTimeDate(); - bool putTimeDate(const TimeDate &t); - Common::WriteStream *_saveStream; - Common::SeekableReadStream *_loadStream; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BPoint.cpp b/engines/wintermute/base/BPoint.cpp deleted file mode 100644 index 4c80e154f2..0000000000 --- a/engines/wintermute/base/BPoint.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBPoint, false) - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -bool CBPoint::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BPoint.h b/engines/wintermute/base/BPoint.h deleted file mode 100644 index 3e4adb5d13..0000000000 --- a/engines/wintermute/base/BPoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPoint: public CBBase { -public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); - int y; - int x; - virtual ~CBPoint(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BQuickMsg.cpp b/engines/wintermute/base/BQuickMsg.cpp deleted file mode 100644 index 32bd04afe2..0000000000 --- a/engines/wintermute/base/BQuickMsg.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BQuickMsg.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { - _text = new char [strlen(text) + 1]; - if (_text) strcpy(_text, text); - _startTime = _gameRef->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { - if (_text) delete [] _text; -} - - -////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::getText() { - return _text; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BQuickMsg.h b/engines/wintermute/base/BQuickMsg.h deleted file mode 100644 index c247183714..0000000000 --- a/engines/wintermute/base/BQuickMsg.h +++ /dev/null @@ -1,48 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBQuickMsg : public CBBase { -public: - char *getText(); - uint32 _startTime; - char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BRegion.cpp b/engines/wintermute/base/BRegion.cpp deleted file mode 100644 index c8ec87e04a..0000000000 --- a/engines/wintermute/base/BRegion.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBRegion, false) - -////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - CBPlatform::setRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::createRegion() { - return DID_SUCCEED(getBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) return false; - - Point32 pt; - pt.x = x; - pt.y = y; - - Rect32 rect; - rect.left = x - 1; - rect.right = x + 2; - rect.top = y - 1; - rect.bottom = y + 2; - - if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); - else return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(POINT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(POINT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int i; - - for (i = 0; i < _points.getSize(); i++) delete _points[i]; - _points.removeAll(); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // AddPoint - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AddPoint") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - _points.add(new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new CBPoint(x, y)); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPoint") == 0) { - stack->correctParams(3); - int Index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (Index >= 0 && Index < _points.getSize()) { - _points[Index]->x = x; - _points[Index]->y = y; - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemovePoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemovePoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - delete _points[index]; - _points[index] = NULL; - - _points.removeAt(index); - createRegion(); - - stack->pushBool(true); - } else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < _points.getSize()) { - CScValue *val = stack->getPushValue(); - if (val) { - val->setProperty("X", _points[index]->x); - val->setProperty("Y", _points[index]->y); - } - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.getSize()); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBRegion::scToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", nameOverride); - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (i = 0; i < _points.getSize(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - if (_scProp) _scProp->saveAsText(buffer, indent + 2); - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -typedef struct { - double x, y; -} dPoint; - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) return false; - - int counter = 0; - double xinters; - dPoint p, p1, p2; - - p.x = (double)x; - p.y = (double)y; - - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; - - for (int i = 1; i <= _points.getSize(); i++) { - p2.x = (double)_points[i % _points.getSize()]->x; - p2.y = (double)_points[i % _points.getSize()]->y; - - if (p.y > MIN(p1.y, p2.y)) { - if (p.y <= MAX(p1.y, p2.y)) { - if (p.x <= MAX(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) - counter++; - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) - return false; - else - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); - else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; - - for (int i = 0; i < _points.getSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); - - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); - } - CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; - - cleanup(); - - for (int i = 0; i < region->_points.getSize(); i++) { - int xVal, yVal; - - xVal = (int)((float)region->_points[i]->x * scale / 100.0f); - yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - - _points.add(new CBPoint(xVal + x, yVal + y)); - } - - _lastMimicScale = scale; - _lastMimicX = x; - _lastMimicY = y; - - return createRegion() ? STATUS_OK : STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegion.h b/engines/wintermute/base/BRegion.h deleted file mode 100644 index 2a92d9daff..0000000000 --- a/engines/wintermute/base/BRegion.h +++ /dev/null @@ -1,68 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H - -#include "engines/wintermute/base/BPoint.h" -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CBRegion : public CBObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); - bool getBoundingRect(Rect32 *rect); - bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(CBRegion, CBObject) - bool _active; - int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); - bool pointInRegion(int x, int y); - bool createRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - Rect32 _rect; - CBArray _points; - virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BRegistry.cpp b/engines/wintermute/base/BRegistry.cpp deleted file mode 100644 index fef09d7479..0000000000 --- a/engines/wintermute/base/BRegistry.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/utils.h" -#include "common/config-manager.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { - _iniName = NULL; - - setIniName("./wme.ini"); - loadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { - saveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - - bool found = false; - ret = getValue(_localValues, subKey, key, found); - if (!found) ret = getValue(_values, subKey, key, found); - if (!found) ret = init; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - if (ConfMan.hasKey("master_volume")) { - return ConfMan.getInt("master_volume"); - } else { - return init; - } - } else if (key == "SFXVolume") { - if (ConfMan.hasKey("sfx_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "SpeechVolume") { - if (ConfMan.hasKey("speech_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "MusicVolume") { - if (ConfMan.hasKey("music_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } - } - AnsiString val = readString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - ConfMan.setInt("master_volume", value); - return true; - } else if (key == "SFXVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "SpeechVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "MusicVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } - } - writeString(subKey, key, StringUtil::toString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (readInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return writeInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setIniName(const char *name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { - _iniName = new char [strlen(name) + 3]; - sprintf(_iniName, "./%s", name); - } else { - _iniName = new char [strlen(name) + 1]; - strcpy(_iniName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *CBRegistry::getIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadValues(bool local) { - if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveValues() { - saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::setBasePath(const char *basePath) { - _basePath = PathUtil::getFileNameWithoutExtension(basePath); - - loadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::createPath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - Common::DumpFile stream; - stream.open(fileName.c_str()); - - if (!stream.isOpen()) return; - else { - stream.write(printer.CStr(), printer.Size()); - stream.close(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BRegistry.h b/engines/wintermute/base/BRegistry.h deleted file mode 100644 index 123d1d8a2f..0000000000 --- a/engines/wintermute/base/BRegistry.h +++ /dev/null @@ -1,76 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBRegistry : public CBBase { -public: - void setIniName(const char *name); - char *getIniName(); - bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); - int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); - - void setBasePath(const char *basePath); - AnsiString getBasePath() const { - return _basePath; - } - - void loadValues(bool local); - void saveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void loadXml(const AnsiString fileName, PathValueMap &values); - void saveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BResources.cpp b/engines/wintermute/base/BResources.cpp deleted file mode 100644 index 839be570c5..0000000000 --- a/engines/wintermute/base/BResources.cpp +++ /dev/null @@ -1,2820 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BResources.h" -#include "common/str.h" -#include "common/memstream.h" - -namespace WinterMute { - -unsigned char invalid[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} ; - -unsigned char invaliddebug[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, - 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, - 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, - 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, - 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, - 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, - 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, - 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, - 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, - 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, - 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, - 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, - 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, - 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, - 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, - 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, - 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, - 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, - 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, - 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, - 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, - 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, - 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, - 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, - 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, - 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, - 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, - 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, - 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, - 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, - 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, - 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, - 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, - 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, - 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, - 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, - 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, - 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, - 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, - 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, - 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, - 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, - 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, - 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, - 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, - 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, - 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, - 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, - 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, - 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, - 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, - 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, - 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, - 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, - 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, - 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, - 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, - 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 -} ; - -unsigned char systemfont[] = { - 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -} ; - -Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { - if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { - return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { - return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { - return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BResources.h b/engines/wintermute/base/BResources.h deleted file mode 100644 index 6ec0541b5c..0000000000 --- a/engines/wintermute/base/BResources.h +++ /dev/null @@ -1,44 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H - -#include "common/stream.h" -#include "common/str.h" - -namespace WinterMute { - -class CBResources { -public: - static Common::SeekableReadStream *getFile(const Common::String &fileName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSaveThumbHelper.cpp b/engines/wintermute/base/BSaveThumbHelper.cpp deleted file mode 100644 index 415d4ed1e4..0000000000 --- a/engines/wintermute/base/BSaveThumbHelper.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSaveThumbHelper.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { - delete _thumbnail; - _thumbnail = NULL; - - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - if (doFlip) { - // when using opengl on windows it seems to be necessary to do this twice - // works normally for direct3d - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - } - - CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) return STATUS_FAILED; - - // normal thumbnail - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new CBImage(_gameRef); - _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); - } - - - delete screenshot; - screenshot = NULL; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSaveThumbHelper.h b/engines/wintermute/base/BSaveThumbHelper.h deleted file mode 100644 index 30db32cfb2..0000000000 --- a/engines/wintermute/base/BSaveThumbHelper.h +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBImage; - -class CBSaveThumbHelper : public CBBase { -public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); - bool storeThumbnail(bool doFlip = false); - - CBImage *_thumbnail; - CBImage *_richThumbnail; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BScriptHolder.cpp b/engines/wintermute/base/BScriptHolder.cpp deleted file mode 100644 index 65d37b2e5c..0000000000 --- a/engines/wintermute/base/BScriptHolder.cpp +++ /dev/null @@ -1,473 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/ad/AdGame.h" -#include "engines/wintermute/base/BScriptHolder.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { - setName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::cleanup() { - delete[] _filename; - _filename = NULL; - - int i; - - for (i = 0; i < _scripts.getSize(); i++) { - _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) delete [] _filename; - - _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) strcpy(_filename, filename); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { - int numHandlers = 0; - - bool ret = STATUS_FAILED; - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); - if (handler) { - //_scripts.add(handler); - numHandlers++; - ret = STATUS_OK; - } - } - } - if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // DEBUG_CrashMe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "DEBUG_CrashMe") == 0) { - stack->correctParams(0); - byte *p = 0; - *p = 10; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ApplyEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ApplyEvent") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - bool ret; - ret = applyEvent(val->getString()); - - if (DID_SUCCEED(ret)) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleEvent") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleEvent(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleMethod - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleMethod") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleMethod(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AttachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AttachScript") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DetachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DetachScript") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool killThreads = stack->pop()->getBool(false); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - _scripts[i]->finish(killThreads); - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScriptRunning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScriptRunning") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("script_holder"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::scToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { - return CBBase::saveAsText(buffer, indent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_name)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); - return STATUS_OK; - } - } - } - - CScScript *scr = _gameRef->_scEngine->runScript(filename, this); - if (!scr) { - if (_gameRef->_editorForceScripts) { - // editor hack - scr = new CScScript(_gameRef, _gameRef->_scEngine); - scr->_filename = new char[strlen(filename) + 1]; - strcpy(scr->_filename, filename); - scr->_state = SCRIPT_ERROR; - scr->_owner = this; - _scripts.add(scr); - _gameRef->_scEngine->_scripts.add(scr); - _gameRef->getDebugMgr()->onScriptInit(scr); - - return STATUS_OK; - } - return STATUS_FAILED; - } else { - scr->_freezable = _freezable; - _scripts.add(scr); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::removeScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) { - _scripts.removeAt(i); - break; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; - } - return false; -} - - -TOKEN_DEF_START -TOKEN_DEF(PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - _gameRef->LOG(0, "'PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading PROPERTY definition"); - return STATUS_FAILED; - } - - - CScValue *val = new CScValue(_gameRef); - val->setString(propValue); - scSetProperty(propName, val); - - delete val; - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool freezable) { - _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->_freezable = freezable; - -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.getSize() - 1; i >= 0; i--) { - if (_scripts[i]->canHandleMethod(methodName)) { - - CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); - if (thread) { - bool ret = thread->createMethodThread(_scripts[i], methodName); - if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); - - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); - if (_name && strcmp(_name, "") != 0) { - strcat(buf, " Name: "); - strcat(buf, _name); - } - if (_filename) { - strcat(buf, " File: "); - strcat(buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *eventName) { - return DID_SUCCEED(applyEvent(eventName)); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptHolder.h b/engines/wintermute/base/BScriptHolder.h deleted file mode 100644 index 1e82b8cacf..0000000000 --- a/engines/wintermute/base/BScriptHolder.h +++ /dev/null @@ -1,74 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CBScriptHolder : public CBScriptable { -public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) - - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *methodName); - virtual void makeFreezable(bool freezable); - bool canHandleEvent(const char *eventName); - virtual bool canHandleMethod(const char *eventMethod); - bool cleanup(); - bool removeScript(CScScript *script); - bool addScript(const char *filename); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); - bool applyEvent(const char *eventName, bool unbreakable = false); - void setFilename(const char *filename); - bool parseProperty(byte *buffer, bool complete = true); - char *_filename; - bool _freezable; - bool _ready; - - CBArray _scripts; - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void scDebuggerDesc(char *buf, int bufSize); - // IWmeObject -public: - virtual bool sendEvent(const char *eventName); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BScriptable.cpp b/engines/wintermute/base/BScriptable.cpp deleted file mode 100644 index d1e3556a85..0000000000 --- a/engines/wintermute/base/BScriptable.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBScriptable, false) - -////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { - _refCount = 0; - - if (noValue) _scValue = NULL; - else _scValue = new CScValue(_gameRef); - - _persistable = persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { - //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); - delete _scValue; - delete _scProp; - _scValue = NULL; - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - /* - stack->correctParams(0); - stack->pushNULL(); - script->runtimeError("Call to undefined method '%s'.", name); - - return STATUS_OK; - */ - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->getProp(name); - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(_gameRef); - if (_scProp) return _scProp->setProp(name, value); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::scToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *CBScriptable::scToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double CBScriptable::scToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetString(const char *val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetInt(int val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetFloat(double val) { -} - - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetBool(bool val) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); - persistMgr->transfer(TMEMBER(_scProp)); - persistMgr->transfer(TMEMBER(_scValue)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *val) { - if (this < val) return -1; - else if (this > val) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool CBScriptable::canHandleMethod(const char *eventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::invokeMethodThread(const char *methodName) { - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::dbgGetNativeClass() { - return getClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { - return scGetProperty(name); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BScriptable.h b/engines/wintermute/base/BScriptable.h deleted file mode 100644 index 534bd3bdf1..0000000000 --- a/engines/wintermute/base/BScriptable.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H - - -#include "engines/wintermute/base/BNamedObject.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CScStack; -class CScScript; - -class CBScriptable : public CBNamedObject, public IWmeDebugObject { -public: - virtual CScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) - - CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); - virtual ~CBScriptable(); - - // high level scripting interface - virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void *scToMemBuffer(); - virtual int scToInt(); - virtual double scToFloat(); - virtual bool scToBool(); - virtual void scSetString(const char *val); - virtual void scSetInt(int val); - virtual void scSetFloat(double val); - virtual void scSetBool(bool val); - virtual int scCompare(CBScriptable *val); - virtual void scDebuggerDesc(char *buf, int bufSize); - int _refCount; - CScValue *_scValue; - CScValue *_scProp; - -public: - // IWmeDebugObject - const char *dbgGetNativeClass(); - IWmeDebugProp *dbgGetProperty(const char *name); - -}; - -// Implemented in their respective .cpp-files -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXMath(CBGame *inGame); -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXStore(CBGame *inGame); -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSound.cpp b/engines/wintermute/base/BSound.cpp deleted file mode 100644 index 2b54b39500..0000000000 --- a/engines/wintermute/base/BSound.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSoundBuffer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSound, false) - -////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { - _sound = NULL; - _soundFilename = NULL; - - _soundType = Audio::Mixer::kSFXSoundType; - _soundStreamed = false; - _soundLooping = false; - _soundPlaying = false; - _soundPaused = false; - _soundFreezePaused = false; - _soundPosition = 0; - _soundPrivateVolume = 0; - _soundLoopStart = 0; - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { - if (_sound) _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - } - delete[] _soundFilename; - _soundFilename = NULL; - - _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); - if (_sound) { - _soundFilename = new char[strlen(filename) + 1]; - strcpy(_soundFilename, filename); - - _soundType = type; - _soundStreamed = streamed; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setSoundSimple() { - _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); - if (_sound) { - if (_soundPosition) _sound->setPosition(_soundPosition); - _sound->setLooping(_soundLooping); - _sound->setPrivateVolume(_soundPrivateVolume); - _sound->setLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->resume(); - else return STATUS_OK; - } else return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getLength() { - if (_sound) return _sound->getLength(); - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::play(bool looping) { - if (_sound) { - _soundPaused = false; - return _sound->play(looping, _soundPosition); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::stop() { - if (_sound) { - _soundPaused = false; - return _sound->stop(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::pause(bool freezePaused) { - if (_sound) { - _soundPaused = true; - if (freezePaused) _sound->_freezePaused = true; - return _sound->pause(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->resume(); - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::persist(CBPersistMgr *persistMgr) { - if (persistMgr->_saving && _sound) { - _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) - _soundPosition = _sound->getPosition(); - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (persistMgr->_saving) { - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - } - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_soundFilename)); - persistMgr->transfer(TMEMBER(_soundLooping)); - persistMgr->transfer(TMEMBER(_soundPaused)); - persistMgr->transfer(TMEMBER(_soundFreezePaused)); - persistMgr->transfer(TMEMBER(_soundPlaying)); - persistMgr->transfer(TMEMBER(_soundPosition)); - persistMgr->transfer(TMEMBER(_soundPrivateVolume)); - persistMgr->transfer(TMEMBER(_soundStreamed)); - persistMgr->transfer(TMEMBER_INT(_soundType)); - persistMgr->transfer(TMEMBER(_soundLoopStart)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPlaying() { - return _sound && _sound->isPlaying(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::isPaused() { - return _sound && _soundPaused; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPositionTime(uint32 time) { - if (!_sound) return STATUS_FAILED; - _soundPosition = time; - bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) - _soundPosition = 0; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getPositionTime() { - if (!_sound) return 0; - - if (!_sound->isPlaying()) - return 0; - else return _sound->getPosition(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolumePercent(int percent) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(percent * 255 / 100); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->setPrivateVolume(volume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPrivateVolume(int volume) { - if (!_sound) - return STATUS_FAILED; - else return _sound->_privateVolume = volume; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolumePercent() { - if (!_sound) - return 0; - else return _sound->_privateVolume * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -int CBSound::getVolume() { - if (!_sound) - return 0; - else return _sound->_privateVolume; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setLoopStart(uint32 pos) { - if (!_sound) - return STATUS_FAILED; - else { - _sound->setLoopStart(pos); - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSound::setPan(float pan) { - if (_sound) - return _sound->setPan(pan); - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) - return STATUS_OK; - - if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - bool ret = _sound->applyFX(type, param1, param2, param3, param4); - - _sFXType = type; - _sFXParam1 = param1; - _sFXParam2 = param2; - _sFXParam3 = param3; - _sFXParam4 = param4; - - return ret; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSound.h b/engines/wintermute/base/BSound.h deleted file mode 100644 index 9dc825e4ac..0000000000 --- a/engines/wintermute/base/BSound.h +++ /dev/null @@ -1,88 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "audio/mixer.h" - -namespace WinterMute { - -class CBSoundBuffer; -class CBSound : public CBBase { -public: - bool setPan(float pan); - int _soundPrivateVolume; - int getVolume(); - int getVolumePercent(); - bool setVolumePercent(int percent); - bool setVolume(int volume); - bool setPrivateVolume(int volume); - bool setLoopStart(uint32 pos); - uint32 getPositionTime(); - bool setPositionTime(uint32 time); - bool _soundPaused; - bool _soundFreezePaused; - bool isPlaying(); - bool isPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) - bool resume(); - bool pause(bool freezePaused = false); - bool stop(); - bool play(bool looping = false); - uint32 getLength(); - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - char *_soundFilename; - bool setSoundSimple(); - bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); - - bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); - -private: - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - CBSoundBuffer *_sound; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSoundBuffer.cpp b/engines/wintermute/base/BSoundBuffer.cpp deleted file mode 100644 index 4808cc9007..0000000000 --- a/engines/wintermute/base/BSoundBuffer.cpp +++ /dev/null @@ -1,383 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BSoundBuffer.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/vorbis.h" -#include "audio/decoders/wave.h" -#include "audio/decoders/raw.h" -#include "common/system.h" -#include "common/substream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { - _stream = NULL; - _handle = NULL; -// _sync = NULL; - - _streamed = false; - _filename = NULL; - _file = NULL; - _privateVolume = 255; - _volume = 255; - - _looping = false; - _loopStart = 0; - - _type = Audio::Mixer::kSFXSoundType; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { - stop(); - - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - delete _stream; - _stream = NULL; - - delete[] _filename; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { - _streamed = Streamed; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif - - // Load a file, but avoid having the File-manager handle the disposal of it. - _file = _gameRef->_fileManager->openFile(filename, true, false); - if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - Common::String strFilename(filename); - if (strFilename.hasSuffix(".ogg")) { - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); - } else if (strFilename.hasSuffix(".wav")) { - int waveSize, waveRate; - byte waveFlags; - uint16 waveType; - - if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { - if (waveType == 1) { - // We need to wrap the file in a substream to make sure the size is right. - _file = new Common::SeekableSubReadStream(_file, 0, waveSize); - _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); - } else { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); - } - } - } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); - } - if (!_stream) { - return STATUS_FAILED; - } - CBUtils::setString(&_filename, filename); - - return STATUS_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return STATUS_FAILED; - } - - CBUtils::setString(&_filename, filename); - - /* - bool res; - bool NewlyCreated = false; - - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = _gameRef->_fileManager->openFile(filename); - if(!_file){ - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if(!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if(DID_FAIL(res)){ - _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); - return res; - } - } - - - - // store filename - if(!_filename){ - _filename = new char[strlen(filename)+1]; - strcpy(_filename, filename); - } - - // close file (if not streaming) - if(!_streamed && _file){ - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - */ - - return STATUS_OK; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::play(bool looping, uint32 startSample) { - if (startSample != 0) { - warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); - } - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - if (_stream) { - _stream->seek(startSample); - _handle = new Audio::SoundHandle; - if (looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); - g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); - } else { - g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); - _looping = looping; -#if 0 - - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::resume() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, false); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::stop() { - if (_stream && _handle) { - g_system->getMixer()->stopHandle(*_handle); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::pause() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, true); - } - return STATUS_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getLength() { - if (_stream) { - uint32 len = _stream->getLength().msecs(); - return len * 1000; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { - _type = type; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::updateVolume() { - setVolume(_privateVolume); -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setVolume(int volume) { - _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; - if (_stream && _handle) { - byte vol = (byte)(_volume); - g_system->getMixer()->setChannelVolume(*_handle, vol); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPrivateVolume(int volume) { - _privateVolume = volume; - return setVolume(_privateVolume); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::isPlaying() { - if (_stream && _handle) { - return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getPosition() { - if (_stream && _handle) { - uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); - return pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPosition(uint32 pos) { - warning("CBSoundBuffer::SetPosition - not implemented yet"); -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setLoopStart(uint32 pos) { - _loopStart = pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif - return STATUS_OK; -} -#if 0 -////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPan(float pan) { - if (_handle) { - g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("CBSoundBuffer::ApplyFX - not implemented yet"); - switch (type) { - case SFX_ECHO: - break; - - case SFX_REVERB: - break; - - default: - break; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundBuffer.h b/engines/wintermute/base/BSoundBuffer.h deleted file mode 100644 index 9384670fbb..0000000000 --- a/engines/wintermute/base/BSoundBuffer.h +++ /dev/null @@ -1,100 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H - - -#include "engines/wintermute/base/BBase.h" -#include "audio/mixer.h" -#include "common/stream.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace WinterMute { - -class CBFile; -class CBSoundBuffer : public CBBase { -public: - - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); - - - bool pause(); - bool play(bool looping = false, uint32 startSample = 0); - bool resume(); - bool stop(); - bool isPlaying(); - - void setLooping(bool looping); - - uint32 getPosition(); - bool setPosition(uint32 pos); - uint32 getLength(); - - bool setLoopStart(uint32 pos); - uint32 getLoopStart() const { - return _loopStart; - } - - bool setPan(float pan); - bool setPrivateVolume(int colume); - bool setVolume(int colume); - void updateVolume(); - - void setType(Audio::Mixer::SoundType Type); - - bool loadFromFile(const char *filename, bool forceReload = false); - void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; - bool _looping; - Common::SeekableReadStream *_file; - char *_filename; - bool _streamed; - - int _privateVolume; -private: - int _volume; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSoundMgr.cpp b/engines/wintermute/base/BSoundMgr.cpp deleted file mode 100644 index 66baa633e4..0000000000 --- a/engines/wintermute/base/BSoundMgr.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSoundMgr.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BSoundBuffer.h" -#include "engines/wintermute/wintermute.h" -#include "common/config-manager.h" -#include "audio/mixer.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { - _soundAvailable = false; - _volumeMaster = 255; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) - delete _sounds[i]; - _sounds.clear(); -#if 0 - BASS_Free(); -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { - if (_soundAvailable) { - _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); - } -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initialize() { - _soundAvailable = false; - - if (!g_system->getMixer()->isReady()) { - return STATUS_FAILED; - } - _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); - _soundAvailable = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initLoop() { - if (!_soundAvailable) - return STATUS_OK; -#if 0 - - BASS_Update(500); -#endif - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) - return NULL; - - CBSoundBuffer *sound; - - // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::compareNoCase(ext, "wav")) { - AnsiString path = PathUtil::getDirectoryName(filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(filename); - - AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (_gameRef->_fileManager->hasFile(newFile)) { - filename = newFile.c_str(); - } - } - - sound = new CBSoundBuffer(_gameRef); - if (!sound) return NULL; - - sound->setStreaming(streamed); - sound->setType(type); - - - bool res = sound->loadFromFile(filename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", filename); - delete sound; - return NULL; - } - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return sound; - - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) - return STATUS_FAILED; - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i] == sound) { - delete _sounds[i]; - _sounds.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) - return STATUS_OK; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - ConfMan.setInt("sfx_volume", volume); - break; - case Audio::Mixer::kSpeechSoundType: - ConfMan.setInt("speech_volume", volume); - break; - case Audio::Mixer::kMusicSoundType: - ConfMan.setInt("music_volume", volume); - break; - case Audio::Mixer::kPlainSoundType: - error("Plain sound type shouldn't be used in WME"); - } - g_wintermute->syncSoundSettings(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { - return setVolume(type, percent * 255 / 100); -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { - int volume = 0; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - case Audio::Mixer::kSpeechSoundType: - case Audio::Mixer::kMusicSoundType: - volume = g_system->getMixer()->getVolumeForSoundType(type); - break; - default: - error("Sound-type not set"); - break; - } - - return (byte)(volume * 100 / 255); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolume(byte value) { - _volumeMaster = value; - for (uint32 i = 0; i < _sounds.size(); i++) { - _sounds[i]->updateVolume(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolumePercent(byte percent) { - setMasterVolume(percent * 255 / 100); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { - return getMasterVolume() * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolume() { - return (byte)_volumeMaster; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::pauseAll(bool includingMusic) { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { - _sounds[i]->pause(); - _sounds[i]->_freezePaused = true; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::resumeAll() { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int x, int y) { - float relPos = (float)x / ((float)_gameRef->_renderer->_width); - - float minPan = -0.7f; - float maxPan = 0.7f; - - return minPan + relPos * (maxPan - minPan); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSoundMgr.h b/engines/wintermute/base/BSoundMgr.h deleted file mode 100644 index a021abadaa..0000000000 --- a/engines/wintermute/base/BSoundMgr.h +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" -#include "audio/mixer.h" -#include "common/array.h" - -namespace WinterMute { -class CBSoundBuffer; -class CBSoundMgr : public CBBase { -public: - float posToPan(int x, int y); - bool resumeAll(); - bool pauseAll(bool includingMusic = true); - bool cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); - byte getMasterVolumePercent(); - byte getMasterVolume(); - bool setMasterVolume(byte percent); - bool setMasterVolumePercent(byte percent); - byte getVolumePercent(Audio::Mixer::SoundType type); - bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); - bool setVolume(Audio::Mixer::SoundType type, int volume); - uint32 _volumeOriginal; - int _volumeMaster; - bool removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initLoop(); - bool initialize(); - bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - Common::Array _sounds; - void saveSettings(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSprite.cpp b/engines/wintermute/base/BSprite.cpp deleted file mode 100644 index c4dfaa3f8d..0000000000 --- a/engines/wintermute/base/BSprite.cpp +++ /dev/null @@ -1,758 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSprite, false) - -////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::setDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - _filename = NULL; - _finished = false; - _changed = false; - _paused = false; - _continuous = false; - _moveX = _moveY = 0; - - _editorMuted = false; - _editorBgFile = NULL; - _editorBgOffsetX = _editorBgOffsetY = 0; - _editorBgAlpha = 0xFF; - _streamed = false; - _streamedKeepLoaded = false; - - setName(""); - - _precise = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSprite::cleanup() { - CBScriptHolder::cleanup(); - - for (int i = 0; i < _frames.getSize(); i++) - delete _frames[i]; - _frames.removeAll(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // move owner if allowed to - if (_changed && _owner && _owner->_movable) { - _owner->_posX += _moveX; - _owner->_posY += _moveY; - _owner->afterMove(); - - x = _owner->_posX; - y = _owner->_posY; - } - - // draw frame - return display(x, y, registerOwner, zoomX, zoomY, alpha); -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); - if (!file) { - _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); - else return loadFile("invalid.bmp", lifeTime, cacheType); - } else { - _gameRef->_fileManager->closeFile(file); - file = NULL; - } - - bool ret; - - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(_gameRef); - CBSubFrame *subframe = new CBSubFrame(_gameRef); - subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); - ret = STATUS_FAILED; - delete frame; - delete subframe; - } else { - CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); - frame->_subframes.add(subframe); - _frames.add(frame); - _currentFrame = 0; - ret = STATUS_OK; - } - } else { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] buffer; - } - } - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - - return ret; -} - - - -TOKEN_DEF_START -TOKEN_DEF(CONTINUOUS) -TOKEN_DEF(SPRITE) -TOKEN_DEF(LOOPING) -TOKEN_DEF(FRAME) -TOKEN_DEF(NAME) -TOKEN_DEF(PRECISE) -TOKEN_DEF(EDITOR_MUTED) -TOKEN_DEF(STREAMED_KEEP_LOADED) -TOKEN_DEF(STREAMED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_BG_FILE) -TOKEN_DEF(EDITOR_BG_OFFSET_X) -TOKEN_DEF(EDITOR_BG_OFFSET_Y) -TOKEN_DEF(EDITOR_BG_ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(CONTINUOUS) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(LOOPING) - TOKEN_TABLE(FRAME) - TOKEN_TABLE(NAME) - TOKEN_TABLE(PRECISE) - TOKEN_TABLE(EDITOR_MUTED) - TOKEN_TABLE(STREAMED_KEEP_LOADED) - TOKEN_TABLE(STREAMED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_BG_FILE) - TOKEN_TABLE(EDITOR_BG_OFFSET_X) - TOKEN_TABLE(EDITOR_BG_OFFSET_Y) - TOKEN_TABLE(EDITOR_BG_ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - CBParser parser(_gameRef); - - cleanup(); - - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - _gameRef->LOG(0, "'SPRITE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int frameCount = 1; - CBFrame *frame; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_CONTINUOUS: - parser.scanStr((char *)params, "%b", &_continuous); - break; - - case TOKEN_EDITOR_MUTED: - parser.scanStr((char *)params, "%b", &_editorMuted); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_LOOPING: - parser.scanStr((char *)params, "%b", &_looping); - break; - - case TOKEN_PRECISE: - parser.scanStr((char *)params, "%b", &_precise); - break; - - case TOKEN_STREAMED: - parser.scanStr((char *)params, "%b", &_streamed); - if (_streamed && lifeTime == -1) { - lifeTime = 500; - cacheType = CACHE_ALL; - } - break; - - case TOKEN_STREAMED_KEEP_LOADED: - parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_EDITOR_BG_FILE: - if (_gameRef->_editorMode) { - delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); - } - break; - - case TOKEN_EDITOR_BG_OFFSET_X: - parser.scanStr((char *)params, "%d", &_editorBgOffsetX); - break; - - case TOKEN_EDITOR_BG_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_editorBgOffsetY); - break; - - case TOKEN_EDITOR_BG_ALPHA: - parser.scanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = MIN(_editorBgAlpha, 255); - _editorBgAlpha = MAX(_editorBgAlpha, 0); - break; - - case TOKEN_FRAME: { - int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - - frame = new CBFrame(_gameRef); - - if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { - delete frame; - _gameRef->LOG(0, "Error parsing frame %d", frameCount); - return STATUS_FAILED; - } - - _frames.add(frame); - frameCount++; - if (_currentFrame == -1) _currentFrame = 0; - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITE definition"); - return STATUS_FAILED; - } - _canBreak = !_continuous; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CBSprite::reset() { - if (_frames.getSize() > 0) _currentFrame = 0; - else _currentFrame = -1; - - killAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - - if (_currentFrame == -1) return false; - - uint32 timer; - if (_owner && _owner->_freezable) timer = _gameRef->_timer; - else timer = _gameRef->_liveTimer; - - int lastFrame = _currentFrame; - - // get current frame - if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.getSize() - 1) { - _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); - } - - if (_changed) { - _moveX = _frames[_currentFrame]->_moveX; - _moveY = _frames[_currentFrame]->_moveY; - - if (zoomX != 100 || zoomY != 100) { - _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); - } - } - - return _changed; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; - - // on change... - if (_changed) { - if (_frames[_currentFrame]->_killSound) { - killAllSounds(); - } - applyEvent("FrameChanged"); - _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); - } - - // draw frame - return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); -} - - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::getSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.getSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - CBPlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.getSize(); i++) { - Rect32 frame; - Rect32 temp; - CBPlatform::copyRect(&temp, rect); - _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); - buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); - if (_streamed) { - buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - - if (_streamedKeepLoaded) - buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); - } - - if (_editorMuted) - buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - - if (_editorBgFile) { - buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); - } - - CBScriptHolder::saveAsText(buffer, indent + 2); - - int i; - - // scripts - for (i = 0; i < _scripts.getSize(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - - for (i = 0; i < _frames.getSize(); i++) { - _frames[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_canBreak)); - persistMgr->transfer(TMEMBER(_changed)); - persistMgr->transfer(TMEMBER(_paused)); - persistMgr->transfer(TMEMBER(_continuous)); - persistMgr->transfer(TMEMBER(_currentFrame)); - persistMgr->transfer(TMEMBER(_editorAllFrames)); - persistMgr->transfer(TMEMBER(_editorBgAlpha)); - persistMgr->transfer(TMEMBER(_editorBgFile)); - persistMgr->transfer(TMEMBER(_editorBgOffsetX)); - persistMgr->transfer(TMEMBER(_editorBgOffsetY)); - persistMgr->transfer(TMEMBER(_editorMuted)); - persistMgr->transfer(TMEMBER(_finished)); - - _frames.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_lastFrameTime)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_precise)); - persistMgr->transfer(TMEMBER(_streamed)); - persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetFrame") == 0) { - stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); - stack->pushNULL(); - } else stack->pushNative(_frames[Index], true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteFrame") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); - } - } else { - CBFrame *Frame = (CBFrame *)Val->getNative(); - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; - delete _frames[i]; - _frames.removeAt(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddFrame") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) { - sub->setDefaultRect(); - frame->_subframes.add(sub); - } else delete sub; - } - _frames.add(frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertFrame") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) - index = 0; - - CScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) - filename = val->getString(); - - CBFrame *frame = new CBFrame(_gameRef); - if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); - else delete sub; - } - - if (index >= _frames.getSize()) - _frames.add(frame); - else _frames.insertAt(index, frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _paused = true; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Play - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Play") == 0) { - stack->correctParams(0); - _paused = false; - stack->pushNULL(); - return STATUS_OK; - } - - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("sprite"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFrames (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.getSize()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { - _scValue->setInt(_currentFrame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_precise); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _scValue->setBool(_looping); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Owner (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->setNULL(); - else _scValue->setNative(_owner, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Finished (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { - _scValue->setBool(_finished); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Paused (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { - _scValue->setBool(_paused); - return _scValue; - } - - else return CBScriptHolder::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { - _currentFrame = -1; - } - _lastFrameTime = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _precise = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _looping = value->getBool(); - return STATUS_OK; - } - - else return CBScriptHolder::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSprite::scToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSprite::killAllSounds() { - for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i]->_sound) - _frames[i]->_sound->stop(); - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSprite.h b/engines/wintermute/base/BSprite.h deleted file mode 100644 index 3c67e5f3fe..0000000000 --- a/engines/wintermute/base/BSprite.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BScriptHolder.h" - -namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { -public: - bool killAllSounds(); - CBSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void cleanup(); - void setDefaults(); - bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) - - bool _editorAllFrames; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - int _moveY; - int _moveX; - bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; - void reset(); - CBObject *_owner; - bool _changed; - bool _paused; - bool _finished; - bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; - bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); - bool _looping; - int _currentFrame; - bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - CBSprite(CBGame *inGame, CBObject *owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - bool saveAsText(CBDynBuffer *buffer, int indent); - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BStringTable.cpp b/engines/wintermute/base/BStringTable.cpp deleted file mode 100644 index 470ae8549c..0000000000 --- a/engines/wintermute/base/BStringTable.cpp +++ /dev/null @@ -1,229 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BStringTable.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return STATUS_FAILED; - - if (scumm_stricmp(key, "@right-to-left") == 0) { - _gameRef->_textRTL = true; - return STATUS_OK; - } - - Common::String finalKey = key; - finalKey.toLowercase(); - - _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); - - _strings[finalKey] = val; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -char *CBStringTable::getKey(const char *str) { - if (str == NULL || str[0] != '/') return NULL; - - const char *value = strchr(str + 1, '/'); - if (value == NULL) return NULL; - - char *key = new char[value - str]; - strncpy(key, str + 1, value - str - 1); - key[value - str - 1] = '\0'; - CBPlatform::strlwr(key); - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = getKey(new_str); - delete [] new_str; - return Ret; - } else { - delete [] new_str; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBStringTable::expand(char **str, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return; - - if (str == NULL || *str == NULL || *str[0] != '/') return; - - char *value = strchr(*str + 1, '/'); - if (value == NULL) return; - - char *key = new char[value - *str]; - strncpy(key, *str + 1, value - *str - 1); - key[value - *str - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); - } - - delete [] key; - delete [] *str; - *str = new_str; - - if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return string; - - if (string == NULL || string[0] == '\0' || string[0] != '/') return string; - - const char *value = strchr(string + 1, '/'); - if (value == NULL) return string; - - char *key = new char[value - string]; - strncpy(key, string + 1, value - string - 1); - key[value - string - 1] = '\0'; - CBPlatform::strlwr(key); - - value++; - - const char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); - } else { - new_str = value; - } - - delete [] key; - - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); - else return new_str; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBStringTable::loadFile(const char *filename, bool clearOld) { - _gameRef->LOG(0, "Loading string table..."); - - if (clearOld) _strings.clear(); - - uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (buffer == NULL) { - _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - uint32 pos = 0; - - if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - pos += 3; - if (_gameRef->_textEncoding != TEXT_UTF8) { - _gameRef->_textEncoding = TEXT_UTF8; - //_gameRef->_textEncoding = TEXT_ANSI; - _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); - } - } else _gameRef->_textEncoding = TEXT_ANSI; - - uint32 lineLength = 0; - while (pos < size) { - lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; - - uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); - char *line = new char[realLength + 1]; - strncpy(line, (char *)&buffer[pos], realLength); - line[realLength] = '\0'; - char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); - - if (line[0] != ';') { - if (value != NULL) { - value[0] = '\0'; - value++; - for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; - } - addString(line, value, clearOld); - } else if (line[0] != '\0') addString(line, "", clearOld); - } - - delete [] line; - pos += lineLength + 1; - } - - delete [] buffer; - - _gameRef->LOG(0, " %d strings loaded", _strings.size()); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BStringTable.h b/engines/wintermute/base/BStringTable.h deleted file mode 100644 index 92d3604b4d..0000000000 --- a/engines/wintermute/base/BStringTable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H - - -#include "common/hashmap.h" -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBStringTable : public CBBase { -public: - const char *expandStatic(const char *string, bool forceExpand = false); - bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str, bool forceExpand = false); - bool addString(const char *key, const char *val, bool reportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); - Common::HashMap _strings; - char *getKey(const char *str); -private: - Common::HashMap::iterator _stringsIter; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSubFrame.cpp b/engines/wintermute/base/BSubFrame.cpp deleted file mode 100644 index 858f2125c6..0000000000 --- a/engines/wintermute/base/BSubFrame.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BActiveRect.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - CBPlatform::setRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; -} - - -TOKEN_DEF_START -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(DECORATION) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custoTrans = false; - CBPlatform::setRectEmpty(&rect); - char *surfaceFile = NULL; - - delete _surface; - _surface = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &_2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &_3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &_mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &_mirrorY); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &_decoration); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); - return STATUS_FAILED; - } - - if (surfaceFile != NULL) { - if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); - } - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); - - /* - if(_surface == NULL) - { - _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); - return STATUS_FAILED; - } - */ - if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); - else _rect = rect; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return STATUS_OK; - - if (registerOwner != NULL && !_decoration) { - if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); - } else { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); - } - } - if (_gameRef->_suspendedRendering) return STATUS_OK; - - bool res; - - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) alpha = _alpha; - - if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); - } else { - if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; - - float ratioX = scaleX / 100.0f; - float ratioY = scaleY / 100.0f; - - CBPlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { - if (complete) - buffer->putTextIndent(indent, "SUBFRAME {\n"); - - if (_surface && _surface->getFileNameStr() != "") - buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); - - if (_transparent != 0xFFFF00FF) - buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - - Rect32 rect; - CBPlatform::setRectEmpty(&rect); - if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::equalRect(&rect, &_rect)) - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); - - if (_hotspotX != 0 || _hotspotY != 0) - buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - - if (_alpha != 0xFFFFFFFF) { - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - } - - if (_mirrorX) - buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - - if (_mirrorY) - buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - - if (_2DOnly) - buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - - if (_3DOnly) - buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - - if (_decoration) - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - - if (_editorSelected) - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - - CBBase::saveAsText(buffer, indent + 2); - - - if (complete) - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBSubFrame::setDefaultRect() { - if (_surface) { - CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_2DOnly)); - persistMgr->transfer(TMEMBER(_3DOnly)); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_hotspotX)); - persistMgr->transfer(TMEMBER(_hotspotY)); - persistMgr->transfer(TMEMBER(_rect)); - - persistMgr->transfer(TMEMBER(_surfaceFilename)); - persistMgr->transfer(TMEMBER(_cKDefault)); - persistMgr->transfer(TMEMBER(_cKRed)); - persistMgr->transfer(TMEMBER(_cKGreen)); - persistMgr->transfer(TMEMBER(_cKBlue)); - persistMgr->transfer(TMEMBER(_lifeTime)); - - persistMgr->transfer(TMEMBER(_keepLoaded)); - persistMgr->transfer(TMEMBER(_mirrorX)); - persistMgr->transfer(TMEMBER(_mirrorY)); - persistMgr->transfer(TMEMBER(_transparent)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - - if (!_surfaceFilename) stack->pushNULL(); - else stack->pushString(_surfaceFilename); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - if (Val->isNULL()) { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); - delete[] _surfaceFilename; - _surfaceFilename = NULL; - stack->pushBool(true); - } else { - const char *filename = Val->getString(); - if (DID_SUCCEED(setSurface(filename))) { - setDefaultRect(); - stack->pushBool(true); - } else stack->pushBool(false); - } - - return STATUS_OK; - } - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("subframe"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - - _scValue->setInt((int)_alpha); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TransparentColor (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { - _scValue->setInt((int)_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _scValue->setBool(_2DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _scValue->setBool(_3DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _scValue->setBool(_mirrorX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _scValue->setBool(_mirrorY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _scValue->setInt(_hotspotX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _scValue->setInt(_hotspotY); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = value->getInt(); - return STATUS_OK; - } - - else return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::scToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - _surface = NULL; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - if (_surface) { - _surfaceFilename = new char[strlen(filename) + 1]; - strcpy(_surfaceFilename, filename); - - _cKDefault = defaultCK; - _cKRed = ckRed; - _cKGreen = ckGreen; - _cKBlue = ckBlue; - _lifeTime = lifeTime; - _keepLoaded = keepLoaded; - - return STATUS_OK; - } else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurfaceSimple() { - if (!_surfaceFilename) { - _surface = NULL; - return STATUS_OK; - } - _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return STATUS_OK; - else return STATUS_FAILED; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSubFrame.h b/engines/wintermute/base/BSubFrame.h deleted file mode 100644 index 57ffcae675..0000000000 --- a/engines/wintermute/base/BSubFrame.h +++ /dev/null @@ -1,86 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool setSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) - void setDefaultRect(); - uint32 _transparent; - bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); - bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - - int _hotspotX; - int _hotspotY; - uint32 _alpha; - Rect32 _rect; - - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - CBSurface *_surface; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BSurfaceStorage.cpp b/engines/wintermute/base/BSurfaceStorage.cpp deleted file mode 100644 index 406535cf39..0000000000 --- a/engines/wintermute/base/BSurfaceStorage.cpp +++ /dev/null @@ -1,189 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BSurfaceStorage.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { - cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::cleanup(bool warn) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); - delete _surfaces[i]; - } - _surfaces.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::initLoop() { - if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { - _lastCleanupTime = _gameRef->_liveTimer; - sortSurfaces(); - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; - - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { - //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->invalidate(); - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::removeSurface(CBSurface *surface) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i] == surface) { - _surfaces[i]->_referenceCount--; - if (_surfaces[i]->_referenceCount <= 0) { - delete _surfaces[i]; - _surfaces.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_debugDebugMode) - return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - else - return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } - - CBSurface *surface; - surface = _gameRef->_renderer->createSurface(); - - if (!surface) return NULL; - - if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { - delete surface; - return NULL; - } else { - surface->_referenceCount = 1; - _surfaces.push_back(surface); - return surface; - } -} - - -////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::restoreAll() { - bool ret; - for (uint32 i = 0; i < _surfaces.size(); i++) { - ret = _surfaces[i]->restore(); - if (ret != STATUS_OK) { - _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return STATUS_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) -{ - - if(!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - - //_surfaces.persist(persistMgr); - - return STATUS_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); - - // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; - - - // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; - - // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BSurfaceStorage.h b/engines/wintermute/base/BSurfaceStorage.h deleted file mode 100644 index c054c2a55b..0000000000 --- a/engines/wintermute/base/BSurfaceStorage.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H - -#include "engines/wintermute/base/BBase.h" -#include "common/array.h" - -namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { -public: - uint32 _lastCleanupTime; - bool initLoop(); - bool sortSurfaces(); - static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); - - bool restoreAll(); - CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); - - Common::Array _surfaces; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BTransitionMgr.cpp b/engines/wintermute/base/BTransitionMgr.cpp deleted file mode 100644 index 1cea7285bf..0000000000 --- a/engines/wintermute/base/BTransitionMgr.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BTransitionMgr.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::isReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return STATUS_OK; - - if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { - _state = TRANS_MGR_READY; - return STATUS_OK; - } - - if (nonInteractive) { - _preserveInteractive = true; - _origInteractive = _gameRef->_interactive; - _gameRef->_interactive = false; - } /*else _preserveInteractive */; - - - _type = type; - _state = TRANS_MGR_RUNNING; - _started = false; - - return STATUS_OK; -} - -#define FADE_DURATION 200 - -////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::update() { - if (isReady()) return STATUS_OK; - - if (!_started) { - _started = true; - _lastTime = CBPlatform::getTime(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - - case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::getTime() - _lastTime; - int alpha = (int)((float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) - _state = TRANS_MGR_READY; - } - break; - default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (isReady()) { - if (_preserveInteractive) - _gameRef->_interactive = _origInteractive; - } - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BTransitionMgr.h b/engines/wintermute/base/BTransitionMgr.h deleted file mode 100644 index faedb6fe3e..0000000000 --- a/engines/wintermute/base/BTransitionMgr.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBTransitionMgr : public CBBase { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - bool update(); - bool start(TTransitionType type, bool nonInteractive = false); - bool isReady(); - TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/BViewport.cpp b/engines/wintermute/base/BViewport.cpp deleted file mode 100644 index 2b237a0d38..0000000000 --- a/engines/wintermute/base/BViewport.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BViewport.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBViewport, false) - -////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_mainObject)); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_rect)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { - if (!noCheck) { - left = MAX(left, 0); - top = MAX(top, 0); - right = MIN(right, _gameRef->_renderer->_width); - bottom = MIN(bottom, _gameRef->_renderer->_height); - } - - CBPlatform::setRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -Rect32 *CBViewport::getRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int CBViewport::getHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/BViewport.h b/engines/wintermute/base/BViewport.h deleted file mode 100644 index 1150b8ebe7..0000000000 --- a/engines/wintermute/base/BViewport.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { -public: - int getHeight(); - int getWidth(); - Rect32 *getRect(); - bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) - int _offsetY; - int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); -private: - Rect32 _rect; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp new file mode 100644 index 0000000000..5fabe94312 --- /dev/null +++ b/engines/wintermute/base/base.cpp @@ -0,0 +1,178 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBBase::CBBase(CBGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +CBBase::CBBase() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +CBBase::~CBBase() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBBase::getEditorProp(const char *propName, const char *initVal) { + _editorPropsIter = _editorProps.find(propName); + if (_editorPropsIter != _editorProps.end()) + return _editorPropsIter->_value.c_str(); + //return _editorPropsIter->second.c_str(); // <- TODO Clean + else return initVal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::setEditorProp(const char *propName, const char *propValue) { + if (propName == NULL) return STATUS_FAILED; + + if (propValue == NULL) { + _editorProps.erase(propName); + } else { + _editorProps[propName] = propValue; + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBBase::parseEditorProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!_gameRef->_editorMode) + return STATUS_OK; + + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + + + setEditorProp(propName, propValue); + + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove + //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove + buffer->putTextIndent(indent, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h new file mode 100644 index 0000000000..e8c87f1f9e --- /dev/null +++ b/engines/wintermute/base/base.h @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BBASE_H +#define WINTERMUTE_BBASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace WinterMute { + +class CBGame; +class CBDynBuffer; + +class CBBase { +public: + bool _persistable; + bool setEditorProp(const char *propName, const char *propValue); + const char *getEditorProp(const char *propName, const char *initVal = NULL); + CBBase(TDynamicConstructor, TDynamicConstructor) {}; + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); + CBBase(); + CBGame *_gameRef; + CBBase(CBGame *GameOwner); + virtual ~CBBase(); + + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; + /* std::map _editorProps; + std::map::iterator _editorPropsIter;*/ +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp new file mode 100644 index 0000000000..5895b1acd5 --- /dev/null +++ b/engines/wintermute/base/base_active_rect.cpp @@ -0,0 +1,107 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { + _owner = owner; + _frame = frame; + CBPlatform::setRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { + _owner = owner; + _region = region; + CBPlatform::copyRect(&_rect, ®ion->_rect); + CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +CBActiveRect::~CBActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + CBRenderer *Rend = _gameRef->_renderer; + + if (!customViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; + if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + + CBPlatform::intersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h new file mode 100644 index 0000000000..7c9e8d4a39 --- /dev/null +++ b/engines/wintermute/base/base_active_rect.h @@ -0,0 +1,60 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BACTIVERECT_H +#define WINTERMUTE_BACTIVERECT_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CBRegion; +class CBSubFrame; +class CBObject; +class CBActiveRect: CBBase { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + CBSubFrame *_frame; + CBObject *_owner; + CBRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + CBActiveRect(CBGame *inGameOwner = NULL); + CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); + virtual ~CBActiveRect(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp new file mode 100644 index 0000000000..f56f08dab2 --- /dev/null +++ b/engines/wintermute/base/base_debugger.cpp @@ -0,0 +1,203 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_Debugger.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { + _enabled = false; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger::~CBDebugger(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::initialize() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::shutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameInit() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameShutdown() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onGameTick() { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onLog(unsigned int errorCode, const char *text) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptInit(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugServer interface implementation +bool CBDebugger::attachClient(IWmeDebugClient *client) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::detachClient(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::queryData(IWmeDebugClient *client) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +int CBDebugger::getPropInt(const char *propName) { + return 0; +} + +////////////////////////////////////////////////////////////////////////// +double CBDebugger::getPropFloat(const char *propName) { + return 0.0; +} + +////////////////////////////////////////////////////////////////////////// +const char *CBDebugger::getPropString(const char *propName) { + return ""; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::getPropBool(const char *propName) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, int propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, double propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, const char *propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::setProp(const char *propName, bool propValue) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBDebugger::continueExecution() { + return false; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h new file mode 100644 index 0000000000..35ea56eafe --- /dev/null +++ b/engines/wintermute/base/base_debugger.h @@ -0,0 +1,95 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDEBUGGER_H +#define WINTERMUTE_BDEBUGGER_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/wme_debugger.h" + +// TODO: The entire debugger should possibly be removed + +namespace WinterMute { +class CScScript; +class CScValue; +class CBDebugger : public CBBase, public IWmeDebugServer { +public: + CBDebugger(CBGame *inGame); + virtual ~CBDebugger(void); + + // initialization + bool _enabled; + bool initialize(); + bool shutdown(); + + // internal interface + bool onGameInit(); + bool onGameShutdown(); + bool onGameTick(); + bool onLog(unsigned int errorCode, const char *text); + bool onScriptInit(CScScript *script); + bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); + + bool onScriptShutdown(CScScript *script); + bool onScriptChangeLine(CScScript *script, int line); + bool onScriptChangeScope(CScScript *script, CScValue *scope); + bool onScriptShutdownScope(CScScript *script, CScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); + bool onVariableChangeValue(CScValue *var, CScValue *value); + + bool onScriptHitBreakpoint(CScScript *script); + + // IWmeDebugServer interface + virtual bool attachClient(IWmeDebugClient *client); + virtual bool detachClient(IWmeDebugClient *client); + virtual bool queryData(IWmeDebugClient *client); + + virtual int getPropInt(const char *propName); + virtual double getPropFloat(const char *propName); + virtual const char *getPropString(const char *propName); + virtual bool getPropBool(const char *propName); + + virtual bool setProp(const char *propName, int propValue); + virtual bool setProp(const char *propName, double propValue); + virtual bool setProp(const char *propName, const char *propValue); + virtual bool setProp(const char *propName, bool propValue); + + virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); + + virtual bool addBreakpoint(const char *scriptFilename, int line); + virtual bool removeBreakpoint(const char *scriptFilename, int line); + + virtual bool continueExecution(); +private: +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp new file mode 100644 index 0000000000..7453838219 --- /dev/null +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -0,0 +1,192 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBDynBuffer::~CBDynBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::cleanup() { + if (_buffer) free(_buffer); + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) initSize = _initSize; + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) init(); + + if (_offset + size > _size) { + _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBDynBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putString(const char *val) { + if (!val) putString("(null)"); + else { + putDWORD(strlen(val) + 1); + putBytes((byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBDynBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) return NULL; + else return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void CBDynBuffer::putTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + putBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h new file mode 100644 index 0000000000..5795fe5bd1 --- /dev/null +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDYNBUFFER_H +#define WINTERMUTE_BDYNBUFFER_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBDynBuffer : public CBBase { +public: + bool _initialized; + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~CBDynBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void putTextForm(const char *format, va_list argptr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp new file mode 100644 index 0000000000..712f64eb6f --- /dev/null +++ b/engines/wintermute/base/base_fader.cpp @@ -0,0 +1,176 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/util.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFader, false) + +////////////////////////////////////////////////////////////////////////// +CBFader::CBFader(CBGame *inGame): CBObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBFader::~CBFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::update() { + if (!_active) return STATUS_OK; + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) time = CBPlatform::getTime() - _startTime; + else time = _gameRef->_timer - _startTime; + + if (time >= _duration) _currentAlpha = _targetAlpha; + else { + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) _active = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::display() { + if (!_active) return STATUS_OK; + + if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); + + _sourceAlpha = RGBCOLGetA(sourceColor); + _targetAlpha = 0; + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = RGBCOLGetA(targetColor); + + _duration = duration; + _system = system; + + if (_system) _startTime = CBPlatform::getTime(); + else _startTime = _gameRef->_timer; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFader::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->_saving) _startTime = 0; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h new file mode 100644 index 0000000000..679f5d0903 --- /dev/null +++ b/engines/wintermute/base/base_fader.h @@ -0,0 +1,62 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFADER_H +#define WINTERMUTE_BFADER_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CBFader : public CBObject { +public: + bool _system; + uint32 getCurrentColor(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); + DECLARE_PERSISTENT(CBFader, CBObject) + CBFader(CBGame *inGame); + virtual ~CBFader(); + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp new file mode 100644 index 0000000000..1cb0464a1f --- /dev/null +++ b/engines/wintermute/base/base_file_manager.cpp @@ -0,0 +1,737 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/base_resources.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "common/str.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/savefile.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { + _basePath = NULL; + + initPaths(); + registerPackages(); +} + + +////////////////////////////////////////////////////////////////////// +CBFileManager::~CBFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::cleanup() { + // delete registered paths + for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + + // delete file entries + _filesIter = _files.begin(); + while (_filesIter != _files.end()) { + delete _filesIter->_value; + _filesIter++; + } + _files.clear(); + + // close open files + for (uint32 i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + + // delete packages + for (uint32 i = 0; i < _packages.size(); i++) + delete _packages[i]; + _packages.clear(); + + delete[] _basePath; + _basePath = NULL; + + return STATUS_OK; +} + + + +#define MAX_FILE_SIZE 10000000 +////////////////////////////////////////////////////////////////////// +byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + return NULL; + } + + /* + if (File->GetSize() > MAX_FILE_SIZE) { + _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); + CloseFile(File); + return NULL; + } + */ + + + buffer = new byte[file->size() + 1]; + if (buffer == NULL) { + _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + closeFile(file); + delete [] buffer; + return NULL; + }; + + buffer[file->size()] = '\0'; + if (size != NULL) *size = file->size(); + closeFile(file); + + return buffer; +} + +Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::InSaveFile *file = saveMan->openForLoading(filename); + return file; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { + // TODO + warning("Implement SaveFile"); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + file->finalize(); + delete file; +#if 0 + RestoreCurrentDir(); + + CBUtils::CreatePath(filename, false); + + FILE *f = fopen(filename, "wb"); + if (!f) { + _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); + return STATUS_FAILED; + } + + if (PrefixBuffer && PrefixSize) { + fwrite(PrefixBuffer, PrefixSize, 1, f); + } + + if (Compressed) { + uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); + Compressed = false; + } else { + if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { + uint32 magic = DCGF_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + magic = COMPRESSED_FILE_MAGIC; + fwrite(&magic, sizeof(uint32), 1, f); + + uint32 DataOffset = 5 * sizeof(uint32); + fwrite(&DataOffset, sizeof(uint32), 1, f); + + fwrite(&CompSize, sizeof(uint32), 1, f); + fwrite(&BufferSize, sizeof(uint32), 1, f); + + fwrite(CompBuffer, CompSize, 1, f); + } else { + _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); + Compressed = false; + } + + delete [] CompBuffer; + } + } + + if (!Compressed) fwrite(Buffer, BufferSize, 1, f); + + fclose(f); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { + // unmount all non-local packages + for (uint32 i = 0; i < _packages.size(); i++) { + if (_packages[i]->_cD > 0) _packages[i]->close(); + } + + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::addPath(TPathType type, const Common::String &path) { + if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; + + bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); + + char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; + if (buffer == NULL) return STATUS_FAILED; + + strcpy(buffer, path.c_str()); + if (!slashed) strcat(buffer, "\\"); + //CBPlatform::strlwr(buffer); + + switch (type) { + case PATH_SINGLE: + _singlePaths.push_back(buffer); + break; + case PATH_PACKAGE: + _packagePaths.push_back(buffer); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::reloadPaths() { + // delete registered paths + for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i]; + _singlePaths.clear(); + + for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i]; + _packagePaths.clear(); + + return initPaths(); +} + + +#define TEMP_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::initPaths() { + restoreCurrentDir(); + + AnsiString pathList; + int numPaths; + + // single files paths + pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_SINGLE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_SINGLE, ".\\"); + + + // package files paths + addPath(PATH_PACKAGE, "./"); + + pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + + for (int i = 0; i < numPaths; i++) { + char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + if (path && strlen(path) > 0) { + addPath(PATH_PACKAGE, path); + } + delete[] path; + path = NULL; + } + addPath(PATH_PACKAGE, "data"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackages() { + restoreCurrentDir(); + + _gameRef->LOG(0, "Scanning packages..."); + debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, "*.dcp"); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + registerPackage((*it)->getName().c_str()); + } +#if 0 + AnsiString extension = AnsiString(PACKAGE_EXTENSION); + + for (int i = 0; i < _packagePaths.getSize(); i++) { + boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); + + //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); + //printf("Scanning: %s\n", absPath.string().c_str()); + + if (!exists(absPath)) continue; + + // scan files + boost::filesystem::directory_iterator endIter; + for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { + if (!is_directory((*dit).status())) { + AnsiString fileName = (*dit).path().string(); + + if (!IsValidPackage(fileName)) continue; + + warning("%s", fileName.c_str()); + //printf("%s\n", fileName.c_str()); + if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; + warning("Registered"); + RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); + } + } + } +#endif + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +// FILE *f = fopen(filename, "rb"); + Common::File *package = new Common::File(); + package->open(filename); + if (!package->isOpen()) { + _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + return STATUS_OK; + } + + uint32 absoluteOffset = 0; + bool boundToExe = false; + + if (searchSignature) { + uint32 offset; + if (!findPackageSignature(package, &offset)) { + delete package; + return STATUS_OK; + } else { + package->seek(offset, SEEK_SET); + absoluteOffset = offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(package); +// package->read(&hdr, sizeof(TPackageHeader), 1, f); + if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete package; + return STATUS_OK; + } + + if (hdr.PackageVersion != PACKAGE_VERSION) { + _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + } + + // new in v2 + if (hdr.PackageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = package->readUint32LE(); + dirOffset += absoluteOffset; + package->seek(dirOffset, SEEK_SET); + } + + for (uint32 i = 0; i < hdr.NumDirs; i++) { + CBPackage *pkg = new CBPackage(_gameRef); + if (!pkg) return STATUS_FAILED; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = package->readByte(); + pkg->_name = new char[nameLength]; + package->read(pkg->_name, nameLength); + pkg->_cD = package->readByte(); + pkg->_priority = hdr.Priority; + + if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 NumFiles = package->readUint32LE(); + + for (uint32 j = 0; j < NumFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = package->readByte(); + name = new char[nameLength]; + package->read(name, nameLength); + + // v2 - xor name + if (hdr.PackageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + + CBPlatform::strupr(name); + + offset = package->readUint32LE(); + offset += absoluteOffset; + length = package->readUint32LE(); + compLength = package->readUint32LE(); + flags = package->readUint32LE(); + + if (hdr.PackageVersion == PACKAGE_VERSION) { + timeDate1 = package->readUint32LE(); + timeDate2 = package->readUint32LE(); + } + _filesIter = _files.find(name); + if (_filesIter == _files.end()) { + CBFileEntry *file = new CBFileEntry(_gameRef); + file->_package = pkg; + file->_offset = offset; + file->_length = length; + file->_compressedLength = compLength; + file->_flags = flags; + + _files[name] = file; + } else { + // current package has lower CD number or higher priority, than the registered + if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + _filesIter->_value->_package = pkg; + _filesIter->_value->_offset = offset; + _filesIter->_value->_length = length; + _filesIter->_value->_compressedLength = compLength; + _filesIter->_value->_flags = flags; + } + } + delete [] name; + } + } + + + delete package; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::isValidPackage(const AnsiString &fileName) const { + AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); + + // check for device-type specific packages + if (StringUtil::startsWith(plainName, "xdevice_", true)) { + return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openPackage(const Common::String &name) { + //TODO: Is it really necessary to do this when we have the ScummVM-system? + + //RestoreCurrentDir(); + + Common::File *ret = new Common::File(); + char filename[MAX_PATH_LENGTH]; + + for (uint32 i = 0; i < _packagePaths.size(); i++) { + sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + } + + sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + ret->open(filename); + if (ret->isOpen()) { + return ret; + } + warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + delete ret; + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +Common::File *CBFileManager::openSingleFile(const Common::String &name) { + restoreCurrentDir(); + + Common::File *ret = NULL; + char filename[MAX_PATH_LENGTH]; + + for (uint32 i = 0; i < _singlePaths.size(); i++) { + sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); + ret->open(filename); + if (ret->isOpen()) + return ret; + } + + // didn't find in search paths, try to open directly + ret->open(name); + if (ret->isOpen()) { + return ret; + } else { + delete ret; + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { + restoreCurrentDir(); + + Common::File f; + bool found = false; + + for (uint32 i = 0; i < _singlePaths.size(); i++) { + sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); + f.open(fullname); + if (f.isOpen()) { + f.close(); + found = true; + break; + } + } + + if (!found) { + f.open(filename.c_str()); + if (f.isOpen()) { + f.close(); + found = true; + strcpy(fullname, filename.c_str()); + } + } + + return found; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { + char *upc_name = new char[strlen(filename.c_str()) + 1]; + strcpy(upc_name, filename.c_str()); + CBPlatform::strupr(upc_name); + + CBFileEntry *ret = NULL; + _filesIter = _files.find(upc_name); + if (_filesIter != _files.end()) ret = _filesIter->_value; + + delete [] upc_name; + + return ret; +} + +bool CBFileManager::hasFile(const Common::String &filename) { + //TODO: Do this in a much simpler fashion + Common::SeekableReadStream *stream = openFile(filename, true, false); + if (!stream) { + return false; + } + delete stream; + return true; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) return NULL; + //_gameRef->LOG(0, "open file: %s", filename); + /*#ifdef __WIN32__ + if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { + char Drive[_MAX_DRIVE]; + _splitpath(filename, Drive, NULL, NULL, NULL); + if (Drive[0] != '\0') { + _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); + } + } + #endif*/ + + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) _openFiles.push_back(file); + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::closeFile(Common::SeekableReadStream *File) { + for (uint32 i = 0; i < _openFiles.size(); i++) { + if (_openFiles[i] == File) { + delete _openFiles[i]; + _openFiles.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { + restoreCurrentDir(); + + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + if (DID_SUCCEED(SaveThumbFile->open(filename))) { + ret = SaveThumbFile->getMemStream(); + } + delete SaveThumbFile; + return ret; + } + + + + ret = openDiskFile(filename, this); + if (ret) return ret; + + ret = openPkgFile(filename, this); + if (ret) return ret; + + ret = CBResources::getFile(filename); + if (ret) return ret; + + warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::restoreCurrentDir() { + if (!_basePath) return STATUS_OK; + else { + /*if (!chdir(_basePath)) return STATUS_OK; + else return STATUS_FAILED;*/ + warning("CBFileManager::RestoreCurrentDir - ignored"); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::setBasePath(const Common::String &path) { + cleanup(); + + if (path.c_str()) { + _basePath = new char[path.size() + 1]; + strcpy(_basePath, path.c_str()); + } + + initPaths(); + registerPackages(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + + } + return false; + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h new file mode 100644 index 0000000000..1bf3156ebe --- /dev/null +++ b/engines/wintermute/base/base_file_manager.h @@ -0,0 +1,85 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEMANAGER_H +#define WINTERMUTE_BFILEMANAGER_H + +#include "engines/wintermute/base/file/base_file_entry.h" +#include "common/archive.h" +#include "common/str.h" + +namespace Common { +class File; +} + +namespace WinterMute { +class CBFile; +class CBFileManager: CBBase { +public: + bool findPackageSignature(Common::File *f, uint32 *offset); + bool cleanup(); + bool setBasePath(const Common::String &path); + bool restoreCurrentDir(); + char *_basePath; + bool getFullPath(const Common::String &filename, char *fullname); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + CBFileEntry *getPackageEntry(const Common::String &filename); + Common::File *openSingleFile(const Common::String &name); + Common::File *openPackage(const Common::String &name); + bool registerPackages(); + bool initPaths(); + bool reloadPaths(); + typedef enum { + PATH_PACKAGE, PATH_SINGLE + } TPathType; + bool addPath(TPathType type, const Common::String &path); + bool requestCD(int cd, char *packageFile, const char *filename); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + CBFileManager(CBGame *inGame = NULL); + virtual ~CBFileManager(); + Common::Array _singlePaths; + Common::Array _packagePaths; + Common::Array _packages; + Common::Array _openFiles; + + Common::HashMap _files; +private: + bool registerPackage(const Common::String &filename, bool searchSignature = false); + Common::HashMap::iterator _filesIter; + bool isValidPackage(const AnsiString &fileName) const; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp new file mode 100644 index 0000000000..468ad29858 --- /dev/null +++ b/engines/wintermute/base/base_frame.cpp @@ -0,0 +1,705 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/str.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFrame, false) + +////////////////////////////////////////////////////////////////////// +CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFrame::~CBFrame() { + delete _sound; + _sound = NULL; + + for (int i = 0; i < _subframes.getSize(); i++) + delete _subframes[i]; + _subframes.removeAll(); + + for (int i = 0; i < _applyEvent.getSize(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.removeAll(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; + + for (int i = 0; i < _subframes.getSize(); i++) { + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); + if (DID_FAIL(res)) return res; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) owner->updateOneSound(_sound); + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (int i = 0; i < _applyEvent.getSize(); i++) { + owner->applyEvent(_applyEvent[i]); + } + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; + CBPlatform::setRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.scanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); + break; + + case TOKEN_MOVE: + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &mirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &editorSelected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.scanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.scanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + CBSubFrame *subframe = new CBSubFrame(_gameRef); + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else _subframes.add(subframe); + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { + if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *Event = new char[strlen(params) + 1]; + strcpy(Event, params); + _applyEvent.add(Event); + } + break; + + case TOKEN_KEYFRAME: + parser.scanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FRAME definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading FRAME definition"); + return STATUS_FAILED; + } + + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (surface_file != NULL) { + if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + + if (!sub->_surface) { + delete sub; + _gameRef->LOG(0, "Error loading SUBFRAME"); + return STATUS_FAILED; + } + + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } + + if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + else sub->_rect = rect; + + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; + + + sub->_editorSelected = editorSelected; + _subframes.insertAt(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + CBPlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (int i = 0; i < _subframes.getSize(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + + if (_sound && _sound->_soundFilename) + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + + if (_editorExpanded) + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + + if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + + for (int i = 1; i < _subframes.getSize(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (int i = 0; i < _applyEvent.getSize(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + CBBase::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + _applyEvent.persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); + else stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new CBSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { + stack->pushBool(false); + delete _sound; + _sound = NULL; + } else stack->pushBool(true); + } else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushNative(_subframes[index], true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _subframes.getSize()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + CBSubFrame *sub = (CBSubFrame *)val->getNative(); + for (int i = 0; i < _subframes.getSize(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + sub->setDefaultRect(); + } + _subframes.add(sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertSubframe") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= _subframes.getSize()) _subframes.add(sub); + else _subframes.insertAt(index, sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _applyEvent.getSize()) { + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); + stack->pushNULL(); + } else stack->pushString(_applyEvent[index]); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + stack->pushNULL(); + return STATUS_OK; + } + } + _applyEvent.add(event); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (int i = 0; i < _applyEvent.getSize(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete [] _applyEvent[i]; + _applyEvent.removeAt(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); + else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delay") == 0) { + _scValue->setInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _scValue->setBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _scValue->setBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _scValue->setInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _scValue->setInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumSubframes") == 0) { + _scValue->setInt(_subframes.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); + else return CBScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Delay") == 0) { + _delay = MAX(0, value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _keyframe = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _killSound = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _moveX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _moveY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); + else return CBScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBFrame::scToString() { + return "[frame]"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h new file mode 100644 index 0000000000..f3dec4e16f --- /dev/null +++ b/engines/wintermute/base/base_frame.h @@ -0,0 +1,73 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFRAME_H +#define WINTERMUTE_BFRAME_H + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { +class CBSound; +class CBSubFrame; +class CBObject; +class CScScript; +class CScStack; +class CBFrame: public CBScriptable { +public: + bool _killSound; + bool _keyframe; + bool oneTimeDisplay(CBObject *owner, bool muted = false); + DECLARE_PERSISTENT(CBFrame, CBScriptable) + CBSound *_sound; + bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool saveAsText(CBDynBuffer *buffer, int indent); + int _moveY; + int _moveX; + uint32 _delay; + CBArray _subframes; + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + CBFrame(CBGame *inGame); + virtual ~CBFrame(); + + CBArray _applyEvent; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp new file mode 100644 index 0000000000..d5e9c99dcf --- /dev/null +++ b/engines/wintermute/base/base_game.cpp @@ -0,0 +1,4477 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/video/video_player.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBGame, true) + + +////////////////////////////////////////////////////////////////////// +CBGame::CBGame(): CBObject(this) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _fileManager = NULL; + _transMgr = NULL; + _debugMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _debugAbsolutePathWarning = true; + _debugShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _videoPlayer = NULL; + _theoraPlayer = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + _registry = new CBRegistry(this); + _stringTable = new CBStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + _doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _richSavedGames = false; + _savedGameExt = NULL; + CBUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _loadImageName = NULL; + _saveImageName = NULL; + _saveLoadImage = NULL; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _localSaveDir = NULL; + CBUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + CBPlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + +/*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices +#else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +CBGame::~CBGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + getDebugMgr()->onGameShutdown(); + + _registry->writeBool("System", "LastRun", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _saveLoadImage; + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + delete _debugMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _fileManager; + delete _registry; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _saveLoadImage = NULL; + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + _debugMgr = NULL; + + _renderer = NULL; + _fileManager = NULL; + _registry = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + CBPlatform::outputDebugString("--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::cleanup() { + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + unregisterObject(_fader); + _fader = NULL; + + for (int i = 0; i < _regObjects.getSize(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.removeAll(); + + _windows.removeAll(); // refs only + _focusedWindow = NULL; // ref only + + delete[] _saveImageName; + delete[] _loadImageName; + _saveImageName = NULL; + _loadImageName = NULL; + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (int i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.removeAll(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + _quickMessages.removeAll(); + + _viewportStack.removeAll(); + _viewportSP = -1; + + delete[] _name; + delete[] _filename; + _name = NULL; + _filename = NULL; + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new CBSurfaceStorage(this); + if (_surfaceStorage == NULL) + break; + + _fontStorage = new CBFontStorage(this); + if (_fontStorage == NULL) + break; + + _fileManager = new CBFileManager(this); + if (_fileManager == NULL) + break; + + _soundMgr = new CBSoundMgr(this); + if (_soundMgr == NULL) + break; + + _debugMgr = new CBDebugger(this); + if (_debugMgr == NULL) + break; + + _mathClass = new CSXMath(this); + if (_mathClass == NULL) + break; + + _scEngine = new CScEngine(this); + if (_scEngine == NULL) + break; + + _videoPlayer = new CVidPlayer(this); + if (_videoPlayer == NULL) + break; + + _transMgr = new CBTransitionMgr(this); + if (_transMgr == NULL) + break; + + _keyboardState = new CBKeyboardState(this); + if (_keyboardState == NULL) + break; + + _fader = new CBFader(this); + if (_fader == NULL) + break; + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _debugMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _fileManager; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) return STATUS_FAILED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + + if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; + if (_indicatorX == -1) _indicatorX = 0; + if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + /* time_t timeNow; + time(&timeNow); + struct tm *tm = localtime(&timeNow); + + #ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); + #endif*/ + int secs = g_system->getMillis() / 1000; + int hours = secs / 3600; + secs = secs % 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); + + AnsiString platform = CBPlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void CBGame::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + if (_debugMgr) _debugMgr->onLog(res, buff); + + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initLoop() { + _viewportSP = -1; + + _currentTime = CBPlatform::getTime(); + + getDebugMgr()->onGameTick(); + _renderer->initLoop(); + _soundMgr->initLoop(); + updateMusicCrossfade(); + + _surfaceStorage->initLoop(); + _fontStorage->initLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else _timerDelta = 0; + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //_gameRef->LOG(0, "%d", _fps); + + getMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) _fader->update(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) *offsetX = _offsetX; + if (offsetY != NULL) *offsetY = _offsetY; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + _gameRef->LOG(0, "'GAME' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _systemFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + _videoFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.scanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.scanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.scanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.scanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.scanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.scanStr((char *)params, "%d", &_indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.scanStr((char *)params, "%d", &_indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + _indicatorColor = BYTETORGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.scanStr((char *)params, "%d", &_indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.scanStr((char *)params, "%d", &_indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + CBUtils::setString(&_saveImageName, (char *)params); + break; + + case TOKEN_SAVE_IMAGE_X: + parser.scanStr((char *)params, "%d", &_saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + CBUtils::setString(&_loadImageName, (char *)params); + break; + + case TOKEN_LOAD_IMAGE_X: + parser.scanStr((char *)params, "%d", &_loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.scanStr((char *)params, "%d", &_loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + CBUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + LOG(0, stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + bool res = CBObject::scCallMethod(script, stack, thisStack, name); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Msg") == 0) { + stack->correctParams(1); + quickMessage(stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RunScript") == 0) { + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + stack->correctParams(1); + if (DID_FAIL(addScript(stack->pop()->getString()))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadStringTable") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + CScValue *Val = stack->pop(); + + bool ClearOld; + if (Val->isNULL()) ClearOld = true; + else ClearOld = Val->getBool(); + + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + stack->pushBool(false); + else + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidObject") == 0) { + stack->correctParams(1); + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *) obj)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + resetContent(); + stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + CBObject *obj = (CBObject *)val->getNative(); + unregisterObject(obj); + if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadWindow") == 0) { + stack->correctParams(1); + CUIWindow *win = new CUIWindow(_gameRef); + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { + _windows.add(win); + registerObject(win); + stack->pushNative(win, true); + } else { + delete win; + win = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExpandString") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); + _stringTable->expand(&str); + stack->pushString(str); + delete [] str; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); + else { + stack->correctParams(4); + channel = stack->pop()->getInt(); + } + + const char *filename = stack->pop()->getString(); + CScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + CScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); + + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); + else { + if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); + else stack->pushString(_music[channel]->_soundFilename); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + uint32 time = stack->pop()->getInt(); + + if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); + else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { + int channel = 0; + if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else stack->pushBool(_music[channel]->isPlaying()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); + else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + int volume = stack->pop()->getInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); + else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); + else stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); + else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); + else stack->pushInt(_music[channel]->getVolumePercent()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->correctParams(4); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); + + if (_musicCrossfadeRunning) { + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->pushBool(false); + return STATUS_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; + + _musicCrossfadeRunning = true; + + stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundLength") == 0) { + stack->correctParams(1); + + int length = 0; + const char *filename = stack->pop()->getString(); + + CBSound *sound = new CBSound(_gameRef); + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; + } + stack->pushInt(length); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMousePos") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + Point32 p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LockMouseRect") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + if (right < left) CBUtils::swap(&left, &right); + if (bottom < top) CBUtils::swap(&top, &bottom); + + CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK; + // TODO: ADDVIDEO + */ + + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + stack->correctParams(6); + const char *filename = stack->pop()->getString(); + warning("PlayVideo: %s - not implemented yet", filename); + CScValue *valType = stack->pop(); + int Type; + if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; + else Type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool FreezeMusic = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) + Type = (int)VID_PLAY_STRETCH; + + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + /* stack->correctParams(0); + stack->pushBool(false); + + return STATUS_OK;*/ + // TODO: ADDVIDEO + + stack->correctParams(7); + const char *filename = stack->pop()->getString(); + CScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) + type = (int)VID_PLAY_STRETCH; + else type = valType->getInt(); + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); + + CScValue *valSub = stack->pop(); + const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + + delete _theoraPlayer; + _theoraPlayer = new CVidTheoraPlayer(this); + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else stack->pushBool(false); + } else { + stack->pushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QuitGame") == 0) { + stack->correctParams(0); + stack->pushNULL(); + _quitting = true; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + _registry->writeInt("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + _registry->writeString("PrivateSettings", key, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + AnsiString val = _registry->readString("PrivateSettings", key, initVal); + stack->pushString(val.c_str()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveGame") == 0) { + stack->correctParams(3); + int slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); + + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); + stack->pushBool(true); + if (DID_FAIL(SaveGame(slot, desc, quick))) { + stack->pop(); + stack->pushBool(false); + } + delete [] desc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadGame") == 0) { + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->getInt(); + _loading = true; + stack->pushBool(false); + script->sleep(0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->correctParams(1); + int Slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(Slot)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + emptySaveSlot(slot); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); + else stack->pushString(_activeCursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->correctParams(0); + if (!_activeCursor) stack->pushNULL(); + else stack->pushNative(_activeCursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->correctParams(0); + delete _activeCursor; + _activeCursor = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->correctParams(0); + + if (_activeCursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FileExists") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + // TODO: Replace with fileExists + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (!file) stack->pushBool(false); + else { + _fileManager->closeFile(file); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Screenshot") == 0) { + stack->correctParams(1); + char filename[MAX_PATH_LENGTH]; + + CScValue *Val = stack->pop(); + + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO + int fileNum = 0; + + while (true) { + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + if (!Common::File::exists(filename)) + break; + fileNum++; + } + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); + + bool ret = false; + CBImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else ret = false; + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + + CUIWindow *win = new CUIWindow(_gameRef); + _windows.add(win); + registerObject(win); + if (!val->isNULL()) win->setName(val->getString()); + stack->pushNative(win, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + CBObject *obj = (CBObject *)stack->pop()->getNative(); + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == obj) { + unregisterObject(_windows[i]); + stack->pushBool(true); + return STATUS_OK; + } + } + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenDocument") == 0) { + stack->correctParams(0); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->correctParams(0); + DEBUG_DumpClassRegistry(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _loadImageX = stack->pop()->getInt(); + _loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _loadImageName; + _loadImageName = NULL; + } else { + CBUtils::setString(&_loadImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + CScValue *val = stack->pop(); + _saveImageX = stack->pop()->getInt(); + _saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + delete[] _saveImageName; + _saveImageName = NULL; + } else { + CBUtils::setString(&_saveImageName, val->getString()); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->correctParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive) stack->pushNULL(); + else stack->pushNative(_cursorNoninteractive, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->correctParams(4); + + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); + + delete _loadingIcon; + _loadingIcon = new CBSprite(this); + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + displayContent(false, true); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->correctParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _renderer->dumpData(filename); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccOutputText") == 0) { + stack->correctParams(2); + /* const char *Str = */ + stack->pop()->getString(); + /* int Type = */ + stack->pop()->getInt(); + // do nothing + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new CBSaveThumbHelper(this); + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushBool(false); + } else stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool asHex = stack->pop()->getBool(false); + + Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + if (file) { + crc remainder = crc_initialize(); + byte buf[1024]; + int bytesRead = 0; + + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); + + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (asHex) { + char Hex[100]; + sprintf(Hex, "%x", checksum); + stack->pushString(Hex); + } else + stack->pushInt(checksum); + + _fileManager->closeFile(file); + file = NULL; + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->enableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->disableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); +/*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); +#endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Hwnd") == 0) { + _scValue->setInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentTime") == 0) { + _scValue->setInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowsTime") == 0) { + _scValue->setInt((int)CBPlatform::getTime()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowedMode") == 0) { + _scValue->setBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _scValue->setInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _scValue->setInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + _scValue->setNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ActiveObject") == 0) { + _scValue->setNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenWidth") == 0) { + _scValue->setInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenHeight") == 0) { + _scValue->setInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + _scValue->setBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DebugMode") == 0) { + _scValue->setBool(_debugDebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundAvailable") == 0) { + _scValue->setBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyboard") == 0) { + if (_keyboardState) _scValue->setNative(_keyboardState, true); + else _scValue->setNULL(); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _scValue->setBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _scValue->setInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _scValue->setBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FPS") == 0) { + _scValue->setInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + _scValue->setBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + _scValue->setInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _scValue->setBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _scValue->setInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _scValue->setBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _scValue->setBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Frozen") == 0) { + _scValue->setBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSTalk") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSCaptions") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSKeypress") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardPause") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _scValue->setBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveDirectory") == 0) { + AnsiString dataDir = getDataDir(); + _scValue->setString(dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _scValue->setBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _scValue->setInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _scValue->setBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Platform") == 0) { + _scValue->setString(CBPlatform::getPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeviceType") == 0) { + _scValue->setString(getDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MostRecentSaveSlot") == 0) { + _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Store") == 0) { + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); + + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _mousePos.x = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _mousePos.y = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + bool res = CBObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + CBScriptable *obj = value->getNative(); + if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + setInteractive(value->getBool()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _subtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _videoSubtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + int Enc = value->getInt(); + if (Enc < 0) Enc = 0; + if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; + _textEncoding = (TTextEncoding)Enc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _textRTL = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = value->getInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _suspendedRendering = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _autorunDisabled = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _autoSaveSlot = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _cursorHidden = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayQuickMsg() { + if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + + // update + for (int i = 0; i < _quickMessages.getSize(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.removeAt(i); + i--; + } + } + + int posY = 20; + + // display + for (int i = 0; i < _quickMessages.getSize(); i++) { + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessage(const char *text) { + if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.removeAt(0); + } + _quickMessages.add(new CBQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::registerObject(CBObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unregisterObject(CBObject *object) { + if (!object) return STATUS_OK; + + // is it a window? + for (int i = 0; i < _windows.getSize(); i++) { + if ((CBObject *)_windows[i] == object) { + _windows.removeAt(i); + + // get new focused window + if (_focusedWindow == object) _focusedWindow = NULL; + + break; + } + } + + // is it active object? + if (_activeObject == object) _activeObject = NULL; + + // is it main object? + if (_mainObject == object) _mainObject = NULL; + + // destroy object + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) { + _regObjects.removeAt(i); + if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::invalidateValues(void *value, void *data) { + CScValue *val = (CScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { + ((CBScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::validObject(CBObject *object) { + if (!object) return false; + if (object == this) return true; + + for (int i = 0; i < _regObjects.getSize(); i++) { + if (_regObjects[i] == object) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { + CScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "String") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXString(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MemBuffer") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "File") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXFile(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Date") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXDate(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Array") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXArray(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Object") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXObject(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sleep") == 0) { + stack->correctParams(1); + + script->sleep((uint32)stack->pop()->getInt()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WaitFor") == 0) { + stack->correctParams(1); + + CBScriptable *obj = stack->pop()->getNative(); + if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Random") == 0) { + stack->correctParams(2); + + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); + + stack->pushInt(CBUtils::randomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->correctParams(1); + + script->_timeSlice = (uint32)stack->pop()->getInt(); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->correctParams(4); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); + int a; + CScValue *val = stack->pop(); + if (val->isNULL()) a = 255; + else a = val->getInt(); + + stack->pushInt(BYTETORGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeHSL") == 0) { + stack->correctParams(3); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); + + stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + CBUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(0); + + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); + script->sleep(0); + } + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToString") == 0) { + stack->correctParams(1); + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete [] str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToInt") == 0) { + stack->correctParams(1); + int val = stack->pop()->getInt(); + stack->pushInt(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToFloat") == 0) { + stack->correctParams(1); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + stack->pushBool(val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + script->runtimeError("Call to undefined function '%s'. Ignored.", name); + stack->correctParams(0); + stack->pushNULL(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::showCursor() { + if (_cursorHidden) return STATUS_OK; + + if (!_interactive && _gameRef->_state == GAME_RUNNING) { + if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + } else { + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; + else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); + else if (_cursor) return drawCursor(_cursor); + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + LOG(0, "Saving game '%s'...", filename); + + _gameRef->applyEvent("BeforeSave", true); + + bool ret; + + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } + + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + + _registry->writeInt("System", "MostRecentSaveSlot", slot); + +save_finish: // TODO: Remove gotos + delete pm; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + return loadGame(filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadGame(const char *filename) { + LOG(0, "Loading game '%s'...", filename); + getDebugMgr()->onGameShutdown(); + + bool ret; + + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName) { + _saveLoadImage = _renderer->createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + + + _loadInProgress = true; + _indicatorDisplay = true; + _indicatorProgress = 0; + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + _debugAbsolutePathWarning = false; + if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + + //if(DID_FAIL(ret = cleanup())) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + +load_finish: + _debugAbsolutePathWarning = true; + + _indicatorDisplay = false; + delete pm; + _loadInProgress = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; + + //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::initAfterLoad() { + CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); + CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); + + _scEngine->refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadRegion(void *region, void *data) { + ((CBRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSubFrame(void *subframe, void *data) { + ((CBSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadSound(void *sound, void *data) { + ((CBSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadFont(void *font, void *data) { + ((CBFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::afterLoadScript(void *script, void *data) { + ((CScScript *)script)->afterLoad(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayWindows(bool inGame) { + bool res; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (int i = _windows.getSize() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) return res; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + delete _music[channel]; + _music[channel] = NULL; + + _music[channel] = new CBSound(_gameRef); + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; + } + if (loopStart) _music[channel]->setLoopStart(loopStart); + return _music[channel]->play(looping); + } else { + delete _music[channel]; + _music[channel] = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) return _music[channel]->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setMusicStartTime(int channel, uint32 time) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::loadSettings(const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return STATUS_FAILED; + } + buffer = params; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + break; + + case TOKEN_STRING_TABLE: + if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_RESOLUTION: + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.scanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.scanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + _registry->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + CBUtils::setString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); + ret = STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading game settings '%s'", filename); + ret = STATUS_FAILED; + } + + _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + //_compressedSavegames = false; + + delete [] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) + cleanup(); + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_doNotExpandStrings)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); + } + + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); + + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); + + _regObjects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); + + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); + + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); + + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); + + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); + + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); + + persistMgr->transfer(TMEMBER(_mouseLockRect)); + + _windows.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); + + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); + + if (!persistMgr->_saving) + _quitting = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::focusWindow(CUIWindow *Window) { + CUIWindow *Prev = _focusedWindow; + + for (int i = 0; i < _windows.getSize(); i++) { + if (_windows[i] == Window) { + if (i < _windows.getSize() - 1) { + _windows.removeAt(i); + _windows.add(Window); + + _gameRef->_focusedWindow = Window; + } + + if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) + return focusWindow(Prev); + else return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::freeze(bool includingMusic) { + if (_freezeLevel == 0) { + _scEngine->pauseAll(); + _soundMgr->pauseAll(includingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::unfreeze() { + if (_freezeLevel == 0) return STATUS_OK; + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleKeypress(Common::Event *event, bool printable) { + if (isVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + stopVideo(); + return true; + } + + if (event->type == Common::EVENT_QUIT) { + onWindowClose(); + return true; + } + + if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { + // TODO: Handle alt-enter as well as alt-return. + _renderer->switchFullscreen(); + return true; + } + + + _keyboardState->handleKeyPress(event); + _keyboardState->readKey(event); +// TODO + + if (_focusedWindow) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + /*if (event->type != SDL_TEXTINPUT) {*/ + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + _gameRef->_focusedWindow->applyEvent("Keypress"); + else + applyEvent("Keypress"); + /*}*/ + } + return true; + } else { /*if (event->type != SDL_TEXTINPUT)*/ + applyEvent("Keypress"); + return true; + } //else return true; + + return false; +} + +void CBGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::handleMouseWheel(int Delta) { + bool handled = false; + if (_focusedWindow) { + handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + + if (!handled) { + if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); + handled = true; + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); + handled = true; + } + + } + } + + if (!handled) { + if (Delta < 0) { + applyEvent("MouseWheelDown"); + } else { + applyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) *verMajor = DCGF_VER_MAJOR; + if (verMinor) *verMinor = DCGF_VER_MINOR; + + if (extMajor) *extMajor = 0; + if (extMinor) *extMinor = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setWindowTitle() { + if (_renderer) { + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') strcat(title, " - "); + strcat(title, "WME Lite"); + + + Utf8String utf8Title; + if (_textEncoding == TEXT_UTF8) { + utf8Title = Utf8String(title); + } else { + warning("CBGame::SetWindowTitle -Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } +#if 0 + CBRenderOSystem *renderer = static_cast(_renderer); + // TODO + + SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); +#endif + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotFilename(int slot, char *buffer) { + AnsiString dataDir = getDataDir(); + //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + strcpy(buffer, filename.c_str()); + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDataDir() { + AnsiString userDir = PathUtil::getUserDirectory(); + AnsiString baseDir = _registry->getBasePath(); + return PathUtil::combine(userDir, baseDir); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(filename))) { + _debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + + _debugAbsolutePathWarning = true; + strcpy(buffer, pm->_savedDescription); + delete pm; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isSaveSlotUsed(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + + warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!File) return false; + delete File; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::emptySaveSlot(int slot) { + char filename[MAX_PATH_LENGTH + 1]; + getSaveSlotFilename(slot, filename); + CBPersistMgr *pm = new CBPersistMgr(this); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setActiveObject(CBObject *obj) { + // not-active when game is frozen + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; + } + + if (obj == _activeObject) return STATUS_OK; + + if (_activeObject) _activeObject->applyEvent("MouseLeave"); + //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + _activeObject = obj; + if (_activeObject) { + _activeObject->applyEvent("MouseEntry"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::pushViewport(CBViewport *viewport) { + _viewportSP++; + if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); + else _viewportStack[_viewportSP] = viewport; + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) return STATUS_FAILED; + else { + if (_viewportSP >= 0) { + CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) *custom = true; + } else { + CBPlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) *custom = false; + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { + if (_viewportSP >= 0) { + if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; + if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + } else { + if (offsetX) *offsetX = 0; + if (offsetY) *offsetY = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) _transMgr->_origInteractive = state; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + if (_indicatorDisplay) displayIndicator(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayIndicator() { + if (_saveLoadImage) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + _renderer->setupLines(); + for (int i = 0; i < _indicatorHeight; i++) + _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + + _renderer->setup2D(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::updateMusicCrossfade() { + /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + + if (!_musicCrossfadeRunning) return STATUS_OK; + if (_state == GAME_FROZEN) return STATUS_OK; + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + + if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); + if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; + + if (currentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); + + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); + + + if (_musicCrossfadeSwap) { + // swap channels + CBSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + CSysClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::invalidateDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::restoreDeviceObjects() { + for (int i = 0; i < _regObjects.getSize(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new CBSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) return true; + if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::stopVideo() { + if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBGame::drawCursor(CBSprite *cursor) { + if (!cursor) return STATUS_FAILED; + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool CBGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) return STATUS_OK; + + _renderer->_active = activate; + + if (refreshMouse) { + Point32 p; + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); + } + + if (activate) _soundMgr->resumeAll(); + else _soundMgr->pauseAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) _capturedObject = _activeObject; + _mouseLeftDown = true; + CBPlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + + CBPlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightDown() { + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseRightUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + + if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onMouseMiddleUp() { + if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + return STATUS_OK; + } else return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::displayDebugInfo() { + char str[100]; + + if (_debugShowFPS) { + sprintf(str, "FPS: %d", _gameRef->_fps); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (_gameRef->_debugDebugMode) { + if (!_gameRef->_renderer->_windowed) + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + else + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + + strcat(str, " ("); + strcat(str, _renderer->getName()); + strcat(str, ")"); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->displayDebugInfo(); + + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBDebugger *CBGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new CBDebugger(this); + return _debugMgr; +} + + +////////////////////////////////////////////////////////////////////////// +void CBGame::getMousePos(Point32 *pos) { + CBPlatform::getCursorPos(pos); + + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { + Common::Rect rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= _gameRef->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= _gameRef->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); + + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); + + Point32 newPos = *pos; + + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; + + CBPlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::miniUpdate() { + if (!_miniUpdateEnabled) return STATUS_OK; + + if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (_soundMgr) _soundMgr->initLoop(); + _lastMiniUpdate = CBPlatform::getTime(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::onScriptShutdown(CScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool CBGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 pos; + CBPlatform::getCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); + + + if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = CBPlatform::getTime(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; + return false; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + _registry->saveValues(); + + if (!_autoSaveOnExit) return; + if (_state == GAME_FROZEN) return; + + SaveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void CBGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h new file mode 100644 index 0000000000..12ab07912b --- /dev/null +++ b/engines/wintermute/base/base_game.h @@ -0,0 +1,391 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BGAME_H +#define WINTERMUTE_BGAME_H + +#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/rect32.h" +#include "common/events.h" + +namespace WinterMute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); + +class CBSoundMgr; +class CBFader; +class CBFont; +class CBFileManager; +class CBTransitionMgr; +class CScEngine; +class CBFontStorage; +class CBStringTable; +class CBQuickMsg; +class CUIWindow; +class CBViewport; +class CBRenderer; +class CBRegistry; +class CBSaveThumbHelper; +class CBSurfaceStorage; +class CSXMath; +class CBKeyboardState; +class CVidPlayer; +class CVidTheoraPlayer; + +#define NUM_MUSIC_CHANNELS 5 + +class CBGame: public CBObject { +public: + DECLARE_PERSISTENT(CBGame, CBObject) + + virtual bool onScriptShutdown(CScScript *script); + + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); + + bool isLeftDoubleClick(); + bool isRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual bool miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + CBSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + char *_localSaveDir; + bool _saveDirChecked; + + int _indicatorProgress; +protected: + bool _indicatorDisplay; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + CBSurface *_saveLoadImage; + bool displayIndicator(); + + bool _reportTextureFormat; +public: + int _thumbnailWidth; + int _thumbnailHeight; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + bool _editorMode; + + bool _doNotExpandStrings; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + CBObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + CBFont *_systemFont; + CBFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + CBFileManager *_fileManager; + CBTransitionMgr *_transMgr; + CBDebugger *getDebugMgr(); + + void LOG(bool res, const char *fmt, ...); + + CBRenderer *_renderer; + CBSoundMgr *_soundMgr; + CScEngine *_scEngine; + CSXMath *_mathClass; + CBSurfaceStorage *_surfaceStorage; + CBFontStorage *_fontStorage; + CBGame(); + + virtual ~CBGame(); + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + bool _debugAbsolutePathWarning; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + CBArray _quickMessages; + CBArray _windows; + CBArray _viewportStack; + + int _viewportSP; + + CBStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; +protected: + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + CBFader *_fader; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); +public: + virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + +private: + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; +public: + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; + bool _videoSubtitles; + bool _subtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + int _scheduledLoadSlot; + bool _loading; + bool _personalizedSave; + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + virtual bool handleMouseWheel(int delta); + bool _quitting; + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual void handleKeyRelease(Common::Event *event); +protected: + int _freezeLevel; +public: + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(CUIWindow *window); + CVidPlayer *_videoPlayer; + CVidTheoraPlayer *_theoraPlayer; + bool _loadInProgress; + CUIWindow *_focusedWindow; + bool _editorForceScripts; +protected: + static void afterLoadRegion(void *region, void *data); + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +public: + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + CBSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); + CBRegistry *_registry; + bool _useD3D; + virtual bool cleanup(); + virtual bool loadGame(int slot); + virtual bool loadGame(const char *filename); + virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + CBSprite *_cursorNoninteractive; + CBObject *_activeObject; + CBKeyboardState *_keyboardState; + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + CBObject *_capturedObject; + Point32 _mousePos; + bool validObject(CBObject *object); + bool unregisterObject(CBObject *object); + bool registerObject(CBObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + + CBArray _regObjects; +public: + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); + bool _forceNonStreamedSounds; + void resetMousePos(); + int _subtitlesSpeed; + void setInteractive(bool state); + virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(CBViewport *Viewport); + bool setActiveObject(CBObject *Obj); + CBSprite *_lastCursor; + bool drawCursor(CBSprite *Cursor); + + virtual bool initAfterLoad(); + CBSaveThumbHelper *_cachedThumbnail; + AnsiString getDataDir(); + void addMem(int bytes); + + bool _touchInterface; + bool _constrainedMemory; + AnsiString getDeviceType() const; + +private: + CBDebugger *_debugMgr; + + struct LastClickInfo { + LastClickInfo() { + posX = posY = 0; + time = 0; + } + + int posX; + int posY; + uint32 time; + }; + + LastClickInfo _lastClick[2]; + bool isDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void autoSaveOnExit(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp new file mode 100644 index 0000000000..240f642b7f --- /dev/null +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -0,0 +1,304 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +CBKeyboardState::~CBKeyboardState() { + delete[] _keyStates; +} + +void CBKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void CBKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + vKey = (int)temp; + } else vKey = val->getInt(); + + warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; +// Uint8 *state = SDL_GetKeyboardState(NULL); +// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBKeyboardState::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->setString(key); + } else _scValue->setString(""); + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Printable") == 0) { + _scValue->setBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KeyCode") == 0) { + _scValue->setInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsShift") == 0) { + _scValue->setBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsAlt") == 0) { + _scValue->setBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsControl") == 0) { + _scValue->setBool(_currentControl); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::readKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = keyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { + //if(!persistMgr->_saving) cleanup(); + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); + + if (!persistMgr->_saving) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool CBKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) return 0; + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +enum VKeyCodes { + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h new file mode 100644 index 0000000000..bdf268c601 --- /dev/null +++ b/engines/wintermute/base/base_keyboard_state.h @@ -0,0 +1,75 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BKEYBOARD_STATE_H +#define WINTERMUTE_BKEYBOARD_STATE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace WinterMute { + +class CBKeyboardState : public CBScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) + CBKeyboardState(CBGame *inGame); + virtual ~CBKeyboardState(); + bool readKey(Common::Event *event); + + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + uint8 *_keyStates; + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp new file mode 100644 index 0000000000..da76fb2047 --- /dev/null +++ b/engines/wintermute/base/base_named_object.cpp @@ -0,0 +1,65 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_named_object.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject() : CBBase() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBNamedObject::~CBNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBNamedObject::setName(const char *name) { + delete[] _name; + + _name = new char [strlen(name) + 1]; + if (_name != NULL) strcpy(_name, name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h new file mode 100644 index 0000000000..c03d1417a3 --- /dev/null +++ b/engines/wintermute/base/base_named_object.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BNAMEDOBJECT_H +#define WINTERMUTE_BNAMEDOBJECT_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBNamedObject : public CBBase { +public: + CBNamedObject(CBGame *inGame); + CBNamedObject(); + virtual ~CBNamedObject(void); + CBNamedObject(TDynamicConstructor, TDynamicConstructor); + + char *_name; + void setName(const char *name); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp new file mode 100644 index 0000000000..0a4a0638f0 --- /dev/null +++ b/engines/wintermute/base/base_object.cpp @@ -0,0 +1,1128 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBObject, false) + +////////////////////////////////////////////////////////////////////// +CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = _gameRef->getSequence(); + + CBPlatform::setRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) + _caption[i] = NULL; + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +CBObject::~CBObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) + _gameRef->_activeObject = NULL; + + CBScriptHolder::cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7) + return; + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::getCaption(int caseVal) { + if (caseVal == 0) caseVal = 1; + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + return ""; + else return _caption[caseVal - 1]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + afterMove(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->getInt())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveCursor") == 0) { + stack->correctParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursor") == 0) { + stack->correctParams(0); + if (!_cursor || !_cursor->_filename) stack->pushNULL(); + else stack->pushString(_cursor->_filename); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursorObject") == 0) { + stack->correctParams(0); + if (!_cursor) stack->pushNULL(); + else stack->pushNative(_cursor, true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasCursor") == 0) { + stack->correctParams(0); + + if (_cursor) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCaption") == 0) { + stack->correctParams(2); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadSound") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + if (DID_SUCCEED(playSFX(filename, false, false))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySound") == 0) { + stack->correctParams(3); + + const char *filename; + bool looping; + uint32 loopStart; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + CScValue *val3 = stack->pop(); + + if (val1->_type == VAL_BOOL) { + filename = NULL; + looping = val1->getBool(); + loopStart = val2->getInt(); + } else { + if (val1->isNULL()) filename = NULL; + else filename = val1->getString(); + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); + } + + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->correctParams(2); + + const char *filename; + const char *eventName; + + CScValue *val1 = stack->pop(); + CScValue *val2 = stack->pop(); + + if (val2->isNULL()) { + filename = NULL; + eventName = val1->getString(); + } else { + filename = val1->getString(); + eventName = val2->getString(); + } + + if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(pauseSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(resumeSFX())) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->correctParams(0); + + if (_sFX && _sFX->isPlaying()) stack->pushBool(true); + else stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->correctParams(1); + + uint32 Time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(0); + else stack->pushInt(_sFX->getPositionTime()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->correctParams(1); + + int volume = stack->pop()->getInt(); + if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); + else stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->correctParams(0); + + if (!_sFX) stack->pushInt(_sFXVolume); + else stack->pushInt(_sFX->getVolumePercent()); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXNone") == 0) { + stack->correctParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->correctParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->correctParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); + + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + _scValue->setString(getCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(getHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ready") == 0) { + _scValue->setBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _scValue->setBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _scValue->setBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _scValue->setBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _scValue->setBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + _scValue->setInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (_scale < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (_scaleX < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (_scaleY < 0) _scValue->setNULL(); + else _scValue->setFloat((double)_scaleY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _scValue->setFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (!_rotateValid) _scValue->setNULL(); + else _scValue->setFloat((double)_rotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _scValue->setFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _scValue->setBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _scValue->setBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _scValue->setBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _scValue->setBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + _scValue->setNULL(); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Caption") == 0) { + setCaption(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _movable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _registrable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _zoomable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _rotatable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alphaColor = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + int i = value->getInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + _blendMode = (TSpriteBlendMode)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (value->isNULL()) _scale = -1; + else _scale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (value->isNULL()) _scaleX = -1; + else _scaleX = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (value->isNULL()) _scaleY = -1; + else _scaleY = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _relativeScale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (value->isNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)value->getFloat(); + _rotateValid = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _relativeRotate = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _shadowable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _autoSoundPanning = value->getBool(); + if (!_autoSoundPanning) resetSoundPan(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _saveState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::showCursor() { + if (_cursor) return _gameRef->drawCursor(_cursor); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + for (int i = 0; i < 7; i++) + persistMgr->transfer(TMEMBER(_caption[i])); + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new CBSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new CBSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { + // just play loaded sound + if (filename == NULL && _sFX) { + if (_gameRef->_editorMode || _sFXStart) { + _sFX->setVolumePercent(_sFXVolume); + _sFX->setPositionTime(_sFXStart); + if (!_gameRef->_editorMode) _sFXStart = 0; + } + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } + + if (filename == NULL) return STATUS_FAILED; + + // create new sound + delete _sFX; + + _sFX = new CBSound(_gameRef); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); + if (_sFXStart) { + _sFX->setPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) _sFX->setLoopStart(loopStart); + return _sFX->play(looping); + } else return STATUS_OK; + } else { + delete _sFX; + _sFX = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::pauseSFX() { + if (_sFX) return _sFX->pause(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resumeSFX() { + if (_sFX) return _sFX->resume(); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) return _sFX->setVolumePercent(volume); + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) updateOneSound(_sFX); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::updateOneSound(CBSound *sound) { + bool Ret = STATUS_OK; + + if (sound) { + if (_autoSoundPanning) + Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + + Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return Ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::resetSoundPan() { + if (!_sFX) return STATUS_OK; + else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void CBObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) strcpy(_soundEvent, eventName); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h new file mode 100644 index 0000000000..70dc69f53d --- /dev/null +++ b/engines/wintermute/base/base_object.h @@ -0,0 +1,144 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BOBJECT_H +#define WINTERMUTE_BOBJECT_H + + +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace WinterMute { + +class CBSprite; +class CBSound; +class CBSurface; +class CBScriptHolder; +class CScValue; +class CScStack; +class CScScript; +class CBObject : public CBScriptHolder { +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + uint32 _alphaColor; + float _scale; + float _scaleX; + float _scaleY; + float _relativeScale; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(CBSound *sound); + bool _autoSoundPanning; + uint32 _sFXStart; + int _sFXVolume; + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + CBSound *_sFX; + + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + + virtual bool handleMouseWheel(int delta); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); + const char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); + bool _editorSelected; + bool _editorAlwaysRegister; + bool _editorOnly; + bool _is3D; + DECLARE_PERSISTENT(CBObject, CBScriptHolder) + virtual bool showCursor(); + CBSprite *_cursor; + bool _sharedCursors; + CBSprite *_activeCursor; + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool _ready; + bool _registrable; + bool _zoomable; + bool _shadowable; + Rect32 _rect; + bool _rectSet; + int _iD; + bool _movable; + CBObject(CBGame *inGame); + virtual ~CBObject(); + char *_caption[7]; + char *_soundEvent; + int _posY; + int _posX; + bool _saveState; + + // base + virtual bool update() { + return STATUS_FAILED; + }; + virtual bool display() { + return STATUS_FAILED; + }; + virtual bool invalidateDeviceObjects() { + return STATUS_OK; + }; + virtual bool restoreDeviceObjects() { + return STATUS_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp new file mode 100644 index 0000000000..0f185636aa --- /dev/null +++ b/engines/wintermute/base/base_parser.cpp @@ -0,0 +1,436 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +CBParser::CBParser(CBGame *inGame): CBBase(inGame) { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +CBParser::~CBParser() { + if (_whiteSpace != NULL) delete [] _whiteSpace; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + skipCharacters(buf, _whiteSpace); + } + + if (! **buf) // at end of file + return PARSERR_EOF; + + // find the token. + // for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else strcpy(_lastOffender, ""); + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + skipCharacters(buf, _whiteSpace); + + // get optional name + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') // An assignment rather than a command/object. + *data = getAssignmentText(buf); + else + *data = getSubText(buf, '{', '}'); + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { + if (!*buf) return PARSERR_TOKENNOTFOUND; + _gameRef->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') _parserLine++; + if (strchr(toSkip, ch) == NULL) + return; + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) + return 0; + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) // we cant nest identical delimiters + open = 0; + while ((theChar = **buf) != 0) { + if (theChar == open) + ++skip; + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *CBParser::getAssignmentText(char **buf) { + ++*buf; // skip the '=' + skipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = getSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) // space and control chars + break; + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) // skip the terminator + ++*buf; + } + + return result; +} + + +////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////// +char *CBParser::getToken(char **buf) { + static char token[100]; + char *b = *buf, * t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) b++; + else break; + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') b++; + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float CBParser::getTokenFloat(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::getTokenInt(char **buf) { + char *t = getToken(buf); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { + char *t = getToken(buf); + if (strcmp(t, tok)) return; // Error +} + + +////////////////////////////////////////////////////////////////////// +int CBParser::scanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') break; + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + strncpy(a, in, (int)(in2 - in)); + a[(int)(in2 - in)] = 0; + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) format++; + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h new file mode 100644 index 0000000000..53a02c0f68 --- /dev/null +++ b/engines/wintermute/base/base_parser.h @@ -0,0 +1,89 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPARSER_H +#define WINTERMUTE_BPARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static CBParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBParser : public CBBase { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, TokenDesc *tokens, char **params); + CBParser(CBGame *inGame = NULL); + virtual ~CBParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + char *getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + char *_whiteSpace; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp new file mode 100644 index 0000000000..743eaf355b --- /dev/null +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -0,0 +1,778 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" + +namespace WinterMute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } +} + + +////////////////////////////////////////////////////////////////////////// +CBPersistMgr::~CBPersistMgr() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete [] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + delete[] _savedDescription; + _savedDescription = NULL; // ref to buffer +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete [] _thumbnailData; + _thumbnailData = NULL; + } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; +} + +Common::String CBPersistMgr::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); +} + +void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void CBPersistMgr::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 CBPersistMgr::getMaxUsedSlot() { + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); it++) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool CBPersistMgr::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initSave(const char *desc) { + if (!desc) return STATUS_FAILED; + + cleanup(); + _saving = true; + + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); + + if (_saveStream) { + // get thumbnails + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + } + } + + uint32 magic = DCGF_MAGIC; + putDWORD(magic); + + magic = SAVE_MAGIC_2; + putDWORD(magic); + + byte VerMajor, VerMinor, ExtMajor, ExtMinor; + _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); + //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(VerMajor); + _saveStream->writeByte(VerMinor); + _saveStream->writeByte(ExtMajor); + _saveStream->writeByte(ExtMinor); + + // new in ver 2 + putDWORD((uint32)DCGF_VER_BUILD); + putString(_gameRef->_name); + + // thumbnail data size + bool thumbnailOK = false; + + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } + + thumbnailOK = true; + } + } + if (!thumbnailOK) putDWORD(0); + + // in any case, destroy the cached thumbnail once used + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + + uint32 dataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(desc) + 1 + // description + sizeof(uint32); // timestamp + + putDWORD(dataOffset); + putString(desc); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); + } + return STATUS_OK; +} + +bool CBPersistMgr::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + if (_loadStream) { + uint32 magic; + magic = getDWORD(); + + if (magic != DCGF_MAGIC) { + cleanup(); + return STATUS_FAILED; + } + + magic = getDWORD(); + + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); + + if (magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)getDWORD(); + _savedName = getStringObj(); + + // load thumbnail + _thumbnailDataSize = getDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + getBytes(_thumbnailData, _thumbnailDataSize); + } else _thumbnailDataSize = 0; + } + } else _savedVerBuild = 35; // last build with ver1 savegames + + uint32 dataOffset = getDWORD(); + + _savedDescription = getString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); + + _offset = dataOffset; + + return STATUS_OK; + } + } + + cleanup(); + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::initLoad(const char *filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + cleanup(); + return STATUS_FAILED; + } + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + + } + + /* + if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) + { + _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); + goto init_fail; + } + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::saveFile(const char *filename) { + return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBPersistMgr::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void CBPersistMgr::putString(const Common::String &val) { + if (!val.size()) putString("(null)"); + else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String CBPersistMgr::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + Common::String retString = ret; + delete[] ret; + + if (retString == "(null)") { + retString = ""; + } + + return retString; +} + +////////////////////////////////////////////////////////////////////////// +char *CBPersistMgr::getString() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else return ret; +} + +bool CBPersistMgr::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +TimeDate CBPersistMgr::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + +void CBPersistMgr::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float CBPersistMgr::getFloat() { + char *str = getString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +void CBPersistMgr::putDouble(double val) { + Common::String str = Common::String::format("F%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double CBPersistMgr::getDouble() { + char *str = getString(); + double value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool CBPersistMgr::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// int +bool CBPersistMgr::transfer(const char *name, int *val) { + if (_saving) { + _saveStream->writeSint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +bool CBPersistMgr::transfer(const char *name, uint32 *val) { + if (_saving) { + _saveStream->writeUint32LE(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readUint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// float +bool CBPersistMgr::transfer(const char *name, float *val) { + if (_saving) { + putFloat(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// double +bool CBPersistMgr::transfer(const char *name, double *val) { + if (_saving) { + putDouble(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = getDouble(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// char* +bool CBPersistMgr::transfer(const char *name, char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// const char* +bool CBPersistMgr::transfer(const char *name, const char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +bool CBPersistMgr::transfer(const char *name, Common::String *val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { + size_t size; + + if (_saving) { + size = val.size(); + _saveStream->writeUint32LE(size); + + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); + } + } else { + val.clear(); + size = _loadStream->readUint32LE(); + + for (size_t i = 0; i < size; i++) { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) val.push_back(str); + delete[] str; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +bool CBPersistMgr::transfer(const char *name, byte *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +bool CBPersistMgr::transfer(const char *name, Rect32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +bool CBPersistMgr::transfer(const char *name, Point32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +bool CBPersistMgr::transfer(const char *name, Vector2 *val) { + if (_saving) { + putFloat(val->x); + putFloat(val->y); + if (_saveStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } else { + val->x = getFloat(); + val->y = getFloat(); + if (_loadStream->err()) + return STATUS_FAILED; + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +bool CBPersistMgr::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { + if (_saving) return true; + + // it's ok if we are same or newer than the saved game + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) + ) return false; + + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h new file mode 100644 index 0000000000..f2fd42ceca --- /dev/null +++ b/engines/wintermute/base/base_persistence_manager.h @@ -0,0 +1,114 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPERSISTMGR_H +#define WINTERMUTE_BPERSISTMGR_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/savestate.h" +#include "common/stream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/rect.h" + +namespace WinterMute { + +class Vector2; + +class CBPersistMgr : public CBBase { +public: + char *_savedDescription; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const char *filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + Common::String getStringObj(); + void putString(const Common::String &val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); + bool initLoad(const char *filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool _saving; + + uint32 _richBufferSize; + byte *_richBuffer; + + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); + CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~CBPersistMgr(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + bool putTimeDate(const TimeDate &t); + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp new file mode 100644 index 0000000000..6887349a7a --- /dev/null +++ b/engines/wintermute/base/base_point.cpp @@ -0,0 +1,64 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBPoint, false) + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::~CBPoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +CBPoint::CBPoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool CBPoint::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h new file mode 100644 index 0000000000..363ab1f919 --- /dev/null +++ b/engines/wintermute/base/base_point.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPOINT_H +#define WINTERMUTE_BPOINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBPoint: public CBBase { +public: + DECLARE_PERSISTENT(CBPoint, CBBase) + CBPoint(); + CBPoint(int initX, int initY); + int y; + int x; + virtual ~CBPoint(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp new file mode 100644 index 0000000000..ac1001a2fe --- /dev/null +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) strcpy(_text, text); + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +CBQuickMsg::~CBQuickMsg() { + if (_text) delete [] _text; +} + + +////////////////////////////////////////////////////////////////////////// +char *CBQuickMsg::getText() { + return _text; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h new file mode 100644 index 0000000000..9a68929932 --- /dev/null +++ b/engines/wintermute/base/base_quick_msg.h @@ -0,0 +1,48 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BQUICKMSG_H +#define WINTERMUTE_BQUICKMSG_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBQuickMsg : public CBBase { +public: + char *getText(); + uint32 _startTime; + char *_text; + CBQuickMsg(CBGame *inGame, const char *Text); + virtual ~CBQuickMsg(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp new file mode 100644 index 0000000000..3e513f9fb8 --- /dev/null +++ b/engines/wintermute/base/base_region.cpp @@ -0,0 +1,508 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBRegion, false) + +////////////////////////////////////////////////////////////////////////// +CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegion::~CBRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegion::cleanup() { + for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + CBPlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::pointInRegion(int x, int y) { + if (_points.getSize() < 3) return false; + + Point32 pt; + pt.x = x; + pt.y = y; + + Rect32 rect; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; + + if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + else return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int i; + + for (i = 0; i < _points.getSize(); i++) delete _points[i]; + _points.removeAll(); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new CBPoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AddPoint") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + _points.add(new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points.insertAt(Index, new CBPoint(x, y)); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPoint") == 0) { + stack->correctParams(3); + int Index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (Index >= 0 && Index < _points.getSize()) { + _points[Index]->x = x; + _points[Index]->y = y; + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemovePoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + delete _points[index]; + _points[index] = NULL; + + _points.removeAt(index); + createRegion(); + + stack->pushBool(true); + } else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < _points.getSize()) { + CScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); + } + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.getSize()); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); + else buffer->putTextIndent(indent, "%s {\n", nameOverride); + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (i = 0; i < _points.getSize(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) _scProp->saveAsText(buffer, indent + 2); + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::ptInPolygon(int x, int y) { + if (_points.getSize() < 3) return false; + + int counter = 0; + double xinters; + dPoint p, p1, p2; + + p.x = (double)x; + p.y = (double)y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (int i = 1; i <= _points.getSize(); i++) { + p2.x = (double)_points[i % _points.getSize()]->x; + p2.y = (double)_points[i % _points.getSize()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) + counter++; + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) + return false; + else + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); + else { + int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + + for (int i = 0; i < _points.getSize(); i++) { + MinX = MIN(MinX, _points[i]->x); + MinY = MIN(MinY, _points[i]->y); + + MaxX = MAX(MaxX, _points[i]->x); + MaxY = MAX(MaxY, _points[i]->y); + } + CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + + cleanup(); + + for (int i = 0; i < region->_points.getSize(); i++) { + int xVal, yVal; + + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); + + _points.add(new CBPoint(xVal + x, yVal + y)); + } + + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; + + return createRegion() ? STATUS_OK : STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h new file mode 100644 index 0000000000..5de1fb9eef --- /dev/null +++ b/engines/wintermute/base/base_region.h @@ -0,0 +1,68 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGION_H +#define WINTERMUTE_BREGION_H + +#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CBRegion : public CBObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); + bool ptInPolygon(int x, int y); + DECLARE_PERSISTENT(CBRegion, CBObject) + bool _active; + int _editorSelectedPoint; + CBRegion(CBGame *inGame); + virtual ~CBRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + Rect32 _rect; + CBArray _points; + virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp new file mode 100644 index 0000000000..350a34b61e --- /dev/null +++ b/engines/wintermute/base/base_registry.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/tinyxml/tinyxml.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/utils.h" +#include "common/config-manager.h" +#include "common/file.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { + _iniName = NULL; + + setIniName("./wme.ini"); + loadValues(true); +} + + +////////////////////////////////////////////////////////////////////////// +CBRegistry::~CBRegistry() { + saveValues(); + delete[] _iniName; + _iniName = NULL; +} + + + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { + AnsiString ret = ""; + + bool found = false; + ret = getValue(_localValues, subKey, key, found); + if (!found) ret = getValue(_values, subKey, key, found); + if (!found) ret = init; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { + _values[subKey][key] = value; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + if (ConfMan.hasKey("master_volume")) { + return ConfMan.getInt("master_volume"); + } else { + return init; + } + } else if (key == "SFXVolume") { + if (ConfMan.hasKey("sfx_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "SpeechVolume") { + if (ConfMan.hasKey("speech_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } else if (key == "MusicVolume") { + if (ConfMan.hasKey("music_volume")) { + error("This key shouldn't be read by the scripts"); + } else { + return init; + } + } + } + AnsiString val = readString(subKey, key, ""); + if (val.empty()) return init; + else return atoi(val.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { + if (subKey == "Audio") { + if (key == "MasterVolume") { + ConfMan.setInt("master_volume", value); + return true; + } else if (key == "SFXVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "SpeechVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } else if (key == "MusicVolume") { + error("This key shouldn't be read by the scripts"); + return true; + } + } + writeString(subKey, key, StringUtil::toString(value)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { + return (readInt(subKey, key, (int)init) != 0); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { + return writeInt(subKey, key, (int)value); +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setIniName(const char *name) { + delete[] _iniName; + _iniName = NULL; + + if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { + _iniName = new char [strlen(name) + 3]; + sprintf(_iniName, "./%s", name); + } else { + _iniName = new char [strlen(name) + 1]; + strcpy(_iniName, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *CBRegistry::getIniName() { + return _iniName; +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadValues(bool local) { + if (local) loadXml("settings.xml", _localValues); + else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveValues() { + saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::setBasePath(const char *basePath) { + _basePath = PathUtil::getFileNameWithoutExtension(basePath); + + loadValues(false); +} + +////////////////////////////////////////////////////////////////////////// +AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { + found = false; + PathValueMap::iterator it = values.find(path); + if (it == values.end()) return ""; + + KeyValuePair pairs = (*it)._value; + KeyValuePair::iterator keyIt = pairs.find(key); + if (keyIt == pairs.end()) return ""; + else { + found = true; + return (*keyIt)._value; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { + TiXmlDocument doc(fileName.c_str()); + if (!doc.LoadFile()) return; + + TiXmlElement *rootElem = doc.RootElement(); + if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + return; + + for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { + for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { + values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + CBUtils::createPath(fileName.c_str()); + + TiXmlDocument doc; + doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); + + TiXmlElement *root = new TiXmlElement("Settings"); + doc.LinkEndChild(root); + + PathValueMap::iterator pathIt; + for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { + TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); + root->LinkEndChild(pathElem); + + + KeyValuePair pairs = (*pathIt)._value; + KeyValuePair::iterator keyIt; + for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { + TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); + pathElem->LinkEndChild(keyElem); + + keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); + } + } + + + TiXmlPrinter printer; + doc.Accept(&printer); + + Common::DumpFile stream; + stream.open(fileName.c_str()); + + if (!stream.isOpen()) return; + else { + stream.write(printer.CStr(), printer.Size()); + stream.close(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h new file mode 100644 index 0000000000..06e052cd03 --- /dev/null +++ b/engines/wintermute/base/base_registry.h @@ -0,0 +1,76 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BREGISTRY_H +#define WINTERMUTE_BREGISTRY_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBRegistry : public CBBase { +public: + void setIniName(const char *name); + char *getIniName(); + bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); + bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); + bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); + int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); + bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); + AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); + CBRegistry(CBGame *inGame); + virtual ~CBRegistry(); + + void setBasePath(const char *basePath); + AnsiString getBasePath() const { + return _basePath; + } + + void loadValues(bool local); + void saveValues(); + +private: + char *_iniName; + + typedef Common::HashMap KeyValuePair; + typedef Common::HashMap PathValueMap; + + PathValueMap _localValues; + PathValueMap _values; + + AnsiString _basePath; + + void loadXml(const AnsiString fileName, PathValueMap &values); + void saveXml(const AnsiString fileName, PathValueMap &values); + + AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp new file mode 100644 index 0000000000..bee63aa307 --- /dev/null +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -0,0 +1,79 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbHelper::~CBSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + if (doFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + } + + CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) return STATUS_FAILED; + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new CBImage(_gameRef); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); + } + + + delete screenshot; + screenshot = NULL; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h new file mode 100644 index 0000000000..e8cdbdc00d --- /dev/null +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BSAVETHUMBHELPER_H +#define WINTERMUTE_BSAVETHUMBHELPER_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBImage; + +class CBSaveThumbHelper : public CBBase { +public: + CBSaveThumbHelper(CBGame *inGame); + virtual ~CBSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + CBImage *_thumbnail; + CBImage *_richThumbnail; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp new file mode 100644 index 0000000000..5192f76f6e --- /dev/null +++ b/engines/wintermute/base/base_script_holder.cpp @@ -0,0 +1,473 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +CBScriptHolder::~CBScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + int i; + + for (i = 0; i < _scripts.getSize(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void CBScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) delete [] _filename; + + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) strcpy(_filename, filename); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread) { + CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + if (handler) { + //_scripts.add(handler); + numHandlers++; + ret = STATUS_OK; + } + } + } + if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->correctParams(0); + byte *p = 0; + *p = 10; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ApplyEvent") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + bool ret; + ret = applyEvent(val->getString()); + + if (DID_SUCCEED(ret)) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AttachScript") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DetachScript") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool killThreads = stack->pop()->getBool(false); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + _scripts[i]->finish(killThreads); + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + bool ret = false; + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(_name); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { + return CBBase::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_name)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::addScript(const char *filename) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + return STATUS_OK; + } + } + } + + CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.add(scr); + _gameRef->_scEngine->_scripts.add(scr); + _gameRef->getDebugMgr()->onScriptInit(scr); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::removeScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) { + _scripts.removeAt(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleEvent(const char *EventName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::canHandleMethod(const char *MethodName) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + _gameRef->LOG(0, "'PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) strcpy(propName, (char *)params); + else cmd = PARSERR_GENERIC; + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) strcpy(propValue, (char *)params); + else cmd = PARSERR_GENERIC; + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading PROPERTY definition"); + return STATUS_FAILED; + } + + + CScValue *val = new CScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->_freezable = freezable; + +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.getSize() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); + + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (_name && strcmp(_name, "") != 0) { + strcat(buf, " Name: "); + strcat(buf, _name); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool CBScriptHolder::sendEvent(const char *eventName) { + return DID_SUCCEED(applyEvent(eventName)); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h new file mode 100644 index 0000000000..0e5bc1b7ec --- /dev/null +++ b/engines/wintermute/base/base_script_holder.h @@ -0,0 +1,74 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTHOLDER_H +#define WINTERMUTE_BSCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CBScriptHolder : public CBScriptable { +public: + DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + + CBScriptHolder(CBGame *inGame); + virtual ~CBScriptHolder(); + virtual CScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + bool cleanup(); + bool removeScript(CScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(CBDynBuffer *buffer, int indent); + virtual bool listen(CBScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + bool parseProperty(byte *buffer, bool complete = true); + char *_filename; + bool _freezable; + bool _ready; + + CBArray _scripts; + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +public: + virtual bool sendEvent(const char *eventName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp new file mode 100644 index 0000000000..e9489fa407 --- /dev/null +++ b/engines/wintermute/base/base_scriptable.cpp @@ -0,0 +1,188 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBScriptable, false) + +////////////////////////////////////////////////////////////////////////// +CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { + _refCount = 0; + + if (noValue) _scValue = NULL; + else _scValue = new CScValue(_gameRef); + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable::~CBScriptable() { + //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->getProp(name); + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scSetProperty(const char *name, CScValue *value) { + if (!_scProp) _scProp = new CScValue(_gameRef); + if (_scProp) return _scProp->setProp(name, value); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *CBScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double CBScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBScriptable::scCompare(CBScriptable *val) { + if (this < val) return -1; + else if (this > val) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool CBScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CBScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugObject +////////////////////////////////////////////////////////////////////////// +const char *CBScriptable::dbgGetNativeClass() { + return getClassName(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { + return scGetProperty(name); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h new file mode 100644 index 0000000000..166f3c0bd1 --- /dev/null +++ b/engines/wintermute/base/base_scriptable.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSCRIPTABLE_H +#define WINTERMUTE_BSCRIPTABLE_H + + +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CScStack; +class CScScript; + +class CBScriptable : public CBNamedObject, public IWmeDebugObject { +public: + virtual CScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + + CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); + virtual ~CBScriptable(); + + // high level scripting interface + virtual bool canHandleMethod(const char *eventMethod); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(CBScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + CScValue *_scValue; + CScValue *_scProp; + +public: + // IWmeDebugObject + const char *dbgGetNativeClass(); + IWmeDebugProp *dbgGetProperty(const char *name); + +}; + +// Implemented in their respective .cpp-files +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXMath(CBGame *inGame); +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); +CBScriptable *makeSXStore(CBGame *inGame); +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp new file mode 100644 index 0000000000..ba55d1b88b --- /dev/null +++ b/engines/wintermute/base/base_sprite.cpp @@ -0,0 +1,758 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSprite, false) + +////////////////////////////////////////////////////////////////////// +CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +CBSprite::~CBSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + _filename = NULL; + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + setName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSprite::cleanup() { + CBScriptHolder::cleanup(); + + for (int i = 0; i < _frames.getSize(); i++) + delete _frames[i]; + _frames.removeAll(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + GetCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->afterMove(); + + x = _owner->_posX; + y = _owner->_posY; + } + + // draw frame + return display(x, y, registerOwner, zoomX, zoomY, alpha); +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + if (!file) { + _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); + else return loadFile("invalid.bmp", lifeTime, cacheType); + } else { + _gameRef->_fileManager->closeFile(file); + file = NULL; + } + + bool ret; + + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + CBFrame *frame = new CBFrame(_gameRef); + CBSubFrame *subframe = new CBSubFrame(_gameRef); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer) { + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + delete [] buffer; + } + } + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + CBParser parser(_gameRef); + + cleanup(); + + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + _gameRef->LOG(0, "'SPRITE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int frameCount = 1; + CBFrame *frame; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.scanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.scanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.scanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.scanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.scanStr((char *)params, "%b", &_streamed); + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (_gameRef->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.scanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int FrameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + + frame = new CBFrame(_gameRef); + + if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + delete frame; + _gameRef->LOG(0, "Error parsing frame %d", frameCount); + return STATUS_FAILED; + } + + _frames.add(frame); + frameCount++; + if (_currentFrame == -1) _currentFrame = 0; + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITE definition"); + return STATUS_FAILED; + } + _canBreak = !_continuous; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CBSprite::reset() { + if (_frames.getSize() > 0) _currentFrame = 0; + else _currentFrame = -1; + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { + //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) return false; + + uint32 timer; + if (_owner && _owner->_freezable) timer = _gameRef->_timer; + else timer = _gameRef->_liveTimer; + + int lastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < _frames.getSize() - 1) { + _currentFrame++; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + killAllSounds(); + } + applyEvent("FrameChanged"); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); +} + + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; + CBFrame *Frame = _frames[_currentFrame]; + if (Frame && Frame->_subframes.getSize() > 0) { + CBSubFrame *Subframe = Frame->_subframes[0]; + if (Subframe) return Subframe->_surface; + else return NULL; + } else return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + CBPlatform::setRectEmpty(rect); + for (int i = 0; i < _frames.getSize(); i++) { + Rect32 frame; + Rect32 temp; + CBPlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + CBPlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + + if (_editorMuted) + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + + if (_editorBgFile) { + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + CBScriptHolder::saveAsText(buffer, indent + 2); + + int i; + + // scripts + for (i = 0; i < _scripts.getSize(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + + for (i = 0; i < _frames.getSize(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::persist(CBPersistMgr *persistMgr) { + CBScriptHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int Index = stack->pop()->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + stack->pushNULL(); + } else stack->pushNative(_frames[Index], true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteFrame") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + if (Val->isInt()) { + int Index = Val->getInt(-1); + if (Index < 0 || Index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + } + } else { + CBFrame *Frame = (CBFrame *)Val->getNative(); + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i] == Frame) { + if (i == _currentFrame) _lastFrameTime = 0; + delete _frames[i]; + _frames.removeAt(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddFrame") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.add(sub); + } else delete sub; + } + _frames.add(frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertFrame") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) + index = 0; + + CScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) + filename = val->getString(); + + CBFrame *frame = new CBFrame(_gameRef); + if (filename != NULL) { + CBSubFrame *sub = new CBSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); + else delete sub; + } + + if (index >= _frames.getSize()) + _frames.add(frame); + else _frames.insertAt(index, frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _paused = true; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Play") == 0) { + stack->correctParams(0); + _paused = false; + stack->pushNULL(); + return STATUS_OK; + } + + else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSprite::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFrames") == 0) { + _scValue->setInt(_frames.getSize()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentFrame") == 0) { + _scValue->setInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _scValue->setBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Owner") == 0) { + if (_owner == NULL) _scValue->setNULL(); + else _scValue->setNative(_owner, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Finished") == 0) { + _scValue->setBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Paused") == 0) { + _scValue->setBool(_paused); + return _scValue; + } + + else return CBScriptHolder::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _precise = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _looping = value->getBool(); + return STATUS_OK; + } + + else return CBScriptHolder::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSprite::killAllSounds() { + for (int i = 0; i < _frames.getSize(); i++) { + if (_frames[i]->_sound) + _frames[i]->_sound->stop(); + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h new file mode 100644 index 0000000000..8f3ce84eb4 --- /dev/null +++ b/engines/wintermute/base/base_sprite.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSPRITE_H +#define WINTERMUTE_BSPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base_script_holder.h" + +namespace WinterMute { +class CBFrame; +class CBSurface; +class CBObject; +class CBSprite: public CBScriptHolder { +public: + bool killAllSounds(); + CBSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + + bool _editorAllFrames; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + int _moveY; + int _moveX; + bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void reset(); + CBObject *_owner; + bool _changed; + bool _paused; + bool _finished; + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + uint32 _lastFrameTime; + bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + CBSprite(CBGame *inGame, CBObject *owner = NULL); + virtual ~CBSprite(); + CBArray _frames; + bool saveAsText(CBDynBuffer *buffer, int indent); + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp new file mode 100644 index 0000000000..c7789add9d --- /dev/null +++ b/engines/wintermute/base/base_string_table.cpp @@ -0,0 +1,229 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/utils/string_util.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CBStringTable::~CBStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) return STATUS_FAILED; + + if (scumm_stricmp(key, "@right-to-left") == 0) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + _stringsIter = _strings.find(finalKey); + if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + + _strings[finalKey] = val; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *CBStringTable::getKey(const char *str) { + if (str == NULL || str[0] != '/') return NULL; + + const char *value = strchr(str + 1, '/'); + if (value == NULL) return NULL; + + char *key = new char[value - str]; + strncpy(key, str + 1, value - str - 1); + key[value - str - 1] = '\0'; + CBPlatform::strlwr(key); + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { + delete [] key; + char *Ret = getKey(new_str); + delete [] new_str; + return Ret; + } else { + delete [] new_str; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBStringTable::expand(char **str, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return; + + if (str == NULL || *str == NULL || *str[0] != '/') return; + + char *value = strchr(*str + 1, '/'); + if (value == NULL) return; + + char *key = new char[value - *str]; + strncpy(key, *str + 1, value - *str - 1); + key[value - *str - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = new char[_stringsIter->_value.size() + 1]; + strcpy(new_str, _stringsIter->_value.c_str()); + } else { + new_str = new char[strlen(value) + 1]; + strcpy(new_str, value); + } + + delete [] key; + delete [] *str; + *str = new_str; + + if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { + if (_gameRef->_doNotExpandStrings && !forceExpand) return string; + + if (string == NULL || string[0] == '\0' || string[0] != '/') return string; + + const char *value = strchr(string + 1, '/'); + if (value == NULL) return string; + + char *key = new char[value - string]; + strncpy(key, string + 1, value - string - 1); + key[value - string - 1] = '\0'; + CBPlatform::strlwr(key); + + value++; + + const char *new_str; + + _stringsIter = _strings.find(key); + if (_stringsIter != _strings.end()) { + new_str = _stringsIter->_value.c_str(); + } else { + new_str = value; + } + + delete [] key; + + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + else return new_str; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) _strings.clear(); + + uint32 size; + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + uint32 pos = 0; + + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else _gameRef->_textEncoding = TEXT_ANSI; + + uint32 lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + strncpy(line, (char *)&buffer[pos], realLength); + line[realLength] = '\0'; + char *value = strchr(line, '\t'); + if (value == NULL) value = strchr(line, ' '); + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (uint32 i = 0; i < strlen(value); i++) { + if (value[i] == '|') value[i] = '\n'; + } + addString(line, value, clearOld); + } else if (line[0] != '\0') addString(line, "", clearOld); + } + + delete [] line; + pos += lineLength + 1; + } + + delete [] buffer; + + _gameRef->LOG(0, " %d strings loaded", _strings.size()); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h new file mode 100644 index 0000000000..c612c33a41 --- /dev/null +++ b/engines/wintermute/base/base_string_table.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSTRINGTABLE_H +#define WINTERMUTE_BSTRINGTABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBStringTable : public CBBase { +public: + const char *expandStatic(const char *string, bool forceExpand = false); + bool loadFile(const char *filename, bool deleteAll = true); + void expand(char **str, bool forceExpand = false); + bool addString(const char *key, const char *val, bool reportDuplicities = true); + CBStringTable(CBGame *inGame); + virtual ~CBStringTable(); + Common::HashMap _strings; + char *getKey(const char *str); +private: + Common::HashMap::iterator _stringsIter; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp new file mode 100644 index 0000000000..adce6c6b75 --- /dev/null +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -0,0 +1,589 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + CBPlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSubFrame::~CBSubFrame() { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + CBPlatform::setRectEmpty(&rect); + char *surfaceFile = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); + return STATUS_FAILED; + } + + if (surfaceFile != NULL) { + if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + + /* + if(_surface == NULL) + { + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); + return STATUS_FAILED; + } + */ + if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + else _rect = rect; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) return STATUS_OK; + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + } else { + _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + } + } + if (_gameRef->_suspendedRendering) return STATUS_OK; + + bool res; + + //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) alpha = _alpha; + + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) return false; + + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; + + CBPlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { + if (complete) + buffer->putTextIndent(indent, "SUBFRAME {\n"); + + if (_surface && _surface->getFileNameStr() != "") + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + + if (_transparent != 0xFFFF00FF) + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + + Rect32 rect; + CBPlatform::setRectEmpty(&rect); + if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!CBPlatform::equalRect(&rect, &_rect)) + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + + if (_hotspotX != 0 || _hotspotY != 0) + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + + if (_alpha != 0xFFFFFFFF) { + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + } + + if (_mirrorX) + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + + if (_mirrorY) + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + + if (_2DOnly) + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + + if (_3DOnly) + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + + if (_decoration) + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + + if (_editorSelected) + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + + CBBase::saveAsText(buffer, indent + 2); + + + if (complete) + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSubFrame::setDefaultRect() { + if (_surface) { + CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else CBPlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + + if (!_surfaceFilename) stack->pushNULL(); + else stack->pushString(_surfaceFilename); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + if (Val->isNULL()) { + if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + delete[] _surfaceFilename; + _surfaceFilename = NULL; + stack->pushBool(true); + } else { + const char *filename = Val->getString(); + if (DID_SUCCEED(setSurface(filename))) { + setDefaultRect(); + stack->pushBool(true); + } else stack->pushBool(false); + } + + return STATUS_OK; + } + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CBSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new CScValue(_gameRef); + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + + _scValue->setInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TransparentColor") == 0) { + _scValue->setInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _scValue->setBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _scValue->setBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _scValue->setBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _scValue->setBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _scValue->setInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _scValue->setInt(_hotspotY); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _2DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _3DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _mirrorX = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _mirrorY = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _hotspotX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _hotspotY = value->getInt(); + return STATUS_OK; + } + + else return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CBSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[strlen(filename) + 1]; + strcpy(_surfaceFilename, filename); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSubFrame::setSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return STATUS_OK; + } + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) return STATUS_OK; + else return STATUS_FAILED; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h new file mode 100644 index 0000000000..6fb24c0e4f --- /dev/null +++ b/engines/wintermute/base/base_sub_frame.h @@ -0,0 +1,86 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSUBFRAME_H +#define WINTERMUTE_BSUBFRAME_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { +class CBObject; +class CBSurface; +class CBSubFrame : public CBScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); + DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + void setDefaultRect(); + uint32 _transparent; + bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool _editorSelected; + CBSubFrame(CBGame *inGame); + virtual ~CBSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + Rect32 _rect; + + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + CBSurface *_surface; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp new file mode 100644 index 0000000000..06c2f1b0cc --- /dev/null +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -0,0 +1,189 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +CBSurfaceStorage::~CBSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::cleanup(bool warn) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::initLoop() { + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; + sortSurfaces(); + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i]->_lifeTime <= 0) break; + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::removeSurface(CBSurface *surface) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!_gameRef->_fileManager->hasFile(filename)) { + if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); + if (_gameRef->_debugDebugMode) + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + else + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + + CBSurface *surface; + surface = _gameRef->_renderer->createSurface(); + + if (!surface) return NULL; + + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.push_back(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::restoreAll() { + bool ret; + for (uint32 i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +{ + + if(!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool CBSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + CBSurface *s1 = *((CBSurface **)arg1); + CBSurface *s2 = *((CBSurface **)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; + else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + + + // sort by validity + if (s1->_valid && !s2->_valid) return -1; + else if (!s1->_valid && s2->_valid) return 1; + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; + else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; + else return 0; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h new file mode 100644 index 0000000000..58f25e6875 --- /dev/null +++ b/engines/wintermute/base/base_surface_storage.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSURFACESTORAGE_H +#define WINTERMUTE_BSURFACESTORAGE_H + +#include "engines/wintermute/base/base.h" +#include "common/array.h" + +namespace WinterMute { +class CBSurface; +class CBSurfaceStorage : public CBBase { +public: + uint32 _lastCleanupTime; + bool initLoop(); + bool sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); + bool cleanup(bool Warn = false); + //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + + bool restoreAll(); + CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(CBSurface *surface); + CBSurfaceStorage(CBGame *inGame); + virtual ~CBSurfaceStorage(); + + Common::Array _surfaces; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp new file mode 100644 index 0000000000..30a1a32e6a --- /dev/null +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CBTransitionMgr::~CBTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) return STATUS_OK; + + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return STATUS_OK; + } + + if (nonInteractive) { + _preserveInteractive = true; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; + } /*else _preserveInteractive */; + + + _type = type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return STATUS_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +bool CBTransitionMgr::update() { + if (isReady()) return STATUS_OK; + + if (!_started) { + _started = true; + _lastTime = CBPlatform::getTime(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = CBPlatform::getTime() - _lastTime; + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) + _state = TRANS_MGR_READY; + } + break; + default: + error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (isReady()) { + if (_preserveInteractive) + _gameRef->_interactive = _origInteractive; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h new file mode 100644 index 0000000000..9b84c653e9 --- /dev/null +++ b/engines/wintermute/base/base_transition_manager.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BTRANSITIONMGR_H +#define WINTERMUTE_BTRANSITIONMGR_H + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBTransitionMgr : public CBBase { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + CBTransitionMgr(CBGame *inGame); + virtual ~CBTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp new file mode 100644 index 0000000000..83cbc5b0f0 --- /dev/null +++ b/engines/wintermute/base/base_viewport.cpp @@ -0,0 +1,98 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_viewport.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBViewport, false) + +////////////////////////////////////////////////////////////////////////// +CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { + CBPlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBViewport::~CBViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); + } + + CBPlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *CBViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int CBViewport::getHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h new file mode 100644 index 0000000000..795e6f404f --- /dev/null +++ b/engines/wintermute/base/base_viewport.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BVIEWPORT_H +#define WINTERMUTE_BVIEWPORT_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { +class CBObject; +class CBViewport : public CBBase { +public: + int getHeight(); + int getWidth(); + Rect32 *getRect(); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); + DECLARE_PERSISTENT(CBViewport, CBBase) + int _offsetY; + int _offsetX; + CBObject *_mainObject; + CBViewport(CBGame *inGame = NULL); + virtual ~CBViewport(); +private: + Rect32 _rect; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/BDiskFile.cpp b/engines/wintermute/base/file/BDiskFile.cpp deleted file mode 100644 index 739eafcc73..0000000000 --- a/engines/wintermute/base/file/BDiskFile.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/file/BDiskFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/stream.h" -#include "common/memstream.h" -#include "common/file.h" -#include "common/zlib.h" - -namespace WinterMute { - -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; - } -} - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { - char fullPath[MAX_PATH_LENGTH]; - uint32 prefixSize = 0; - Common::SeekableReadStream *file = NULL; - - for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { - sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); - correctSlashes(fullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - // if we didn't find it in search paths, try to open directly - if (!file) { - strcpy(fullPath, filename.c_str()); - correctSlashes(fullPath); - - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - if (file) { - uint32 magic1, magic2; - magic1 = file->readUint32LE(); - magic2 = file->readUint32LE(); - - bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; - - if (compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = file->readUint32LE(); - CompSize = file->readUint32LE(); - UncompSize = file->readUint32LE(); - - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - error("Error allocating memory for compressed file '%s'", filename.c_str()); - delete file; - return NULL; - } - - byte *data = new byte[UncompSize]; - if (!data) { - error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - file->seek(DataOffset + prefixSize, SEEK_SET); - file->read(CompBuffer, CompSize); - - if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { - error("Error uncompressing file '%s'", filename.c_str()); - delete [] CompBuffer; - delete file; - return NULL; - } - - delete [] CompBuffer; - - return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); - delete file; - file = NULL; - } else { - file->seek(0, SEEK_SET); - return file; - } - - return file; - - } - return NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BDiskFile.h b/engines/wintermute/base/file/BDiskFile.h deleted file mode 100644 index 23e1a0a315..0000000000 --- a/engines/wintermute/base/file/BDiskFile.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFile.cpp b/engines/wintermute/base/file/BFile.cpp deleted file mode 100644 index 911039e36d..0000000000 --- a/engines/wintermute/base/file/BFile.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "common/memstream.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFile::isEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *CBFile::getMemStream() { - uint32 oldPos = getPos(); - seek(0); - byte *data = new byte[getSize()]; - read(data, getSize()); - seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFile.h b/engines/wintermute/base/file/BFile.h deleted file mode 100644 index d1737df0ce..0000000000 --- a/engines/wintermute/base/file/BFile.h +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H - - -#include "engines/wintermute/base/BBase.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBFile : public CBBase { -protected: - uint32 _pos; - uint32 _size; -public: - virtual uint32 getSize() { - return _size; - }; - virtual uint32 getPos() { - return _pos; - }; - virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; - virtual bool read(void *buffer, uint32 size) = 0; - virtual bool close() = 0; - virtual bool open(const Common::String &filename) = 0; - virtual bool isEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BFileEntry.cpp b/engines/wintermute/base/file/BFileEntry.cpp deleted file mode 100644 index b00ecb6f9d..0000000000 --- a/engines/wintermute/base/file/BFileEntry.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFileEntry.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BFileEntry.h b/engines/wintermute/base/file/BFileEntry.h deleted file mode 100644 index 5fdf2b6308..0000000000 --- a/engines/wintermute/base/file/BFileEntry.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H - - -#include "engines/wintermute/base/BBase.h" - -namespace WinterMute { - -class CBPackage; - -class CBFileEntry : public CBBase { -public: - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BPackage.cpp b/engines/wintermute/base/file/BPackage.cpp deleted file mode 100644 index bddf1abc1e..0000000000 --- a/engines/wintermute/base/file/BPackage.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPackage.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "common/file.h" -#include "common/stream.h" - -namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { - _file = NULL; - _name = NULL; - _cD = 0; - _priority = 0; - _boundToExe = false; -} - - -////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { - if (_name) delete [] _name; - closeFilePointer(_file); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { - if (_file) return STATUS_OK; - else { - _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { - delete _file; - _file = NULL; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (DID_FAIL(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); - if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); - } - return file; -} - -////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPackage.h b/engines/wintermute/base/file/BPackage.h deleted file mode 100644 index 8c803fddd9..0000000000 --- a/engines/wintermute/base/file/BPackage.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H - - -#include "engines/wintermute/base/BBase.h" - -namespace Common { -class SeekableReadStream; -} - -namespace WinterMute { - -class CBPackage : public CBBase { -public: - Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - - bool _boundToExe; - byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; - int _cD; - Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index b787851290..3acde9c1ff 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -27,10 +27,10 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPackage.h" +#include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" #include "common/util.h" #include "common/file.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index dc8b4b684f..4356ae5519 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -29,7 +29,10 @@ #ifndef WINTERMUTE_BPKGFILE_H #define WINTERMUTE_BPKGFILE_H -#include "engines/wintermute/base/file/BFileEntry.h" +#include "engines/wintermute/base/file/base_file_entry.h" + +// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size +// as such it is not renamed to follow the convention of the rest of the files. namespace Common { class SeekableReadStream; diff --git a/engines/wintermute/base/file/BSaveThumbFile.cpp b/engines/wintermute/base/file/BSaveThumbFile.cpp deleted file mode 100644 index 4a75b7d7ce..0000000000 --- a/engines/wintermute/base/file/BSaveThumbFile.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/file/BSaveThumbFile.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { - close(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::open(const Common::String &filename) { - close(); - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; - - char *tempFilename = new char[strlen(filename.c_str()) - 8]; - strcpy(tempFilename, filename.c_str() + 9); - for (uint32 i = 0; i < strlen(tempFilename); i++) { - if (tempFilename[i] < '0' || tempFilename[i] > '9') { - tempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int slot = atoi(tempFilename); - delete [] tempFilename; - - char slotFilename[MAX_PATH_LENGTH + 1]; - _gameRef->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); - if (!pm) return STATUS_FAILED; - - _gameRef->_debugAbsolutePathWarning = false; - if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_debugAbsolutePathWarning = true; - delete pm; - return STATUS_FAILED; - } - _gameRef->_debugAbsolutePathWarning = true; - - bool res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = STATUS_OK; - } else res = STATUS_FAILED; - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return STATUS_FAILED; - - memcpy(buffer, (byte *)_data + _pos, size); - _pos += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) return STATUS_FAILED; - - uint32 newPos = 0; - - switch (whence) { - case SEEK_SET: - newPos = pos; - break; - case SEEK_END: - newPos = _size + pos; - break; - case SEEK_CUR: - newPos = _pos + pos; - break; - } - - if (newPos > _size) return STATUS_FAILED; - else _pos = newPos; - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BSaveThumbFile.h b/engines/wintermute/base/file/BSaveThumbFile.h deleted file mode 100644 index 5d33ac2220..0000000000 --- a/engines/wintermute/base/file/BSaveThumbFile.h +++ /dev/null @@ -1,52 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H - - -#include "engines/wintermute/base/file/BFile.h" - -namespace WinterMute { - -//TODO: Get rid of this -class CBSaveThumbFile : public CBFile { -public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); - virtual bool seek(uint32 pos, int whence = SEEK_SET); - virtual bool read(void *buffer, uint32 size); - virtual bool close(); - virtual bool open(const Common::String &filename); -private: - byte *_data; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp new file mode 100644 index 0000000000..99bf9cff3f --- /dev/null +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -0,0 +1,131 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/file/BPkgFile.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/file.h" +#include "common/zlib.h" + +namespace WinterMute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') fileName[i] = '/'; + } +} + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { + char fullPath[MAX_PATH_LENGTH]; + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; + + for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { + sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); + correctSlashes(fullPath); + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + // if we didn't find it in search paths, try to open directly + if (!file) { + strcpy(fullPath, filename.c_str()); + correctSlashes(fullPath); + + Common::File *tempFile = new Common::File(); + if (tempFile->open(fullPath)) { + file = tempFile; + } else { + delete tempFile; + } + } + + if (file) { + uint32 magic1, magic2; + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + + if (compressed) { + uint32 DataOffset, CompSize, UncompSize; + DataOffset = file->readUint32LE(); + CompSize = file->readUint32LE(); + UncompSize = file->readUint32LE(); + + byte *CompBuffer = new byte[CompSize]; + if (!CompBuffer) { + error("Error allocating memory for compressed file '%s'", filename.c_str()); + delete file; + return NULL; + } + + byte *data = new byte[UncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + file->seek(DataOffset + prefixSize, SEEK_SET); + file->read(CompBuffer, CompSize); + + if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + error("Error uncompressing file '%s'", filename.c_str()); + delete [] CompBuffer; + delete file; + return NULL; + } + + delete [] CompBuffer; + + return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; + } else { + file->seek(0, SEEK_SET); + return file; + } + + return file; + + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h new file mode 100644 index 0000000000..23e1a0a315 --- /dev/null +++ b/engines/wintermute/base/file/base_disk_file.h @@ -0,0 +1,42 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BDISKFILE_H +#define WINTERMUTE_BDISKFILE_H + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp new file mode 100644 index 0000000000..88a64cb147 --- /dev/null +++ b/engines/wintermute/base/file/base_file.cpp @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "common/memstream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBFile::CBFile(CBGame *inGame): CBBase(inGame) { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFile::~CBFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *CBFile::getMemStream() { + uint32 oldPos = getPos(); + seek(0); + byte *data = new byte[getSize()]; + read(data, getSize()); + seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h new file mode 100644 index 0000000000..b29fc41299 --- /dev/null +++ b/engines/wintermute/base/file/base_file.h @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILE_H +#define WINTERMUTE_BFILE_H + + +#include "engines/wintermute/base/base.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBFile : public CBBase { +protected: + uint32 _pos; + uint32 _size; +public: + virtual uint32 getSize() { + return _size; + }; + virtual uint32 getPos() { + return _pos; + }; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; + virtual bool isEOF(); + CBFile(CBGame *inGame); + virtual ~CBFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp new file mode 100644 index 0000000000..3b6f4c7c16 --- /dev/null +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -0,0 +1,50 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file_entry.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBFileEntry::~CBFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h new file mode 100644 index 0000000000..ed80821004 --- /dev/null +++ b/engines/wintermute/base/file/base_file_entry.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFILEENTRY_H +#define WINTERMUTE_BFILEENTRY_H + + +#include "engines/wintermute/base/base.h" + +namespace WinterMute { + +class CBPackage; + +class CBFileEntry : public CBBase { +public: + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + CBPackage *_package; + CBFileEntry(CBGame *inGame); + virtual ~CBFileEntry(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp new file mode 100644 index 0000000000..fab6409c00 --- /dev/null +++ b/engines/wintermute/base/file/base_package.cpp @@ -0,0 +1,104 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "common/file.h" +#include "common/stream.h" + +namespace WinterMute { +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { + _file = NULL; + _name = NULL; + _cD = 0; + _priority = 0; + _boundToExe = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBPackage::~CBPackage() { + if (_name) delete [] _name; + closeFilePointer(_file); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::open() { + if (_file) return STATUS_OK; + else { + _file = getFilePointer(); + return _file ? STATUS_OK : STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::close() { + delete _file; + _file = NULL; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { + bool ret; + if (DID_FAIL(ret = open())) return ret; + else { + if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; + if (file->read(buffer, size) != 1) return STATUS_FAILED; + else return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *CBPackage::getFilePointer() { + Common::File *file = _gameRef->_fileManager->openPackage(_name); + if (!file) { + _gameRef->_fileManager->requestCD(_cD, _name, ""); + file = _gameRef->_fileManager->openPackage(_name); + } + return file; +} + +////////////////////////////////////////////////////////////////////////// +void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { + delete file; + file = NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h new file mode 100644 index 0000000000..52fc4f9677 --- /dev/null +++ b/engines/wintermute/base/file/base_package.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BPACKAGE_H +#define WINTERMUTE_BPACKAGE_H + + +#include "engines/wintermute/base/base.h" + +namespace Common { +class SeekableReadStream; +} + +namespace WinterMute { + +class CBPackage : public CBBase { +public: + Common::SeekableReadStream *getFilePointer(); + void closeFilePointer(Common::SeekableReadStream *&file); + + bool _boundToExe; + byte _priority; + bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); + bool close(); + bool open(); + char *_name; + int _cD; + Common::SeekableReadStream *_file; + CBPackage(CBGame *inGame); + virtual ~CBPackage(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp new file mode 100644 index 0000000000..09cbae88fe --- /dev/null +++ b/engines/wintermute/base/file/base_resources.cpp @@ -0,0 +1,2820 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/file/base_resources.h" +#include "common/str.h" +#include "common/memstream.h" + +namespace WinterMute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + +Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { + if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); + } + return NULL; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h new file mode 100644 index 0000000000..6ec0541b5c --- /dev/null +++ b/engines/wintermute/base/file/base_resources.h @@ -0,0 +1,44 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BRESOURCES_H +#define WINTERMUTE_BRESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace WinterMute { + +class CBResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &fileName); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp new file mode 100644 index 0000000000..68200d3fc6 --- /dev/null +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -0,0 +1,146 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +CBSaveThumbFile::~CBSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::open(const Common::String &filename) { + close(); + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (uint32 i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int slot = atoi(tempFilename); + delete [] tempFilename; + + char slotFilename[MAX_PATH_LENGTH + 1]; + _gameRef->getSaveSlotFilename(slot, slotFilename); + CBPersistMgr *pm = new CBPersistMgr(_gameRef); + if (!pm) return STATUS_FAILED; + + _gameRef->_debugAbsolutePathWarning = false; + if (DID_FAIL(pm->initLoad(slotFilename))) { + _gameRef->_debugAbsolutePathWarning = true; + delete pm; + return STATUS_FAILED; + } + _gameRef->_debugAbsolutePathWarning = true; + + bool res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = STATUS_OK; + } else res = STATUS_FAILED; + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) return STATUS_FAILED; + + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSaveThumbFile::seek(uint32 pos, int whence) { + if (!_data) return STATUS_FAILED; + + uint32 newPos = 0; + + switch (whence) { + case SEEK_SET: + newPos = pos; + break; + case SEEK_END: + newPos = _size + pos; + break; + case SEEK_CUR: + newPos = _pos + pos; + break; + } + + if (newPos > _size) return STATUS_FAILED; + else _pos = newPos; + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h new file mode 100644 index 0000000000..42566581e2 --- /dev/null +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -0,0 +1,52 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSAVETHUMBFILE_H +#define WINTERMUTE_BSAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/base_file.h" + +namespace WinterMute { + +//TODO: Get rid of this +class CBSaveThumbFile : public CBFile { +public: + CBSaveThumbFile(CBGame *Game); + virtual ~CBSaveThumbFile(); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); +private: + byte *_data; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/BFont.cpp b/engines/wintermute/base/font/BFont.cpp deleted file mode 100644 index 5d0086c581..0000000000 --- a/engines/wintermute/base/font/BFont.cpp +++ /dev/null @@ -1,206 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/font/BFontBitmap.h" -#include "engines/wintermute/base/font/BFontTT.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFont, false) - -////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { -} - - -////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - -/* -////////////////////////////////////////////////////////////////////// -bool CBFont::loadFile(const char * Filename) -{ - BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ - _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - CBParser parser(_gameRef); - - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ - -////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFont::persist(CBPersistMgr *persistMgr) { - - CBObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { - if (isTrueType(gameRef, filename)) { - CBFontTT *font = new CBFontTT(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - CBFontBitmap *font = new CBFontBitmap(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; - - byte *WorkBuffer = buffer; - - char *params; - CBParser parser(gameRef); - - bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) - ret = true; - - delete [] buffer; - return ret; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFont.h b/engines/wintermute/base/font/BFont.h deleted file mode 100644 index a6ab757b0d..0000000000 --- a/engines/wintermute/base/font/BFont.h +++ /dev/null @@ -1,61 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H - -#include "engines/wintermute/base/BObject.h" - -#define NUM_CHARACTERS 256 - -namespace WinterMute { - -class CBFont: public CBObject { -public: - DECLARE_PERSISTENT(CBFont, CBObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - virtual void initLoop() {}; - virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); - - static CBFont *createFromFile(CBGame *game, const char *filename); - -private: - //bool loadBuffer(byte * Buffer); - //bool loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontBitmap.cpp b/engines/wintermute/base/font/BFontBitmap.cpp deleted file mode 100644 index 62576cdfea..0000000000 --- a/engines/wintermute/base/font/BFontBitmap.cpp +++ /dev/null @@ -1,540 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFontBitmap.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BFrame.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (maxLength >= 0 && str.size() > (uint32)maxLength) - str = Common::String(str.c_str(), (uint32)maxLength); - //str.substr(0, maxLength); // TODO: Remove - - int textWidth = 0; - for (int i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; - - if (text == NULL || text[0] == '\0') return _tileHeight; - - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - if (str.empty()) return 0; - - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool new_line = false; - bool long_line = false; - - if (draw) _gameRef->_renderer->startSpriteBatch(); - - while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) _gameRef->_renderer->endSpriteBatch(); - return NumLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { - end = index - 1; - RealLength = LineLength; - } - - if (str[index] == '\n') { - end = index - 1; - RealLength = LineLength; - new_line = true; - } - - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; - } - - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!new_line) { - end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; - } - } else LineLength += getCharWidth(str[index]); - - if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; - int StartX; - switch (align) { - case TAL_CENTER: - StartX = x + (width - RealLength) / 2; - break; - case TAL_RIGHT: - StartX = x + width - RealLength; - break; - case TAL_LEFT: - StartX = x; - break; - default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); - StartX += getCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (long_line) end--; - start = end + 2; - index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; - } - } - - if (draw) _gameRef->_renderer->endSpriteBatch(); - - return NumLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - Rect32 rect; - /* l t r b */ - int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; - - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); - bool handled = false; - if (_sprite) { - _sprite->GetCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); - } - handled = true; - } - } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - int widths[300]; - int num = 0, default_width = 8; - int lastWidth = 0; - int i; - int r = 255, g = 255, b = 255; - bool custoTrans = false; - char *surfaceFile = NULL; - char *spriteFile = NULL; - - bool autoWidth = false; - int spaceWidth = 0; - int expandWidth = 0; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = (char *)params; - break; - - case TOKEN_SPRITE: - spriteFile = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_WIDTHS: - parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { - _widths[lastWidth] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); - break; - - case TOKEN_WIDTHS_FRAME: - parser.scanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.scanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.scanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.scanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.scanStr(params, "%b", &autoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.scanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.scanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.scanStr(params, "%d", &spaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.scanStr(params, "%d", &expandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - if (spriteFile != NULL) { - delete _sprite; - _sprite = new CBSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(_gameRef); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - _gameRef->LOG(0, "Incomplete font definition"); - return STATUS_FAILED; - } - - if (autoWidth) { - // calculate characters width - getWidths(); - - // do we need to modify widths? - if (expandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; - - _widths[i] = (byte)NewWidth; - } - } - - // handle space character - uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; - - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { - if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { - _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { - - CBFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); - - persistMgr->transfer(TMEMBER(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); - - if (persistMgr->_saving) - persistMgr->putBytes(_widths, sizeof(_widths)); - else - persistMgr->getBytes(_widths, sizeof(_widths)); - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::getWidths() { - CBSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int minCol = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; - if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - minCol = MAX(col, minCol); - break; - } - } - if (minCol == _tileWidth - 1) break; - } - - _widths[i] = minCol + 1; - } - surf->endPixelOp(); - /* - _gameRef->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontBitmap.h b/engines/wintermute/base/font/BFontBitmap.h deleted file mode 100644 index 17bf433f65..0000000000 --- a/engines/wintermute/base/font/BFontBitmap.h +++ /dev/null @@ -1,72 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H - - -#include "engines/wintermute/base/font/BFont.h" - -namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { -public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) - bool loadBuffer(byte *Buffer); - bool loadFile(const char *filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); - - - bool getWidths(); - CBSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; - bool _wholeCell; - -private: - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontStorage.cpp b/engines/wintermute/base/font/BFontStorage.cpp deleted file mode 100644 index b5605cf2bc..0000000000 --- a/engines/wintermute/base/font/BFontStorage.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CBFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); - delete _fonts[i]; - } - _fonts.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { - if (!filename) return NULL; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - CBFont* font = new CBFont(_gameRef); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - CBFont *font = CBFont::createFromFile(_gameRef, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::removeFont(CBFont *font) { - if (!font) return STATUS_FAILED; - - for (int i = 0; i < _fonts.getSize(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.removeAt(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::persist(CBPersistMgr *persistMgr) { - - if (!persistMgr->_saving) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontStorage.h b/engines/wintermute/base/font/BFontStorage.h deleted file mode 100644 index 9759d5d25e..0000000000 --- a/engines/wintermute/base/font/BFontStorage.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace WinterMute { - -class CBFont; - -class CBFontStorage : public CBBase { -public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) - bool cleanup(bool warn = false); - bool removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; - bool initLoop(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/BFontTT.cpp b/engines/wintermute/base/font/BFontTT.cpp deleted file mode 100644 index 5f0c9fec1a..0000000000 --- a/engines/wintermute/base/font/BFontTT.cpp +++ /dev/null @@ -1,762 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/font/BFontTT.h" -#include "engines/wintermute/utils/PathUtil.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BParser.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CBFontTT, false) - -////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - _deletableFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { - clearCache(); - - for (int i = 0; i < _layers.getSize(); i++) { - delete _layers[i]; - } - _layers.removeAll(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (_gameRef->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; - } - } -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - measureText(textStr, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); - - - int textWidth, textHeight; - measureText(textStr, width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; - - WideString textStr = (char *)text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - //text = text.substr(0, MaxLength); // TODO: Remove - - CBRenderer *renderer = _gameRef->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - CBSurface *surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - minPriority = 0; - minIndex = i; - } else { - if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { - surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; - minIndex = i; - } - } - } - } - - // not found, create one - if (!surface) { - debugC(kWinterMuteDebugFont, "Draw text: %s", text); - surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); - if (surface) { - // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; - - _cachedTexts[minIndex]->_surface = surface; - _cachedTexts[minIndex]->_align = align; - _cachedTexts[minIndex]->_width = width; - _cachedTexts[minIndex]->_maxHeight = maxHeight; - _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; - _cachedTexts[minIndex]->_text = textStr; - _cachedTexts[minIndex]->_textOffset = textOffset; - _cachedTexts[minIndex]->_marked = true; - } - } - - - // and paint it - if (surface) { - Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { - uint32 color = _layers[i]->_color; - uint32 origForceAlpha = renderer->_forceAlphaColor; - if (renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); - renderer->_forceAlphaColor = 0; - } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - renderer->_forceAlphaColor = origForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO - //WrapText(text, width, maxHeight, lines); - Common::Array lines; - _font->wordWrapText(text, width, lines); - - Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; - if (align == TAL_LEFT) { - alignment = Graphics::kTextAlignLeft; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - alignment = Graphics::kTextAlignRight; - } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); - } - - debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); -// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; - Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - else // We are using a fallback, they can't do 32bpp - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); - uint32 useColor = 0xffffffff; - Common::Array::iterator it; - int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += (int)_lineHeight; - } - - CBSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; - - float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} - -////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); - - delete [] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - _gameRef->LOG(0, "'TTFONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - uint32 BaseColor = 0x00000000; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.scanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.scanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.scanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.scanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.scanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); - } - break; - - case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TTFONT definition"); - return STATUS_FAILED; - } - - // create at least one layer - if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); - } - - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - CBParser parser(_gameRef); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.scanStr(params, "%d", &layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.scanStr(params, "%d", &layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); - - - // persist layers - int numLayers; - if (persistMgr->_saving) { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); - } else { - numLayers = _layers.getSize(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->_saving) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -bool CBFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; - - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); - if (!file) { - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); - if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; - } - } - - if (file) { -#ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - _gameRef->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } - if (maxWidth >= 0) { - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - Common::Array::iterator it; - textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { - textWidth = MAX(textWidth, _font->getStringWidth(*it)); - } - - //WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * getLineHeight()); - } else { - textWidth = _font->getStringWidth(text); - textHeight = _fontHeight; - } - /* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/BFontTT.h b/engines/wintermute/base/font/BFontTT.h deleted file mode 100644 index 9b995b293e..0000000000 --- a/engines/wintermute/base/font/BFontTT.h +++ /dev/null @@ -1,180 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H - -#include "engines/wintermute/base/font/BFontStorage.h" -#include "engines/wintermute/base/font/BFont.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace WinterMute { - -class CBFontTT : public CBFont { -private: - ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - CBSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - CBCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~CBCachedTTFontText() { - if (_surface) delete _surface; - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { - public: - CBTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - bool persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - -public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); - - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - bool loadBuffer(byte *buffer); - bool loadFile(const char *filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - bool parseLayer(CBTTFontLayer *layer, byte *buffer); - - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); - void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - - - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - bool initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _ascender; - float _descender; - float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - CBArray _layers; - void clearCache(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp new file mode 100644 index 0000000000..8976cfdabd --- /dev/null +++ b/engines/wintermute/base/font/base_font.cpp @@ -0,0 +1,206 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFont, false) + +////////////////////////////////////////////////////////////////////// +CBFont::CBFont(CBGame *inGame): CBObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +CBFont::~CBFont() { +} + + +////////////////////////////////////////////////////////////////////// +void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int CBFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + +/* +////////////////////////////////////////////////////////////////////// +bool CBFont::loadFile(const char * Filename) +{ + BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + if(Buffer==NULL){ + _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename)+1]; + strcpy(_filename, filename); + + if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] Buffer; + + return ret; +} + + +TOKEN_DEF_START + TOKEN_DEF (FONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFont::loadBuffer(byte * Buffer) +{ + TOKEN_TABLE_START(commands) + TOKEN_TABLE (FONT) + TOKEN_TABLE_END + + char* params; + int cmd; + CBParser parser(_gameRef); + + if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + Buffer = (byte *)params; + + while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) + { + switch (cmd) + { + case TOKEN_IMAGE: + surface_file = (char*)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custo_trans = true; + break; + } + + + } + if (cmd == PARSERR_TOKENNOTFOUND){ + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} +*/ + +////////////////////////////////////////////////////////////////////////// +int CBFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFont::persist(CBPersistMgr *persistMgr) { + + CBObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { + if (isTrueType(gameRef, filename)) { + CBFontTT *font = new CBFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + CBFontBitmap *font = new CBFontBitmap(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) return false; + + byte *WorkBuffer = buffer; + + char *params; + CBParser parser(gameRef); + + bool ret = false; + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + ret = true; + + delete [] buffer; + return ret; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h new file mode 100644 index 0000000000..3df3090bb9 --- /dev/null +++ b/engines/wintermute/base/font/base_font.h @@ -0,0 +1,61 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONT_H +#define WINTERMUTE_BFONT_H + +#include "engines/wintermute/base/base_object.h" + +#define NUM_CHARACTERS 256 + +namespace WinterMute { + +class CBFont: public CBObject { +public: + DECLARE_PERSISTENT(CBFont, CBObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {}; + virtual void afterLoad() {}; + CBFont(CBGame *inGame); + virtual ~CBFont(); + + static CBFont *createFromFile(CBGame *game, const char *filename); + +private: + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); + static bool isTrueType(CBGame *game, const char *filename); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp new file mode 100644 index 0000000000..ef730afb0a --- /dev/null +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -0,0 +1,540 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +CBFontBitmap::~CBFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { + textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) + str = Common::String(str.c_str(), (uint32)maxLength); + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (int i = 0; i < str.size(); i++) { + textWidth += getCharWidth(str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) return 0; + + if (text == NULL || text[0] == '\0') return _tileHeight; + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + if (str.empty()) return 0; + + int LineLength = 0; + int RealLength = 0; + int NumLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool new_line = false; + bool long_line = false; + + if (draw) _gameRef->_renderer->startSpriteBatch(); + + while (!done) { + if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (draw) _gameRef->_renderer->endSpriteBatch(); + return NumLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + RealLength = LineLength; + } + + if (str[index] == '\n') { + end = index - 1; + RealLength = LineLength; + new_line = true; + } + + if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + RealLength = LineLength; + new_line = true; + long_line = true; + } + + if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!new_line) { + end = index; + LineLength += getCharWidth(str[index]); + RealLength = LineLength; + } + } else LineLength += getCharWidth(str[index]); + + if ((LineLength > width) || done || new_line) { + if (end < 0) done = true; + int StartX; + switch (align) { + case TAL_CENTER: + StartX = x + (width - RealLength) / 2; + break; + case TAL_RIGHT: + StartX = x + width - RealLength; + break; + case TAL_LEFT: + StartX = x; + break; + default: + error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) drawChar(str[i], StartX, y); + StartX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (long_line) end--; + start = end + 2; + index = end + 1; + LineLength = 0; + new_line = false; + long_line = false; + NumLines++; + } + } + + if (draw) _gameRef->_renderer->endSpriteBatch(); + + return NumLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void CBFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) c--; + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) tileWidth = _tileWidth; + else tileWidth = _widths[c]; + + CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->GetCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, default_width = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &default_width); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new CBSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new CBSubFrame(_gameRef); + if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); + else _subframe->setSurface(surfaceFile); + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + _gameRef->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int NewWidth = (int)_widths[i] + expandWidth; + if (NewWidth < 0) NewWidth = 0; + + _widths[i] = (byte)NewWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) spaceChar--; + + if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; + else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { + + CBFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->_saving) + persistMgr->putBytes(_widths, sizeof(_widths)); + else + persistMgr->getBytes(_widths, sizeof(_widths)); + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getCharWidth(byte index) { + if (_fontextFix) index--; + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontBitmap::getWidths() { + CBSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { + if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) surf = _subframe->_surface; + if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) break; + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + _gameRef->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h new file mode 100644 index 0000000000..8af530cbc9 --- /dev/null +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -0,0 +1,72 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTBITMAP_H +#define WINTERMUTE_BFONTBITMAP_H + + +#include "engines/wintermute/base/font/base_font.h" + +namespace WinterMute { +class CBSubFrame; +class CBFontBitmap : public CBFont { +public: + DECLARE_PERSISTENT(CBFontBitmap, CBFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const char *filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + CBFontBitmap(CBGame *inGame); + virtual ~CBFontBitmap(); + + + bool getWidths(); + CBSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + CBSubFrame *_subframe; + bool _wholeCell; + +private: + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp new file mode 100644 index 0000000000..13f779f2cb --- /dev/null +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -0,0 +1,135 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CBFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +CBFontStorage::~CBFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::cleanup(bool warn) { + for (int i = 0; i < _fonts.getSize(); i++) { + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + delete _fonts[i]; + } + _fonts.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::initLoop() { + for (int i = 0; i < _fonts.getSize(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CBFont *CBFontStorage::addFont(const char *filename) { + if (!filename) return NULL; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + CBFont* font = new CBFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + CBFont *font = CBFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::removeFont(CBFont *font) { + if (!font) return STATUS_FAILED; + + for (int i = 0; i < _fonts.getSize(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.removeAt(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontStorage::persist(CBPersistMgr *persistMgr) { + + if (!persistMgr->_saving) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h new file mode 100644 index 0000000000..7c88e9a2f4 --- /dev/null +++ b/engines/wintermute/base/font/base_font_storage.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTSTORAGE_H +#define WINTERMUTE_BFONTSTORAGE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace WinterMute { + +class CBFont; + +class CBFontStorage : public CBBase { +public: + DECLARE_PERSISTENT(CBFontStorage, CBBase) + bool cleanup(bool warn = false); + bool removeFont(CBFont *font); + CBFont *addFont(const char *filename); + CBFontStorage(CBGame *inGame); + virtual ~CBFontStorage(); + CBArray _fonts; + bool initLoop(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp new file mode 100644 index 0000000000..a52922fb76 --- /dev/null +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -0,0 +1,762 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBFontTT, false) + +////////////////////////////////////////////////////////////////////////// +CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + +#if 0 + _fTFace = NULL; + _fTStream = NULL; +#endif + + _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; + _horDpi = _vertDpi = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +CBFontTT::~CBFontTT(void) { + clearCache(); + + for (int i = 0; i < _layers.getSize(); i++) { + delete _layers[i]; + } + _layers.removeAll(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; + +#if 0 + if (_fTFace) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + } + delete[] _fTStream; + _fTStream = NULL; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (_gameRef->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) continue; + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else _cachedTexts[i]->_marked = false; + } + } +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); + else textStr = StringUtil::ansiToWide((char *)text); + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((char *)text, "") == 0) return; + + WideString textStr = (char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + //text = text.substr(0, MaxLength); // TODO: Remove + + CBRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + CBSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + debugC(kWinterMuteDebugFont, "Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + _cachedTexts[minIndex] = new CBCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (int i = 0; i < _layers.getSize(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + } + + debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + if (_deletableFont) // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + else // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + uint32 useColor = 0xffffffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); it++) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + CBSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; +#if 0 //TODO + int textHeight = lines.size() * (_maxCharHeight + _ascender); + SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); + + SDL_LockSurface(surface); + + int posY = (int)GetLineHeight() - (int)_descender; + + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + int posX = 0; + + switch (align) { + case TAL_CENTER: + posX += (width - line->GetWidth()) / 2; + break; + + case TAL_RIGHT: + posX += width - line->GetWidth(); + break; + } + + + textOffset = 0; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + textOffset = MAX(textOffset, glyph->GetBearingY()); + } + + + int origPosX = posX; + + wchar_t prevChar = L'\0'; + for (size_t i = 0; i < line->GetText().size(); i++) { + wchar_t ch = line->GetText()[i]; + + GlyphInfo *glyph = _glyphCache->GetGlyph(ch); + if (!glyph) continue; + + float kerning = 0; + if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + posX += (int)kerning; + + + if (glyph->GetBearingY() > 0) { + int i = 10; + } + + SDL_Rect rect; + rect.x = posX + glyph->GetBearingX(); + rect.y = posY - glyph->GetBearingY() + textOffset; + rect.w = glyph->GetImage()->w; + rect.h = glyph->GetImage()->h; + + BlitSurface(glyph->GetImage(), surface, &rect); + + prevChar = ch; + posX += (int)(glyph->GetAdvanceX()); + posY += (int)(glyph->GetAdvanceY()); + } + + if (_isUnderline) { + for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { + Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; + Uint32 *buf32 = (Uint32 *)buf; + + buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); + } + } + + SDL_UnlockSurface(surface); + + delete line; + line = NULL; + posY += GetLineHeight(); + } + + CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { + SDL_FreeSurface(surface); + return wmeSurface; + } else { + SDL_FreeSurface(surface); + delete wmeSurface; + return NULL; + } +#endif + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { + //SDL_BlitSurface(src, NULL, target, targetRect); + warning("CBFontTT::BlitSurface - not ported yet"); +#if 0 + for (int y = 0; y < src->h; y++) { + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + + + uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; + uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; + + uint32 *srcBuf32 = (uint32 *)srcBuf; + uint32 *tgtBuf32 = (uint32 *)tgtBuf; + + for (int x = 0; x < src->w; x++) { + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + + tgtBuf32[x + targetRect->x] = srcBuf32[x]; + } + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +int CBFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadFile(const char *filename) { + byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + _filename = new char [strlen(filename) + 1]; + strcpy(_filename, filename); + + if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + + delete [] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool CBFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + _gameRef->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 BaseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + CBUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + } + break; + + case TOKEN_LAYER: { + CBTTFontLayer *Layer = new CBTTFontLayer; + if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); + else { + delete Layer; + Layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.getSize() == 0) { + CBTTFontLayer *Layer = new CBTTFontLayer; + Layer->_color = BaseColor; + _layers.add(Layer); + } + + if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + CBParser parser(_gameRef); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) return STATUS_FAILED; + else return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::persist(CBPersistMgr *persistMgr) { + CBFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->_saving) { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + } else { + numLayers = _layers.getSize(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + CBTTFontLayer *layer = new CBTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->_saving) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBFontTT::initFont() { + if (!_fontFile) return STATUS_FAILED; + + Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + if (!file) { + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + if (!file) { + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + } + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +#if 0 + FT_Error error; + + float vertDpi = 96.0; + float horDpi = 96.0; + + + _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; + memset(_fTStream, 0, sizeof(*_fTStream)); + + _fTStream->read = CBFontTT::FTReadSeekProc; + _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->descriptor.pointer = file; + _fTStream->size = file->GetSize(); + + FT_Open_Args args; + args.flags = FT_OPEN_STREAM; + args.stream = _fTStream; + + error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); + if (error) { + SAFE_DELETE_ARRAY(_fTStream); + _gameRef->_fileManager->closeFile(file); + return STATUS_FAILED; + } + + error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); + if (error) { + FT_Done_Face(_fTFace); + _fTFace = NULL; + return STATUS_FAILED; + } + + // http://en.wikipedia.org/wiki/E_(typography) + float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi + float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float pixelsPerUnit = pixelsPerEm * EmsPerUnit; + + // bounding box in pixels + float xMin = _fTFace->bbox.xMin * pixelsPerUnit; + float xMax = _fTFace->bbox.xMax * pixelsPerUnit; + float yMin = _fTFace->bbox.yMin * pixelsPerUnit; + float yMax = _fTFace->bbox.yMax * pixelsPerUnit; + + // metrics in pixels + _ascender = _fTFace->ascender * pixelsPerUnit; + _descender = - _fTFace->descender * pixelsPerUnit; + _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; + _underlinePos = - _fTFace->underline_position * pixelsPerUnit; + + // max character size (used for texture grid) + _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); + _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); + + _glyphCache = new FontGlyphCache(); + _glyphCache->Initialize(); + +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + // TODO: This function gets called a lot, so warnings like these drown out the usefull information + static bool hasWarned = false; + if (!hasWarned) { + hasWarned = true; + warning("Todo: Test Mesuretext"); + } + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); it++) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h new file mode 100644 index 0000000000..4d8e71a3ff --- /dev/null +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -0,0 +1,180 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BFONTTT_H +#define WINTERMUTE_BFONTTT_H + +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace WinterMute { + +class CBFontTT : public CBFont { +private: + ////////////////////////////////////////////////////////////////////////// + class CBCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + CBSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + CBCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~CBCachedTTFontText() { + if (_surface) delete _surface; + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class CBTTFontLayer { + public: + CBTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + + ////////////////////////////////////////////////////////////////////////// + class TextLine { + public: + TextLine(const WideString &text, int width) { + _text = text; + _width = width; + } + + const WideString getText() const { + return _text; + } + int getWidth() const { + return _width; + } + private: + WideString _text; + int _width; + }; + typedef Common::List TextLineList; + + +public: + DECLARE_PERSISTENT(CBFontTT, CBFont) + CBFontTT(CBGame *inGame); + virtual ~CBFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + bool loadBuffer(byte *buffer); + bool loadFile(const char *filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(CBTTFontLayer *layer, byte *buffer); + + void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); + + + CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _ascender; + float _descender; + float _lineHeight; + float _underlinePos; + float _pointSize; + float _vertDpi; + float _horDpi; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + CBArray _layers; + void clearCache(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index f1e27c9622..fb6b23db2b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -28,10 +28,10 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/graphics/transparentSurface.h" -#include "engines/wintermute/utils/StringUtil.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#include "engines/wintermute/utils/string_util.h" #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 646a9ddd2d..6cda3e6b46 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BIMAGE_H #define WINTERMUTE_BIMAGE_H -#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/base.h" #include "graphics/surface.h" #include "graphics/pixelformat.h" #include "graphics/decoders/image_decoder.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 5c5ebd91b4..a8c19362f6 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -27,11 +27,11 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/BActiveRect.h" +#include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/BSubFrame.h" -#include "engines/wintermute/base/BRegion.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 81c13f8b39..d743f19791 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -31,7 +31,7 @@ #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" +#include "engines/wintermute/base/base.h" #include "common/rect.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 6c0ca40765..73b385d180 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/wintypes.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/base_surface.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index f5fbd495aa..22c1fb83b8 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_BSURFACE_H #define WINTERMUTE_BSURFACE_H -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" #include "graphics/surface.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ee971ab6c9..dbd2511928 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -28,15 +28,15 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/BRegistry.h" +#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/base/BSurfaceStorage.h" +#include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/math/MathUtil.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSprite.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" #include "common/system.h" -#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/transparent_surface.h" #include "common/queue.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 66c6e4a61a..87c5731b49 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -26,9 +26,9 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/base/BGame.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -36,7 +36,7 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" -#include "engines/wintermute/graphics/transparentSurface.h" +#include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/graphics/tga.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" diff --git a/engines/wintermute/base/particles/PartEmitter.cpp b/engines/wintermute/base/particles/PartEmitter.cpp deleted file mode 100644 index 97de1fe044..0000000000 --- a/engines/wintermute/base/particles/PartEmitter.cpp +++ /dev/null @@ -1,1199 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/particles/PartEmitter.h" -#include "engines/wintermute/base/particles/PartParticle.h" -#include "engines/wintermute/math/Vector2.h" -#include "engines/wintermute/math/Matrix4.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BRegion.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/math.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CPartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { - _width = _height = 0; - - CBPlatform::setRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = Owner; -} - - -////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - for (int i = 0; i < _forces.getSize(); i++) { - delete _forces[i]; - } - _forces.removeAll(); - - - for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; - } - _sprites.removeAll(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; - - // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; - } - - // check if file exists - Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); - if (!File) { - _gameRef->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else _gameRef->_fileManager->closeFile(File); - - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; - _sprites.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; - - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); - - float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); - - float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); - - int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); - - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); - - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); - - if (!CBPlatform::isRectEmpty(&_border)) { - int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); - int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); - int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); - int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - - particle->_border = _border; - particle->_border.left += thicknessLeft; - particle->_border.right -= thicknessRight; - particle->_border.top += thicknessTop; - particle->_border.bottom -= thicknessBottom; - } - - Vector2 vecPos((float)posX, (float)posY); - Vector2 vecVel(0, velocity); - - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); - particle->_alpha1 = alpha; - particle->_alpha2 = alpha; - } - - particle->_creationTime = currentTime; - particle->_pos = vecPos; - particle->_posZ = posZ; - particle->_velocity = vecVel; - particle->_scale = scale; - particle->_lifeTime = lifeTime; - particle->_rotation = rotation; - particle->_angVelocity = angVelocity; - particle->_growthRate = growthRate; - particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); - particle->fadeIn(currentTime, _fadeInTime); - - - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->update(this, currentTime, timerDelta); - - if (!_particles[i]->_isDead) numLive++; - } - - - // we're understaffed - if (numLive < _maxParticles) { - bool needsSort = false; - if ((int)(currentTime - _lastGenTime) > _genInterval) { - _lastGenTime = currentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return STATUS_OK; - } - - int toGen = MIN(_genAmount, _maxParticles - numLive); - while (toGen > 0) { - int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - CPartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { - particle = new CPartParticle(_gameRef); - _particles.add(particle); - } - initParticle(particle, currentTime, timerDelta); - needsSort = true; - - toGen--; - } - } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) - sortParticlesByZ(); - - // we actually generated some particles and we're not in fast-forward mode - if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::display(CBRegion *region) { - if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); - - for (int i = 0; i < _particles.getSize(); i++) { - if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; - } - - _particles[i]->display(this); - } - - if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 delta = 500; - int steps = _overheadTime / delta; - uint32 currentTime = _gameRef->_timer - _overheadTime; - - for (int i = 0; i < steps; i++) { - updateInternal(currentTime, delta); - currentTime += delta; - } - _overheadTime = 0; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::sortParticlesByZ() { - // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; - - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; - - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new CPartForce(_gameRef); - if (force) { - force->setName(name); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeForce(const char *name) { - for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { - delete _forces[i]; - _forces.removeAt(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetBorder") == 0) { - stack->correctParams(4); - int borderX = stack->pop()->getInt(); - int borderY = stack->pop()->getInt(); - int borderWidth = stack->pop()->getInt(); - int borderHeight = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBorderThickness") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Start") == 0) { - stack->correctParams(1); - _overheadTime = stack->pop()->getInt(); - stack->pushBool(DID_SUCCEED(start())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Stop") == 0) { - stack->correctParams(0); - - for (int i = 0; i < _particles.getSize(); i++) { - delete _particles[i]; - } - _particles.removeAll(); - - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Resume") == 0) { - stack->correctParams(0); - _running = true; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddGlobalForce") == 0) { - stack->correctParams(3); - const char *forceName = stack->pop()->getString(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddPointForce") == 0) { - stack->correctParams(5); - const char *forceName = stack->pop()->getString(); - int posX = stack->pop()->getInt(); - int posY = stack->pop()->getInt(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveForce") == 0) { - stack->correctParams(1); - const char *forceName = stack->pop()->getString(); - - stack->pushBool(DID_SUCCEED(removeForce(forceName))); - - return STATUS_OK; - } - - else return CBObject::scCallMethod(script, stack, thisStack, name); -} - -////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scValue->setFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scValue->setFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->setBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _scValue->setFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _scValue->setFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->setBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _scValue->setInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _scValue->setInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->setBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _scValue->setInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _scValue->setInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->setFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->setFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _scValue->setFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _scValue->setFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _scValue->setInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _scValue->setInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->setBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _scValue->setInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { - int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; - } - _scValue->setInt(numAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->setInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->setInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _scValue->setInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _scValue->setInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->setInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->setFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->setFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->setBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _scValue->setBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); - return _scValue; - } - - else return CBObject::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); - return STATUS_OK; - } - - else return CBObject::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); - - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); - - persistMgr->transfer(TMEMBER(_velocity1)); - persistMgr->transfer(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); - - persistMgr->transfer(TMEMBER(_scale1)); - persistMgr->transfer(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); - - persistMgr->transfer(TMEMBER(_maxParticles)); - - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); - - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); - - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); - - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); - - persistMgr->transfer(TMEMBER(_angVelocity1)); - persistMgr->transfer(TMEMBER(_angVelocity2)); - - persistMgr->transfer(TMEMBER(_rotation1)); - persistMgr->transfer(TMEMBER(_rotation2)); - - persistMgr->transfer(TMEMBER(_growthRate1)); - persistMgr->transfer(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - - persistMgr->transfer(TMEMBER(_useRegion)); - - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - - persistMgr->transfer(TMEMBER(_emitEvent)); - persistMgr->transfer(TMEMBER(_owner)); - - - _sprites.persist(persistMgr); - - int numForces; - if (persistMgr->_saving) { - numForces = _forces.getSize(); - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(_gameRef); - force->persist(persistMgr); - _forces.add(force); - } - } - - int numParticles; - if (persistMgr->_saving) { - numParticles = _particles.getSize(); - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(_gameRef); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartEmitter.h b/engines/wintermute/base/particles/PartEmitter.h deleted file mode 100644 index 5156783653..0000000000 --- a/engines/wintermute/base/particles/PartEmitter.h +++ /dev/null @@ -1,139 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/base/BObject.h" -#include "engines/wintermute/base/particles/PartForce.h" - -namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { -public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) - - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); - - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - Rect32 _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - int _fadeOutTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - CBScriptHolder *_owner; - - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(CBRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); - - CBArray _forces; - - // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - CPartForce *addForceByName(const char *name); - int static compareZ(const void *obj1, const void *obj2); - bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); - bool updateInternal(uint32 currentTime, uint32 timerDelta); - uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/PartForce.cpp b/engines/wintermute/base/particles/PartForce.cpp deleted file mode 100644 index b864c05292..0000000000 --- a/engines/wintermute/base/particles/PartForce.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/particles/PartForce.h" -#include "engines/wintermute/base/BPersistMgr.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartForce::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartForce.h b/engines/wintermute/base/particles/PartForce.h deleted file mode 100644 index 640c8d7f20..0000000000 --- a/engines/wintermute/base/particles/PartForce.h +++ /dev/null @@ -1,57 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/base/BNamedObject.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartForce : public CBNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - bool persist(CBPersistMgr *PersistMgr); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/PartParticle.cpp b/engines/wintermute/base/particles/PartParticle.cpp deleted file mode 100644 index 1439231993..0000000000 --- a/engines/wintermute/base/particles/PartParticle.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/particles/PartParticle.h" -#include "engines/wintermute/base/particles/PartEmitter.h" -#include "engines/wintermute/base/BSprite.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - CBPlatform::setRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(_gameRef, _gameRef); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { - if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - - return STATUS_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _isDead = true; - return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - - return STATUS_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) - fadeOut(currentTime, emitter->_fadeOutTime); - else - _isDead = true; - } - } - - // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) - fadeOut(currentTime, emitter->_fadeOutTime); - } - if (_state != PARTICLE_NORMAL) return STATUS_OK; - - // update alpha - if (_lifeTime > 0) { - int age = (int)(currentTime - _creationTime); - int alphaDelta = (int)(_alpha2 - _alpha1); - - _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); - } - - // update position - float elapsedTime = (float)timerDelta / 1000.f; - - for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; - switch (force->_type) { - case CPartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case CPartForce::FORCE_POINT: { - Vector2 vecDist = force->_pos - _pos; - float dist = fabs(vecDist.length()); - - dist = 100.0f / dist; - - _velocity += force->_direction * dist * elapsedTime; - } - break; - } - } - _pos += _velocity * elapsedTime; - - // update rotation - _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) - _scale += _scale / 100.0f * _growthRate * elapsedTime; - else - _scale += _growthRate * elapsedTime; - - if (_scale <= 0.0f) - _isDead = true; - - - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::display(CPartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; - - _sprite->GetCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CPartParticle::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_angVelocity)); - persistMgr->transfer(TMEMBER(_rotation)); - persistMgr->transfer(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - - if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/PartParticle.h b/engines/wintermute/base/particles/PartParticle.h deleted file mode 100644 index ab5730d3c5..0000000000 --- a/engines/wintermute/base/particles/PartParticle.h +++ /dev/null @@ -1,90 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTPARTICLE_H -#define WINTERMUTE_PARTPARTICLE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/math/Rect32.h" -#include "engines/wintermute/math/Vector2.h" - -namespace WinterMute { - -class CPartEmitter; -class CBSprite; -class CBPersistMgr; - -class CPartParticle : public CBBase { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - CBSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(CPartEmitter *emitter); - - bool setSprite(const char *filename); - - bool fadeIn(uint32 currentTime, int fadeTime); - bool fadeOut(uint32 currentTime, int fadeTime); - - bool persist(CBPersistMgr *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp new file mode 100644 index 0000000000..11ebafd329 --- /dev/null +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -0,0 +1,1199 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/math.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CPartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { + _width = _height = 0; + + CBPlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = Owner; +} + + +////////////////////////////////////////////////////////////////////////// +CPartEmitter::~CPartEmitter(void) { + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + for (int i = 0; i < _forces.getSize(); i++) { + delete _forces[i]; + } + _forces.removeAll(); + + + for (int i = 0; i < _sprites.getSize(); i++) { + delete [] _sprites[i]; + } + _sprites.removeAll(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addSprite(const char *filename) { + if (!filename) return STATUS_FAILED; + + // do we already have the file? + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + } + + // check if file exists + Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else _gameRef->_fileManager->closeFile(File); + + char *Str = new char[strlen(filename) + 1]; + strcpy(Str, filename); + _sprites.add(Str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeSprite(const char *filename) { + for (int i = 0; i < _sprites.getSize(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete [] _sprites[i]; + _sprites.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) return STATUS_FAILED; + if (_sprites.getSize() == 0) return STATUS_FAILED; + + int posX = CBUtils::randomInt(_posX, _posX + _width); + int posY = CBUtils::randomInt(_posY, _posY + _height); + float posZ = CBUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + + float scale; + if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + else scale = CBUtils::randomFloat(_scale1, _scale2); + + int lifeTime; + if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + + float angle = CBUtils::randomAngle(_angle1, _angle2); + int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + + float rotation = CBUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + + if (!CBPlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = CBUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) return STATUS_FAILED; + else return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::update() { + if (!_running) return STATUS_OK; + else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) numLive++; + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + CPartParticle *particle; + if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; + else { + particle = new CPartParticle(_gameRef); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + sortParticlesByZ(); + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::display(CBRegion *region) { + if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + + for (int i = 0; i < _particles.getSize(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + } + + _particles[i]->display(this); + } + + if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::start() { + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = _gameRef->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::sortParticlesByZ() { + // sort particles by _posY + qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CPartEmitter::compareZ(const void *obj1, const void *obj2) { + CPartParticle *p1 = *(CPartParticle **)obj1; + CPartParticle *p2 = *(CPartParticle **)obj2; + + if (p1->_posZ < p2->_posZ) return -1; + else if (p1->_posZ > p2->_posZ) return 1; + else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorder(int x, int y, int width, int height) { + CBPlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +CPartForce *CPartEmitter::addForceByName(const char *name) { + CPartForce *force = NULL; + + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new CPartForce(_gameRef); + if (force) { + force->setName(name); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { + CPartForce *force = addForceByName(name); + if (!force) return STATUS_FAILED; + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::removeForce(const char *name) { + for (int i = 0; i < _forces.getSize(); i++) { + if (scumm_stricmp(name, _forces[i]->_name) == 0) { + delete _forces[i]; + _forces.removeAt(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (int i = 0; i < _particles.getSize(); i++) { + delete _particles[i]; + } + _particles.removeAll(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } + + else return CBObject::scCallMethod(script, stack, thisStack, name); +} + +////////////////////////////////////////////////////////////////////////// +CScValue *CPartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (int i = 0; i < _particles.getSize(); i++) { + if (_particles[i] && !_particles[i]->_isDead) numAlive++; + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) _scValue->setNULL(); + else _scValue->setString(_emitEvent); + return _scValue; + } + + else return CBObject::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) _alpha1 = 0; + if (_alpha1 > 255) _alpha1 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) _alpha2 = 0; + if (_alpha2 > 255) _alpha2 = 255; + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + return STATUS_OK; + } + + else return CBObject::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CPartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CPartEmitter::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + int numForces; + if (persistMgr->_saving) { + numForces = _forces.getSize(); + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < _forces.getSize(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (int i = 0; i < numForces; i++) { + CPartForce *force = new CPartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + int numParticles; + if (persistMgr->_saving) { + numParticles = _particles.getSize(); + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < _particles.getSize(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (int i = 0; i < numParticles; i++) { + CPartParticle *particle = new CPartParticle(_gameRef); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h new file mode 100644 index 0000000000..cff0a1ec83 --- /dev/null +++ b/engines/wintermute/base/particles/part_emitter.h @@ -0,0 +1,139 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/particles/part_force.h" + +namespace WinterMute { +class CBRegion; +class CPartParticle; +class CPartEmitter : public CBObject { +public: + DECLARE_PERSISTENT(CPartEmitter, CBObject) + + CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); + virtual ~CPartEmitter(void); + + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + int _fadeOutTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + CBScriptHolder *_owner; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(CBRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + CBArray _forces; + + // scripting interface + virtual CScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, CScValue *value); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + CPartForce *addForceByName(const char *name); + int static compareZ(const void *obj1, const void *obj2); + bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + CBArray _particles; + CBArray _sprites; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp new file mode 100644 index 0000000000..2f330c21b0 --- /dev/null +++ b/engines/wintermute/base/particles/part_force.cpp @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/particles/part_force.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +CPartForce::~CPartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartForce::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_name)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h new file mode 100644 index 0000000000..f0a6d66c43 --- /dev/null +++ b/engines/wintermute/base/particles/part_force.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/math/vector2.h" + +namespace WinterMute { + +class CPartForce : public CBNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + CPartForce(CBGame *inGame); + virtual ~CPartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(CBPersistMgr *PersistMgr); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp new file mode 100644 index 0000000000..931f7558c7 --- /dev/null +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -0,0 +1,257 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////////// +CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + CBPlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +CPartParticle::~CPartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::setSprite(const char *filename) { + if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + CSysClassRegistry::getInstance()->_disabled = true; + _sprite = new CBSprite(_gameRef, _gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + CSysClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) + fadeOut(currentTime, emitter->_fadeOutTime); + else + _isDead = true; + } + } + + // particle hit the border + if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!CBPlatform::ptInRect(&_border, p)) + fadeOut(currentTime, emitter->_fadeOutTime); + } + if (_state != PARTICLE_NORMAL) return STATUS_OK; + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (int i = 0; i < emitter->_forces.getSize(); i++) { + CPartForce *force = emitter->_forces[i]; + switch (force->_type) { + case CPartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case CPartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = CBUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) + _scale += _scale / 100.0f * _growthRate * elapsedTime; + else + _scale += _growthRate * elapsedTime; + + if (_scale <= 0.0f) + _isDead = true; + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::display(CPartEmitter *emitter) { + if (!_sprite) return STATUS_FAILED; + if (_isDead) return STATUS_OK; + + _sprite->GetCurrentFrame(); + return _sprite->display(_pos.x, _pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CPartParticle::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->_saving) { + persistMgr->transfer(TMEMBER(_sprite->_filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + CSysClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + CSysClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h new file mode 100644 index 0000000000..0b256d44ec --- /dev/null +++ b/engines/wintermute/base/particles/part_particle.h @@ -0,0 +1,90 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/math/vector2.h" + +namespace WinterMute { + +class CPartEmitter; +class CBSprite; +class CBPersistMgr; + +class CPartParticle : public CBBase { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + CPartParticle(CBGame *inGame); + virtual ~CPartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + CBSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(CPartEmitter *emitter); + + bool setSprite(const char *filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(CBPersistMgr *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/SXArray.cpp b/engines/wintermute/base/scriptables/SXArray.cpp deleted file mode 100644 index 425118a3e7..0000000000 --- a/engines/wintermute/base/scriptables/SXArray.cpp +++ /dev/null @@ -1,238 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/system/SysInstance.h" -#include "engines/wintermute/base/scriptables/SXArray.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXArray, false) - -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { - return new CSXArray(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); - - int numParams = stack->pop()->getInt(0); - - if (numParams == 1) _length = stack->pop()->getInt(0); - else if (numParams > 1) { - _length = numParams; - char paramName[20]; - for (int i = 0; i < numParams; i++) { - sprintf(paramName, "%d", i); - _values->setProp(paramName, stack->pop()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { - _length = 0; - _values = new CScValue(_gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXArray::scToString() { - static char dummy[32768]; // TODO: Get rid of static. - strcpy(dummy, ""); - char propName[20]; - for (int i = 0; i < _length; i++) { - sprintf(propName, "%d", i); - CScValue *val = _values->getProp(propName); - if (val) { - if (strlen(dummy) + strlen(val->getString()) < 32768) { - strcat(dummy, val->getString()); - } - } - - if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); - } - return dummy; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Push - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Push") == 0) { - int numParams = stack->pop()->getInt(0); - char paramName[20]; - - for (int i = 0; i < numParams; i++) { - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, stack->pop(), true); - } - stack->pushInt(_length); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pop - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Pop") == 0) { - - stack->correctParams(0); - - if (_length > 0) { - char paramName[20]; - sprintf(paramName, "%d", _length - 1); - stack->push(_values->getProp(paramName)); - _values->deleteProp(paramName); - _length--; - } else stack->pushNULL(); - - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("array"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(_length); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char ParamName[20]; - if (validNumber(name, ParamName)) { - return _values->getProp(ParamName); - } else return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length") == 0) { - int OrigLength = _length; - _length = MAX(value->getInt(0), 0); - - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->deleteProp(PropName); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char paramName[20]; - if (validNumber(name, paramName)) { - int Index = atoi(paramName); - if (Index >= _length) _length = Index + 1; - return _values->setProp(paramName, value); - } else return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_length)); - persistMgr->transfer(TMEMBER(_values)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::validNumber(const char *origStr, char *outStr) { - bool isNumber = true; - for (uint32 i = 0; i < strlen(origStr); i++) { - if (!(origStr[i] >= '0' && origStr[i] <= '9')) { - isNumber = false; - break; - } - } - - if (isNumber) { - int index = atoi(origStr); - sprintf(outStr, "%d", index); - return true; - } else return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXArray::push(CScValue *val) { - char paramName[20]; - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, val, true); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXArray.h b/engines/wintermute/base/scriptables/SXArray.h deleted file mode 100644 index 0f46bd546e..0000000000 --- a/engines/wintermute/base/scriptables/SXArray.h +++ /dev/null @@ -1,54 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXArray : public CBScriptable { -public: - bool push(CScValue *Val); - bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - int _length; - CScValue *_values; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXDate.cpp b/engines/wintermute/base/scriptables/SXDate.cpp deleted file mode 100644 index cd705cc9d4..0000000000 --- a/engines/wintermute/base/scriptables/SXDate.cpp +++ /dev/null @@ -1,297 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/SXDate.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXDate, false) - -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(6); - - memset(&_tm, 0, sizeof(_tm)); - - CScValue *valYear = stack->pop(); - _tm.tm_year = valYear->getInt() - 1900; - _tm.tm_mon = stack->pop()->getInt() - 1; - _tm.tm_mday = stack->pop()->getInt(); - _tm.tm_hour = stack->pop()->getInt(); - _tm.tm_min = stack->pop()->getInt(); - _tm.tm_sec = stack->pop()->getInt(); - - if (valYear->isNULL()) { - g_system->getTimeAndDate(_tm); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { - -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXDate::scToString() { - // TODO: Make this more stringy, and less ISO 8601-like - _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); - return _strRep.c_str(); -#if 0 - return asctime(&_tm); -#endif -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetYear - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetYear") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_year + 1900); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMonth") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mon + 1); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDate") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mday); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHours") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_hour); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMinutes") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_min); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSeconds") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_sec); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetWeekday - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWeekday") == 0) { - stack->correctParams(0); - warning("GetWeekday returns a wrong value on purpose"); - stack->pushInt(_tm.tm_mday % 7); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetYear - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetYear") == 0) { - stack->correctParams(1); - _tm.tm_year = stack->pop()->getInt() - 1900; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMonth") == 0) { - stack->correctParams(1); - _tm.tm_mon = stack->pop()->getInt() - 1; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDate") == 0) { - stack->correctParams(1); - _tm.tm_mday = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHours") == 0) { - stack->correctParams(1); - _tm.tm_hour = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMinutes") == 0) { - stack->correctParams(1); - _tm.tm_min = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSeconds") == 0) { - stack->correctParams(1); - _tm.tm_sec = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetCurrentTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCurrentTime") == 0) { - stack->correctParams(0); - g_system->getTimeAndDate(_tm); - stack->pushNULL(); - return STATUS_OK; - } - - else - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("date"); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Name")==0){ - setName(value->getString()); - return STATUS_OK; - } - - else*/ return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXDate::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_tm.tm_year)); - persistMgr->transfer(TMEMBER(_tm.tm_mon)); - persistMgr->transfer(TMEMBER(_tm.tm_mday)); - persistMgr->transfer(TMEMBER(_tm.tm_hour)); - persistMgr->transfer(TMEMBER(_tm.tm_min)); - persistMgr->transfer(TMEMBER(_tm.tm_sec)); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int CSXDate::scCompare(CBScriptable *Value) { - TimeDate time1 = _tm; - TimeDate time2 = ((CSXDate *)Value)->_tm; - - if (time1.tm_year < time2.tm_year) { - return -1; - } else if (time1.tm_year == time2.tm_year) { - if (time1.tm_mon < time2.tm_mon) { - return -1; - } else if (time1.tm_mon == time2.tm_mon) { - if (time1.tm_mday < time2.tm_mday) { - return -1; - } else if (time1.tm_mday == time2.tm_mday) { - if (time1.tm_hour < time2.tm_hour) { - return -1; - } else if (time1.tm_hour == time2.tm_hour) { - if (time1.tm_min < time2.tm_min) { - return -1; - } else if (time1.tm_min == time2.tm_min) { - if (time1.tm_sec < time2.tm_sec) { - return -1; - } else if (time1.tm_sec == time2.tm_sec) { - return 0; // Equal - } else { - return 1; // Sec - } - } else { - return 1; // Minute - } - } else { - return 1; // Hour - } - } else { - return 1; // Day - } - } else { - return 1; // Month - } - } else { - return 1; // Year - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXDate.h b/engines/wintermute/base/scriptables/SXDate.h deleted file mode 100644 index df0641983f..0000000000 --- a/engines/wintermute/base/scriptables/SXDate.h +++ /dev/null @@ -1,55 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXDATE_H -#define WINTERMUTE_SXDATE_H - -#include "common/system.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXDate : public CBScriptable { -public: - int scCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - char *_string; - TimeDate _tm; -private: - Common::String _strRep; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXFile.cpp b/engines/wintermute/base/scriptables/SXFile.cpp deleted file mode 100644 index 1924a42d72..0000000000 --- a/engines/wintermute/base/scriptables/SXFile.cpp +++ /dev/null @@ -1,779 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/system/SysClassRegistry.h" -#include "engines/wintermute/system/SysClass.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/file/BFile.h" -#include "engines/wintermute/base/BFileManager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/SXFile.h" - -// Note: This code is completely untested, as I have yet to find a game that uses SXFile. - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXFile, false) - -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { - return new CSXFile(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - CScValue *Val = stack->pop(); - - _filename = NULL; - if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void CSXFile::cleanup() { - delete[] _filename; - _filename = NULL; - close(); -} - - -////////////////////////////////////////////////////////////////////////// -void CSXFile::close() { - if (_readFile) { - _gameRef->_fileManager->closeFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - _writeFile->finalize(); - delete _writeFile; - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXFile::scToString() { - if (_filename) return _filename; - else return "[file object]"; -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFilename") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - cleanup(); - CBUtils::setString(&_filename, filename); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenAsText / OpenAsBinary - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->correctParams(1); - close(); - _mode = stack->pop()->getInt(1); - if (_mode < 1 || _mode > 3) { - script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); - _mode = 1; - } - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) { - //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } else { - if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = openForWrite(_filename, false); - else _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) _writeFile = openForWrite(_filename, true); - else _writeFile = openForAppend(_filename, true); - } - - if (!_writeFile) { - //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; - } - - if (_readFile || _writeFile) stack->pushBool(true); - else stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - close(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPosition") == 0) { - stack->correctParams(1); - if (_mode == 0) { - script->runtimeError("File.%s: File is not open", name); - stack->pushBool(false); - } else { - int Pos = stack->pop()->getInt(); - stack->pushBool(setPos(Pos)); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Delete - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delete") == 0) { - stack->correctParams(0); - close(); - stack->pushBool(CBPlatform::deleteFile(_filename) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Copy - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Copy") == 0) { - stack->correctParams(2); - const char *Dest = stack->pop()->getString(); - bool Overwrite = stack->pop()->getBool(true); - - close(); - stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadLine") == 0) { - stack->correctParams(0); - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - bool foundNewLine = false; - bool ret = STATUS_FAILED; - do { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == '\n') { - buf[counter] = '\0'; - foundNewLine = true; - break; - } else if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } while (DID_SUCCEED(ret)); - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (!foundNewLine && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadText") == 0) { - stack->correctParams(1); - int textLen = stack->pop()->getInt(); - - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - - bool ret = STATUS_FAILED; - while (counter < (uint32)textLen) { - ret = _readFile->read(&b, 1); - if (ret != 1) break; - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == 0x0D) continue; - else { - buf[counter] = b; - counter++; - } - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (textLen > 0 && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteLine / WriteText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->correctParams(1); - const char *line = stack->pop()->getString(); - if (!_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in text mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - Common::String writeLine; - if (strcmp(name, "WriteLine") == 0) { - writeLine = Common::String::format("%s\n", line); - } else { - writeLine = Common::String::format("%s", line); - } - _writeFile->writeString(writeLine); - _writeFile->writeByte(0); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ReadBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadBool") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadByte") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - byte val = _readFile->readByte(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadShort") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int16 val = _readFile->readSint16LE(); - if (!_readFile->err()) { - stack->pushInt(65536 + val); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadInt / ReadLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int32 val = _readFile->readSint32LE(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadFloat") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - float val; - (*(uint32*)&val) = _readFile->readUint32LE(); - if (!_readFile->err()) { - stack->pushFloat(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. - error("SXFile::ReadDouble - Not endian safe yet"); - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); - else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadString") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 size = _readFile->readUint32LE(); - if (!_readFile->err()) { - byte *str = new byte[size + 1]; - if (str) { - if (_readFile->read(str, size) == size) { - str[size] = '\0'; - stack->pushString((char *)str); - } - delete [] str; - } else stack->pushNULL(); - } else stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteByte") == 0) { - stack->correctParams(1); - byte val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteShort") == 0) { - stack->correctParams(1); - int16 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint16LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteInt / WriteLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->correctParams(1); - int32 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint32LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteFloat") == 0) { - stack->correctParams(1); - float val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - uint32 *ptr = (uint32*)&val; - _writeFile->writeUint32LE(*ptr); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteDouble") == 0) { - error("SXFile::WriteDouble - Not endian safe yet"); - stack->correctParams(1); - double val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteString") == 0) { - stack->correctParams(1); - const char *val = stack->pop()->getString(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - - uint32 size = strlen(val); - _writeFile->writeUint32LE(size); - _writeFile->writeString(val); - - stack->pushBool(true); - - return STATUS_OK; - } - - - else return CBScriptable::scCallMethod(script, stack, thisStack, name); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("file"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Position (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { - _scValue->setInt(getPos()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(getLength()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { - _scValue->setBool(_textMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccessMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { - _scValue->setInt(_mode); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getPos() { - if (_mode == 1 && _readFile) - return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - getPos for WriteFile not supported"); - return 0; -// return ftell((FILE *)_writeFile); - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) - return _readFile->seek(pos, whence); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - seeking in WriteFile not supported"); - return false; -// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; - } - else return false; -} - -////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getLength() { - if (_mode == 1 && _readFile) - return _readFile->size(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - reading length for WriteFile not supported"); - return 0; -/* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXFile::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); - - uint32 pos = 0; - if (persistMgr->_saving) { - pos = getPos(); - persistMgr->transfer(TMEMBER(pos)); - } else { - persistMgr->transfer(TMEMBER(pos)); - - // try to re-open file if needed - _writeFile = NULL; - _readFile = NULL; - - if (_mode != 0) { - // open for reading - if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) - close(); - } - // open for writing / appending - else { - if (_textMode) { - if (_mode == 2) - _writeFile = openForWrite(_filename, false); - else - _writeFile = openForAppend(_filename, false); - } else { - if (_mode == 2) - _writeFile = openForWrite(_filename, true); - else - _writeFile = openForAppend(_filename, true); - } - if (_writeFile) - close(); - } - setPos(pos); - } - } - - return STATUS_OK; -} - -// Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { - error("SXFile::openForWrite - WriteFiles not supported"); -} - -// Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXFile.h b/engines/wintermute/base/scriptables/SXFile.h deleted file mode 100644 index 709d1f4378..0000000000 --- a/engines/wintermute/base/scriptables/SXFile.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTES_SXFILE_H -#define WINTERMUTES_SXFILE_H - - -#include "engines/wintermute/base/BScriptable.h" -#include "common/stream.h" - -namespace WinterMute { - -class CBFile; - -class CSXFile : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); -private: - Common::SeekableReadStream *_readFile; - Common::WriteStream *_writeFile; - int _mode; // 0..none, 1..read, 2..write, 3..append - bool _textMode; - void close(); - void cleanup(); - uint32 getPos(); - uint32 getLength(); - bool setPos(uint32 Pos, int whence = SEEK_SET); - char *_filename; - Common::WriteStream *openForWrite(const Common::String &filename, bool binary); - Common::WriteStream *openForAppend(const Common::String &filename, bool binary); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXMath.cpp b/engines/wintermute/base/scriptables/SXMath.cpp deleted file mode 100644 index fb2838ee94..0000000000 --- a/engines/wintermute/base/scriptables/SXMath.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/persistent.h" -#include "common/math.h" -#include - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -IMPLEMENT_PERSISTENT(CSXMath, true) - -CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); -} - -////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Abs - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Abs") == 0) { - stack->correctParams(1); - stack->pushFloat(fabs(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Acos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Acos") == 0) { - stack->correctParams(1); - stack->pushFloat(acos(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Asin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Asin") == 0) { - stack->correctParams(1); - stack->pushFloat(asin(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan") == 0) { - stack->correctParams(1); - stack->pushFloat(atan(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan2") == 0) { - stack->correctParams(2); - double y = stack->pop()->getFloat(); - double x = stack->pop()->getFloat(); - stack->pushFloat(atan2(y, x)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Ceil - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ceil") == 0) { - stack->correctParams(1); - stack->pushFloat(ceil(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cos") == 0) { - stack->correctParams(1); - stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cosh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cosh") == 0) { - stack->correctParams(1); - stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exp") == 0) { - stack->correctParams(1); - stack->pushFloat(exp(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Floor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Floor") == 0) { - stack->correctParams(1); - stack->pushFloat(floor(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log") == 0) { - stack->correctParams(1); - stack->pushFloat(log(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log10 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log10") == 0) { - stack->correctParams(1); - stack->pushFloat(log10(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pow") == 0) { - stack->correctParams(2); - double x = stack->pop()->getFloat(); - double y = stack->pop()->getFloat(); - - stack->pushFloat(pow(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sin") == 0) { - stack->correctParams(1); - stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sinh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sinh") == 0) { - stack->correctParams(1); - stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tan") == 0) { - stack->correctParams(1); - stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tanh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tanh") == 0) { - stack->correctParams(1); - stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sqrt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sqrt") == 0) { - stack->correctParams(1); - stack->pushFloat(sqrt(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DegToRad - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DegToRad") == 0) { - stack->correctParams(1); - stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RadToDeg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RadToDeg") == 0) { - stack->correctParams(1); - stack->pushFloat(radianToDegree(stack->pop()->getFloat())); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("math"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PI - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { - _scValue->setFloat(M_PI); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::degreeToRadian(double value) { - return value * (M_PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double CSXMath::radianToDegree(double value) { - return value * (180.0f / M_PI); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMath::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMath.h b/engines/wintermute/base/scriptables/SXMath.h deleted file mode 100644 index 4389de611f..0000000000 --- a/engines/wintermute/base/scriptables/SXMath.h +++ /dev/null @@ -1,53 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMATH_H -#define WINTERMUTE_SXMATH_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXMath : public CBScriptable { -public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - -private: - double degreeToRadian(double value); - double radianToDegree(double value); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.cpp b/engines/wintermute/base/scriptables/SXMemBuffer.cpp deleted file mode 100644 index 9ac98ab11d..0000000000 --- a/engines/wintermute/base/scriptables/SXMemBuffer.cpp +++ /dev/null @@ -1,508 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BScriptable.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/SXMemBuffer.h" -#include "common/file.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) - -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { - return new CSXMemBuffer(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - stack->correctParams(1); - _buffer = NULL; - _size = 0; - - int NewSize = stack->pop()->getInt(); - resize(MAX(0, NewSize)); -} - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { - _size = 0; - _buffer = Buffer; -} - - -////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::scToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::cleanup() { - if (_size) free(_buffer); - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::resize(int newSize) { - int oldSize = _size; - - if (_size == 0) { - _buffer = malloc(newSize); - if (_buffer) _size = newSize; - } else { - void *newBuf = realloc(_buffer, newSize); - if (!newBuf) { - if (newSize == 0) { - _buffer = newBuf; - _size = newSize; - } else return STATUS_FAILED; - } else { - _buffer = newBuf; - _size = newSize; - } - } - - if (_buffer && _size > oldSize) { - memset((byte *)_buffer + oldSize, 0, _size - oldSize); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { - if (_buffer == NULL) { - script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); - return false; - } - if (_size == 0) - return true; - - if (start < 0 || length == 0 || start + length > _size) { - script->runtimeError("Set/Get method call is out of bounds"); - return false; - } else - return true; -} - -////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::scToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSize - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSize") == 0) { - stack->correctParams(1); - int newSize = stack->pop()->getInt(); - newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) - stack->pushBool(true); - else - stack->pushBool(false); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBool") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) - stack->pushNULL(); - else - stack->pushBool(*(bool *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetByte") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) - stack->pushNULL(); - else - stack->pushInt(*(byte *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetShort") == 0) { - stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) - stack->pushNULL(); - else - stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInt / GetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) - stack->pushNULL(); - else - stack->pushInt(*(int *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFloat") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) - stack->pushNULL(); - else - stack->pushFloat(*(float *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDouble") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) - stack->pushNULL(); - else - stack->pushFloat(*(double *)((byte *)_buffer + start)); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int length = stack->pop()->getInt(); - - // find end of string - if (length == 0 && start >= 0 && start < _size) { - for (int i = start; i < _size; i++) { - if (((char *)_buffer)[i] == '\0') { - length = i - start; - break; - } - } - } - - if (!checkBounds(script, start, length)) - stack->pushNULL(); - else { - char *str = new char[length + 1]; - strncpy(str, (const char *)_buffer + start, length); - str[length] = '\0'; - stack->pushString(str); - delete [] str; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPointer") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) - stack->pushNULL(); - else { - void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); - stack->pushNative(buf, false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBool") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - bool val = stack->pop()->getBool(); - - if (!checkBounds(script, start, sizeof(bool))) - stack->pushBool(false); - else { - *(bool *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetByte") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - byte val = (byte)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(byte))) - stack->pushBool(false); - else { - *(byte *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetShort") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - short val = (short)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(short))) - stack->pushBool(false); - else { - *(short *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInt / SetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int val = stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(int))) - stack->pushBool(false); - else { - *(int *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFloat") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - float val = (float)stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(float))) - stack->pushBool(false); - else { - *(float *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDouble") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - double val = stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(double))) - stack->pushBool(false); - else { - *(double *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - const char *val = stack->pop()->getString(); - - if (!checkBounds(script, start, strlen(val) + 1)) - stack->pushBool(false); - else { - memcpy((byte *)_buffer + start, val, strlen(val) + 1); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPointer") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - /* CScValue *Val = */ stack->pop(); - - if (!checkBounds(script, start, sizeof(void *))) - stack->pushBool(false); - else { - /* - int Pointer = (int)Val->getMemBuffer(); - memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->pushBool(true); - */ - // TODO fix - stack->pushBool(false); - - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_Dump - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->correctParams(0); - if (_buffer && _size) { - warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); - Common::DumpFile f; - f.open("buffer.bin"); - f.write(_buffer, _size); - f.close(); - } - stack->pushNULL(); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("membuffer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Size (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { - _scValue->setInt(_size); - return _scValue; - } - - else return CBScriptable::scGetProperty(name); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ - int OrigLength = _length; - _length = max(value->getInt(0), 0); - - char PropName[20]; - if(_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return CBScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_size)); - - if (persistMgr->_saving) { - if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); - } else { - if (_size > 0) { - _buffer = malloc(_size); - persistMgr->getBytes((byte *)_buffer, _size); - } else _buffer = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *val) { - if (_buffer == val->scToMemBuffer()) return 0; - else return 1; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXMemBuffer.h b/engines/wintermute/base/scriptables/SXMemBuffer.h deleted file mode 100644 index 09831bf464..0000000000 --- a/engines/wintermute/base/scriptables/SXMemBuffer.h +++ /dev/null @@ -1,59 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXMemBuffer : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *stack); - CSXMemBuffer(CBGame *inGame, void *buffer); - virtual ~CSXMemBuffer(); - virtual void *scToMemBuffer(); - int _size; -private: - bool resize(int newSize); - void *_buffer; - void cleanup(); - bool checkBounds(CScScript *script, int start, int length); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SXString.cpp b/engines/wintermute/base/scriptables/SXString.cpp deleted file mode 100644 index ed3d243cb0..0000000000 --- a/engines/wintermute/base/scriptables/SXString.cpp +++ /dev/null @@ -1,404 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/scriptables/SXString.h" -#include "engines/wintermute/base/scriptables/SXArray.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "common/tokenizer.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CSXString, false) - -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { - return new CSXString(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { - _string = NULL; - _capacity = 0; - - stack->correctParams(1); - CScValue *val = stack->pop(); - - if (val->isInt()) { - _capacity = MAX(0, val->getInt()); - if (_capacity > 0) { - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - } else { - setStringVal(val->getString()); - } - - if (_capacity == 0) setStringVal(""); -} - - -////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { - if (_string) delete [] _string; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::setStringVal(const char *val) { - int len = strlen(val); - if (len >= _capacity) { - _capacity = len + 1; - delete[] _string; - _string = NULL; - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - strcpy(_string, val); -} - - -////////////////////////////////////////////////////////////////////////// -const char *CSXString::scToString() { - if (_string) return _string; - else return "[null string]"; -} - - -////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *val) { - setStringVal(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Substring - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Substring") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int end = stack->pop()->getInt(); - - if (end < start) CBUtils::swap(&start, &end); - - //try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); - // } catch (std::exception &) { - // stack->pushNULL(); - // } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Substr - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Substr") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - - CScValue *val = stack->pop(); - int len = val->getInt(); - - if (!val->isNULL() && len <= 0) { - stack->pushString(""); - return STATUS_OK; - } - - if (val->isNULL()) len = strlen(_string) - start; - -// try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - -// WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); -// } catch (std::exception &) { -// stack->pushNULL(); -// } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToUpperCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToUpperCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toUppercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToLowerCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToLowerCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - str.toLowercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IndexOf - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IndexOf") == 0) { - stack->correctParams(2); - - const char *strToFind = stack->pop()->getString(); - int index = stack->pop()->getInt(); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) - toFind = StringUtil::utf8ToWide(strToFind); - else - toFind = StringUtil::ansiToWide(strToFind); - - int indexOf = StringUtil::indexOf(str, toFind, index); - stack->pushInt(indexOf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Split - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Split") == 0) { - stack->correctParams(1); - CScValue *val = stack->pop(); - char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) strcpy(separators, val->getString()); - - CSXArray *array = new CSXArray(_gameRef); - if (!array) { - stack->pushNULL(); - return STATUS_OK; - } - - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) - str = StringUtil::utf8ToWide(_string); - else - str = StringUtil::ansiToWide(_string); - - WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) - delims = StringUtil::utf8ToWide(separators); - else - delims = StringUtil::ansiToWide(separators); - - Common::Array parts; - - - - Common::StringTokenizer tokenizer(str, delims); - while (!tokenizer.empty()) { - Common::String str2 = tokenizer.nextToken(); - parts.push_back(str2); - } - // TODO: Clean this up - /*do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - - } while (pos != str.size());*/ - - for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { - WideString &part = (*it); - - if (_gameRef->_textEncoding == TEXT_UTF8) - val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - else - val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); - - array->push(val); - delete val; - val = NULL; - } - - stack->pushNative(array, false); - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("string"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(_string); - _scValue->setInt(wstr.size()); - } else - _scValue->setInt(strlen(_string)); - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { - _scValue->setInt(_capacity); - return _scValue; - } - - else return _scValue; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::scSetProperty(const char *name, CScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Capacity") == 0) { - int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); - else if (newCap != _capacity) { - char *newStr = new char[newCap]; - if (newStr) { - memset(newStr, 0, newCap); - strcpy(newStr, _string); - delete[] _string; - _string = newStr; - _capacity = newCap; - } - } - return STATUS_OK; - } - - else return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXString::persist(CBPersistMgr *persistMgr) { - - CBScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_capacity)); - - if (persistMgr->_saving) { - if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); - } else { - if (_capacity > 0) { - _string = new char[_capacity]; - persistMgr->getBytes((byte *)_string, _capacity); - } else _string = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *val) { - return strcmp(_string, ((CSXString *)val)->_string); -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SXString.h b/engines/wintermute/base/scriptables/SXString.h deleted file mode 100644 index 348595ad29..0000000000 --- a/engines/wintermute/base/scriptables/SXString.h +++ /dev/null @@ -1,58 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTRING_H -#define WINTERMUTE_SXSTRING_H - - -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -class CSXString : public CBScriptable { -public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); - void scSetString(const char *val); - const char *scToString(); - void setStringVal(const char *val); - - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScEngine.cpp b/engines/wintermute/base/scriptables/ScEngine.cpp deleted file mode 100644 index db79a7d0e9..0000000000 --- a/engines/wintermute/base/scriptables/ScEngine.cpp +++ /dev/null @@ -1,712 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/SXMath.h" -#include "engines/wintermute/base/BRegistry.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/BSound.h" -#include "engines/wintermute/base/BFileManager.h" - - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { - _gameRef->LOG(0, "Initializing scripting engine..."); - - if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); - else _gameRef->LOG(0, " Script compiler is NOT available"); - - _globals = new CScValue(_gameRef); - - - // register 'Game' as global variable - if (!_globals->propExists("Game")) { - CScValue val(_gameRef); - val.setNative(_gameRef, true); - _globals->setProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->propExists("Math")) { - CScValue val(_gameRef); - val.setNative(_gameRef->_mathClass, true); - _globals->setProp("Math", &val); - } - - // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; - - _currentScript = NULL; - - _isProfiling = false; - _profilingStartTime = 0; - - //EnableProfiling(); -} - - -////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { - _gameRef->LOG(0, "Shutting down scripting engine"); - saveBreakpoints(); - - disableProfiling(); - - cleanup(); - - for (int i = 0; i < _breakpoints.getSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::cleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - - _scripts.removeAll(); - - delete _globals; - _globals = NULL; - - emptyScriptCache(); - - _currentScript = NULL; // ref only - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *gameRef = (CBGame *)data; - return gameRef->_fileManager->readWholeFile(filename, size); -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::closeFile(void *data, byte *buffer) { - delete [] buffer; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::parseElement(void *data, int line, int type, void *elementData) { -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { - byte *compBuffer; - uint32 compSize; - - // get script from cache - compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) return NULL; - - // add new script - CScScript *script = new CScScript(_gameRef, this); - bool ret = script->create(filename, compBuffer, compSize, owner); - if (DID_FAIL(ret)) { - _gameRef->LOG(ret, "Error running script '%s'...", filename); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - CScValue val(_gameRef); - if (owner)val.setNative(owner, true); - else val.setNULL(); - - script->_globals->setProp("self", &val); - script->_globals->setProp("this", &val); - - _scripts.add(script); - _gameRef->getDebugMgr()->onScriptInit(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { - // is script in cache? - if (!ignoreCache) { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::getTime(); - *outSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *compBuffer; - uint32 compSize; - - uint32 size; - - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); - if (!buffer) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); - return NULL; - } - - // needs to be compiled? - if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { - compBuffer = buffer; - compSize = size; - } else { - if (!_compilerAvailable) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] buffer; - return NULL; - } - // This code will never be called, since _compilerAvailable is const false. - // It's only here in the event someone would want to reinclude the compiler. - error("Script needs compilation, ScummVM does not contain a WME compiler"); - } - - byte *ret = NULL; - - // add script to cache - CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); - if (cachedScript) { - int index = 0; - uint32 MinTime = CBPlatform::getTime(); - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] == NULL) { - index = i; - break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; - index = i; - } - } - - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; - _cachedScripts[index] = cachedScript; - - ret = cachedScript->_buffer; - *outSize = cachedScript->_size; - } - - - // cleanup - delete [] buffer; - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tick() { - if (_scripts.getSize() == 0) - return STATUS_OK; - - - // resolve waiting scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - switch (_scripts[i]->_state) { - case SCRIPT_WAITING: { - /* - bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.getSize(); j++) - { - if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) - { - if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); - obj_found = true; - break; - } - } - if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists - */ - if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); - } else _scripts[i]->finish(); - break; - } - - case SCRIPT_SLEEPING: { - if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); - } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); - } - break; - } - - case SCRIPT_WAITING_SCRIPT: { - if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { - // fake return value - _scripts[i]->_stack->pushNULL(); - _scripts[i]->_waitScript = NULL; - _scripts[i]->run(); - } else { - if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { - // copy return value - _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); - _scripts[i]->run(); - _scripts[i]->_waitScript->finish(); - _scripts[i]->_waitScript = NULL; - } - } - break; - } - default: - //warning("CScEngine::Tick - Unhandled enum"); - break; - } // switch - } // for each script - - - // execute scripts - for (int i = 0; i < _scripts.getSize(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; - - // time sliced script - if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); - } - - // normal script - else { - uint32 startTime = 0; - bool isProfiling = _isProfiling; - if (isProfiling) startTime = CBPlatform::getTime(); - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); - } - _currentScript = NULL; - } - - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::tickUnbreakable() { - // execute unbreakable scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - _scripts[i]->finish(); - _currentScript = NULL; - } - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeFinishedScripts() { - // remove finished scripts - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); - _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { - int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; - switch (_scripts[i]->_state) { - case SCRIPT_RUNNING: - case SCRIPT_SLEEPING: - case SCRIPT_PAUSED: - numRunning++; - break; - case SCRIPT_WAITING: - numWaiting++; - break; - case SCRIPT_PERSISTENT: - numPersistent++; - break; - default: - warning("CScEngine::GetNumScripts - unhandled enum"); - break; - } - numTotal++; - } - if (running) *running = numRunning; - if (waiting) *waiting = numWaiting; - if (persistent) *persistent = numPersistent; - - return numTotal; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::emptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetObject(CBObject *Object) { - // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); - - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetScript(CScScript *script) { - // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { - _scripts[i]->finish(); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::persist(CBPersistMgr *persistMgr) { - if (!persistMgr->_saving) cleanup(); - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_globals)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::editorCleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { - delete _scripts[i]; - _scripts.removeAt(i); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::pauseAll() { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->pause(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) - _scripts[i]->resume(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::isValidScript(CScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::clearGlobals(bool includingNatives) { - _globals->CleanProps(includingNatives); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { - // send global variables - _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; - _scripts[i]->dbgSendScript(client); - } - - // and threads later - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) - _scripts[i]->dbgSendScript(client); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - bp = _breakpoints[i]; - break; - } - } - if (bp == NULL) { - bp = new CScBreakpoint(scriptFilename); - _breakpoints.add(bp); - } - - for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) return STATUS_OK; - } - bp->_lines.add(line); - - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.removeAt(j); - if (_breakpoints[i]->_lines.getSize() == 0) { - delete _breakpoints[i]; - _breakpoints.removeAt(i); - } - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; - } - } - break; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - for (int i = 0; i < _scripts.getSize(); i++) { - refreshScriptBreakpoints(_scripts[i]); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints(CScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - if (!script || !script->_filename) return STATUS_FAILED; - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.copy(_breakpoints[i]->_lines); - return STATUS_OK; - } - } - if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - - char text[512]; - char key[100]; - - int count = 0; - for (int i = 0; i < _breakpoints.getSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - count++; - sprintf(key, "Breakpoint%d", count); - sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - _gameRef->_registry->writeString("Debug", key, text); - } - } - _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; - - char key[100]; - - int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= count; i++) { - /* uint32 BufSize = 512; */ - sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); - - char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); - - if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); - delete[] path; - delete[] line; - path = NULL; - line = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) return; - - AnsiString fileName = filename; - fileName.toLowercase(); - _scriptTimes[fileName] += time; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::enableProfiling() { - if (_isProfiling) return; - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = CBPlatform::getTime(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::disableProfiling() { - if (!_isProfiling) return; - - dumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScEngine::dumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; - - typedef std::vector > TimeVector; - TimeVector times; - - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); - - - TimeVector::reverse_iterator tit; - - _gameRef->LOG(0, "***** Script profiling information: *****"); - _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - - for (tit = times.rbegin(); tit != times.rend(); tit++) { - _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScEngine.h b/engines/wintermute/base/scriptables/ScEngine.h deleted file mode 100644 index 0322319b3d..0000000000 --- a/engines/wintermute/base/scriptables/ScEngine.h +++ /dev/null @@ -1,147 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCENGINE_H -#define WINTERMUTE_SCENGINE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" - -namespace WinterMute { - -#define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { -public: - class CScCachedScript { - public: - CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::getTime(); - _buffer = new byte[size]; - if (_buffer) memcpy(_buffer, buffer, size); - _size = size; - _filename = filename; - }; - - ~CScCachedScript() { - if (_buffer) delete [] _buffer; - }; - - uint32 _timestamp; - byte *_buffer; - uint32 _size; - Common::String _filename; - }; - - class CScBreakpoint { - public: - CScBreakpoint(const char *filename) { - _filename = filename; - } - - ~CScBreakpoint() { - _lines.removeAll(); - } - - Common::String _filename; - CBArray _lines; - }; - - - - -public: - bool dbgSendScripts(IWmeDebugClient *client); - - CBArray _breakpoints; - bool addBreakpoint(const char *scriptFilename, int line); - bool removeBreakpoint(const char *scriptFilename, int line); - bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(CScScript *script); - bool saveBreakpoints(); - bool loadBreakpoints(); - - bool clearGlobals(bool includingNatives = false); - bool tickUnbreakable(); - bool removeFinishedScripts(); - bool isValidScript(CScScript *script); - - CScScript *_currentScript; - bool resumeAll(); - bool pauseAll(); - void editorCleanup(); - bool resetObject(CBObject *Object); - bool resetScript(CScScript *script); - bool emptyScriptCache(); - byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) - bool cleanup(); - int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - bool tick(); - CScValue *_globals; - CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); - static const bool _compilerAvailable = false; - - CScEngine(CBGame *inGame); - virtual ~CScEngine(); - static byte *loadFile(void *data, char *filename, uint32 *size); - static void closeFile(void *data, byte *buffer); - static void parseElement(void *data, int line, int type, void *elementData); - - CBArray _scripts; - - void enableProfiling(); - void disableProfiling(); - bool getIsProfiling() { - return _isProfiling; - } - - void addScriptTime(const char *filename, uint32 Time); - void dumpStats(); - -private: - - CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; - bool _isProfiling; - uint32 _profilingStartTime; - - typedef Common::HashMap ScriptTimes; - ScriptTimes _scriptTimes; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScScript.cpp b/engines/wintermute/base/scriptables/ScScript.cpp deleted file mode 100644 index 0b5b3c24bf..0000000000 --- a/engines/wintermute/base/scriptables/ScScript.cpp +++ /dev/null @@ -1,1461 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScEngine.h" -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "common/memstream.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScScript, false) - -////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { - _buffer = NULL; - _bufferSize = _iP = 0; - _scriptStream = NULL; - _filename = NULL; - _currentLine = 0; - - _symbols = NULL; - _numSymbols = 0; - - _engine = Engine; - - _globals = NULL; - - _scopeStack = NULL; - _callStack = NULL; - _thisStack = NULL; - _stack = NULL; - - _operand = NULL; - _reg1 = NULL; - - _functions = NULL; - _numFunctions = 0; - - _methods = NULL; - _numMethods = 0; - - _events = NULL; - _numEvents = 0; - - _externals = NULL; - _numExternals = 0; - - _state = SCRIPT_FINISHED; - _origState = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _timeSlice = 0; - - _thread = false; - _methodThread = false; - _threadEvent = NULL; - - _freezable = true; - _owner = NULL; - - _unbreakable = false; - _parentScript = NULL; - - _tracingMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { - cleanup(); -} - -void CScScript::readHeader() { - uint32 oldPos = _scriptStream->pos(); - _scriptStream->seek(0); - _header.magic = _scriptStream->readUint32LE(); - _header.version = _scriptStream->readUint32LE(); - _header.code_start = _scriptStream->readUint32LE(); - _header.func_table = _scriptStream->readUint32LE(); - _header.symbol_table = _scriptStream->readUint32LE(); - _header.event_table = _scriptStream->readUint32LE(); - _header.externals_table = _scriptStream->readUint32LE(); - _header.method_table = _scriptStream->readUint32LE(); - _scriptStream->seek(oldPos); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initScript() { - if (!_scriptStream) { - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - } - readHeader(); - - if (_header.magic != SCRIPT_MAGIC) { - _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); - cleanup(); - return STATUS_FAILED; - } - - if (_header.version > SCRIPT_VERSION) { - _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - cleanup(); - return STATUS_FAILED; - } - - initTables(); - - // init stacks - _scopeStack = new CScStack(_gameRef); - _callStack = new CScStack(_gameRef); - _thisStack = new CScStack(_gameRef); - _stack = new CScStack(_gameRef); - - _operand = new CScValue(_gameRef); - _reg1 = new CScValue(_gameRef); - - - // skip to the beginning - _iP = _header.code_start; - _scriptStream->seek(_iP); - _currentLine = 0; - - // init breakpoints - _engine->refreshScriptBreakpoints(this); - - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::initTables() { - uint32 OrigIP = _iP; - - readHeader(); - // load symbol table - _iP = _header.symbol_table; - - _numSymbols = getDWORD(); - _symbols = new char*[_numSymbols]; - for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = getDWORD(); - _symbols[index] = getString(); - } - - // load functions table - _iP = _header.func_table; - - _numFunctions = getDWORD(); - _functions = new TFunctionPos[_numFunctions]; - for (uint32 i = 0; i < _numFunctions; i++) { - _functions[i].pos = getDWORD(); - _functions[i].name = getString(); - } - - - // load events table - _iP = _header.event_table; - - _numEvents = getDWORD(); - _events = new TEventPos[_numEvents]; - for (uint32 i = 0; i < _numEvents; i++) { - _events[i].pos = getDWORD(); - _events[i].name = getString(); - } - - - // load externals - if (_header.version >= 0x0101) { - _iP = _header.externals_table; - - _numExternals = getDWORD(); - _externals = new TExternalFunction[_numExternals]; - for (uint32 i = 0; i < _numExternals; i++) { - _externals[i].dll_name = getString(); - _externals[i].name = getString(); - _externals[i].call_type = (TCallType)getDWORD(); - _externals[i].returns = (TExternalType)getDWORD(); - _externals[i].nu_params = getDWORD(); - if (_externals[i].nu_params > 0) { - _externals[i].params = new TExternalType[_externals[i].nu_params]; - for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)getDWORD(); - } - } - } - } - - // load method table - _iP = _header.method_table; - - _numMethods = getDWORD(); - _methods = new TMethodPos[_numMethods]; - for (uint32 i = 0; i < _numMethods; i++) { - _methods[i].pos = getDWORD(); - _methods[i].name = getString(); - } - - - _iP = OrigIP; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { - cleanup(); - - _thread = false; - _methodThread = false; - - delete[] _threadEvent; - _threadEvent = NULL; - - _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); - - _buffer = new byte [size]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, buffer, size); - - _bufferSize = size; - - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // establish global variables table - _globals = new CScValue(_gameRef); - - _owner = owner; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { - cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[strlen(eventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, eventName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = initIP; - _scriptStream->seek(_iP); - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::createMethodThread(CScScript *original, const char *methodName) { - uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return STATUS_FAILED; - - cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[strlen(methodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, methodName); - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) return res; - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = ip; - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::cleanup() { - if (_buffer) delete [] _buffer; - _buffer = NULL; - - if (_filename) delete [] _filename; - _filename = NULL; - - if (_symbols) delete [] _symbols; - _symbols = NULL; - _numSymbols = 0; - - if (_globals && !_thread) delete _globals; - _globals = NULL; - - delete _scopeStack; - _scopeStack = NULL; - - delete _callStack; - _callStack = NULL; - - delete _thisStack; - _thisStack = NULL; - - delete _stack; - _stack = NULL; - - if (_functions) delete [] _functions; - _functions = NULL; - _numFunctions = 0; - - if (_methods) delete [] _methods; - _methods = NULL; - _numMethods = 0; - - if (_events) delete [] _events; - _events = NULL; - _numEvents = 0; - - - if (_externals) { - for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; - } - delete [] _externals; - } - _externals = NULL; - _numExternals = 0; - - delete _operand; - delete _reg1; - _operand = NULL; - _reg1 = NULL; - - delete[] _threadEvent; - _threadEvent = NULL; - - _state = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _parentScript = NULL; // ref only - - delete _scriptStream; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getDWORD() { - _scriptStream->seek((int32)_iP); - uint32 ret = _scriptStream->readUint32LE(); - _iP += sizeof(uint32); -// assert(oldRet == ret); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -double CScScript::getFloat() { - _scriptStream->seek((int32)_iP); - byte buffer[8]; - _scriptStream->read(buffer, 8); - -#ifdef SCUMM_BIG_ENDIAN - // TODO: For lack of a READ_LE_UINT64 - SWAP(buffer[0], buffer[7]); - SWAP(buffer[1], buffer[6]); - SWAP(buffer[2], buffer[5]); - SWAP(buffer[3], buffer[4]); -#endif - - double ret = *(double *)(buffer); - _iP += 8; // Hardcode the double-size used originally. - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -char *CScScript::getString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; - _iP++; // string terminator - _scriptStream->seek(_iP); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::executeInstruction() { - bool ret = STATUS_OK; - - uint32 dw; - const char *str = NULL; - - //CScValue* op = new CScValue(_gameRef); - _operand->cleanup(); - - CScValue *op1; - CScValue *op2; - - uint32 inst = getDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->setNULL(); - dw = getDWORD(); - if (_scopeStack->_sP < 0) { - _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); - } else { - _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); - } - - break; - - case II_DEF_GLOB_VAR: - case II_DEF_CONST_VAR: { - dw = getDWORD(); - /* char *Temp = _symbols[dw]; // TODO delete */ - // only create global var if it doesn't exist - if (!_engine->_globals->propExists(_symbols[dw])) { - _operand->setNULL(); - _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); - - _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->getInt(); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } else { - if (_thread) { - _state = SCRIPT_THREAD_FINISHED; - } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; - } - } - - break; - - case II_RET_EVENT: - _state = SCRIPT_FINISHED; - break; - - - case II_CALL: - dw = getDWORD(); - - _operand->setInt(_iP); - _callStack->push(_operand); - - _iP = dw; - - break; - - case II_CALL_BY_EXP: { - // push var - // push string - str = _stack->pop()->getString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); - - CScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; - - bool res = STATUS_FAILED; - bool TriedNative = false; - - // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - TriedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - } - - if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { - if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(MethodName); - if (!_waitScript) { - _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", MethodName); - _stack->pushNULL(); - } else { - _state = SCRIPT_WAITING_SCRIPT; - _waitScript->copyParameters(_stack); - } - } else { - // can call methods in unbreakable mode - _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - delete [] MethodName; - break; - } - /* - CScValue* val = var->getProp(MethodName); - if(val){ - dw = GetFuncPos(val->getString()); - if(dw==0){ - TExternalFunction* f = GetExternal(val->getString()); - if(f){ - ExternalCall(_stack, _thisStack, f); - } - else{ - // not an internal nor external, try for native function - _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); - } - } - else{ - _operand->setInt(_iP); - _callStack->Push(_operand); - _iP = dw; - } - } - */ - else { - res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); - - if (DID_FAIL(res)) { - _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", MethodName); - _stack->pushNULL(); - } - } - } - delete [] MethodName; - } - break; - - case II_EXTERNAL_CALL: { - uint32 SymbolIndex = getDWORD(); - - TExternalFunction *f = getExternal(_symbols[SymbolIndex]); - if (f) { - externalCall(_stack, _thisStack, f); - } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); - - break; - } - case II_SCOPE: - _operand->setNULL(); - _scopeStack->push(_operand); - - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - - break; - - case II_CORRECT_STACK: - dw = getDWORD(); // params expected - _stack->correctParams(dw); - break; - - case II_CREATE_OBJECT: - _operand->setObject(); - _stack->push(_operand); - break; - - case II_POP_EMPTY: - _stack->pop(); - break; - - case II_PUSH_VAR: { - CScValue *var = getVar(_symbols[getDWORD()]); - if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->setReference(var); - _stack->push(_operand); - } else _stack->push(var); - break; - } - - case II_PUSH_VAR_REF: { - CScValue *var = getVar(_symbols[getDWORD()]); - _operand->setReference(var); - _stack->push(_operand); - break; - } - - case II_POP_VAR: { - char *VarName = _symbols[getDWORD()]; - CScValue *var = getVar(VarName); - if (var) { - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else { - if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->setValue(val); - else { - var->copy(val); - } - } - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, val); - } - - break; - } - - case II_PUSH_VAR_THIS: - _stack->push(_thisStack->getTop()); - break; - - case II_PUSH_INT: - _stack->pushInt((int)getDWORD()); - break; - - case II_PUSH_FLOAT: - _stack->pushFloat(getFloat()); - break; - - - case II_PUSH_BOOL: - _stack->pushBool(getDWORD() != 0); - - break; - - case II_PUSH_STRING: - _stack->pushString(getString()); - break; - - case II_PUSH_NULL: - _stack->pushNULL(); - break; - - case II_PUSH_THIS_FROM_STACK: - _operand->setReference(_stack->getTop()); - _thisStack->push(_operand); - break; - - case II_PUSH_THIS: - _operand->setReference(getVar(_symbols[getDWORD()])); - _thisStack->push(_operand); - break; - - case II_POP_THIS: - _thisStack->pop(); - break; - - case II_PUSH_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *val = _stack->pop()->getProp(str); - if (val) _stack->push(val); - else _stack->pushNULL(); - - break; - } - - case II_POP_BY_EXP: { - str = _stack->pop()->getString(); - CScValue *var = _stack->pop(); - CScValue *val = _stack->pop(); - - if (val == NULL) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else var->setProp(str, val); - - if (_gameRef->getDebugMgr()->_enabled) - _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); - - break; - } - - case II_PUSH_REG1: - _stack->push(_reg1); - break; - - case II_POP_REG1: - _reg1->copy(_stack->pop()); - break; - - case II_JMP: - _iP = getDWORD(); - break; - - case II_JMP_FALSE: { - dw = getDWORD(); - //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - } else { - if (!val->getBool()) _iP = dw; - } - break; - } - - case II_ADD: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; - strcpy(tempStr, op1->getString()); - strcat(tempStr, op2->getString()); - _operand->setString(tempStr); - delete [] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() + op2->getInt()); - else _operand->setFloat(op1->getFloat() + op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_SUB: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) - _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() - op2->getInt()); - else _operand->setFloat(op1->getFloat() - op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MUL: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) - _operand->setInt(op1->getInt() * op2->getInt()); - else _operand->setFloat(op1->getFloat() * op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_DIV: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getFloat() == 0.0f) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); - else _operand->setFloat(op1->getFloat() / op2->getFloat()); - - _stack->push(_operand); - - break; - - case II_MODULO: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getInt() == 0) - runtimeError("Division by zero."); - - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) - _operand->setNULL(); - else _operand->setInt(op1->getInt() % op2->getInt()); - - _stack->push(_operand); - - break; - - case II_NOT: - op1 = _stack->pop(); - //if(op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) _operand->setBool(true); - else _operand->setBool(!op1->getBool()); - _stack->push(_operand); - - break; - - case II_AND: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() && op2->getBool()); - } - _stack->push(_operand); - break; - - case II_OR: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() || op2->getBool()); - } - _stack->push(_operand); - break; - - case II_CMP_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() == op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() == op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() == op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) == 0); - _stack->push(_operand); - break; - - case II_CMP_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if(op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() != op2->getNative()); - } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); - } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() != op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() != op2->getInt()); - } - */ - - _operand->setBool(CScValue::compare(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_CMP_L: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() < op2->getFloat()); - } - else _operand->setBool(op1->getInt() < op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) < 0); - _stack->push(_operand); - break; - - case II_CMP_G: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() > op2->getFloat()); - } - else _operand->setBool(op1->getInt() > op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) > 0); - _stack->push(_operand); - break; - - case II_CMP_LE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() <= op2->getFloat()); - } - else _operand->setBool(op1->getInt() <= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) <= 0); - _stack->push(_operand); - break; - - case II_CMP_GE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() >= op2->getFloat()); - } - else _operand->setBool(op1->getInt() >= op2->getInt()); - */ - - _operand->setBool(CScValue::compare(op1, op2) >= 0); - _stack->push(_operand); - break; - - case II_CMP_STRICT_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) == 0); - _stack->push(_operand); - - break; - - case II_CMP_STRICT_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_DBG_LINE: { - int newLine = getDWORD(); - if (newLine != _currentLine) { - _currentLine = newLine; - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (_breakpoints[i] == _currentLine) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - if (_tracingMode) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - } - break; - - } - default: - _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); - _state = SCRIPT_FINISHED; - ret = STATUS_FAILED; - } // switch(instruction) - - //delete op; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getFuncPos(const char *name) { - for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) - return _functions[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getMethodPos(const char *name) { - for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) - return _methods[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::getVar(char *name) { - CScValue *ret = NULL; - - // scope locals - if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) - ret = _scopeStack->getTop()->getProp(name); - } - - // script globals - if (ret == NULL) { - if (_globals->propExists(name)) - ret = _globals->getProp(name); - } - - // engine globals - if (ret == NULL) { - if (_engine->_globals->propExists(name)) - ret = _engine->_globals->getProp(name); - } - - if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); - _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(_gameRef); - CScValue *scope = _scopeStack->getTop(); - if (scope) { - scope->setProp(name, val); - ret = _scopeStack->getTop()->getProp(name); - } else { - _globals->setProp(name, val); - ret = _globals->getProp(name); - } - delete val; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitFor(CBObject *object) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = object; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::waitForExclusive(CBObject *object) { - _engine->resetObject(object); - return waitFor(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::sleep(uint32 duration) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_SLEEPING; - if (_gameRef->_state == GAME_FROZEN) { - _waitTime = CBPlatform::getTime() + duration; - _waitFrozen = true; - } else { - _waitTime = _gameRef->_timer + duration; - _waitFrozen = false; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finish(bool includingThreads) { - if (_state != SCRIPT_FINISHED && includingThreads) { - _state = SCRIPT_FINISHED; - finishThreads(); - } else _state = SCRIPT_FINISHED; - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::run() { - _state = SCRIPT_RUNNING; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(const char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - _gameRef->LOG(0, " %s", buff); - - if (!_gameRef->_suppressScriptErrors) - _gameRef->quickMessage("Script runtime error. View log for details."); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - // buffer - if (persistMgr->_saving) { - if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - persistMgr->transfer(TMEMBER(_bufferSize)); - persistMgr->putBytes(_buffer, _bufferSize); - } else { - // don't save idle/finished scripts - int bufferSize = 0; - persistMgr->transfer(TMEMBER(bufferSize)); - } - } else { - persistMgr->transfer(TMEMBER(_bufferSize)); - if (_bufferSize > 0) { - _buffer = new byte[_bufferSize]; - persistMgr->getBytes(_buffer, _bufferSize); - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - initTables(); - } else { - _buffer = NULL; - _scriptStream = NULL; - } - } - - persistMgr->transfer(TMEMBER(_callStack)); - persistMgr->transfer(TMEMBER(_currentLine)); - persistMgr->transfer(TMEMBER(_engine)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_globals)); - persistMgr->transfer(TMEMBER(_iP)); - persistMgr->transfer(TMEMBER(_scopeStack)); - persistMgr->transfer(TMEMBER(_stack)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_operand)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_reg1)); - persistMgr->transfer(TMEMBER(_thread)); - persistMgr->transfer(TMEMBER(_threadEvent)); - persistMgr->transfer(TMEMBER(_thisStack)); - persistMgr->transfer(TMEMBER(_timeSlice)); - persistMgr->transfer(TMEMBER(_waitObject)); - persistMgr->transfer(TMEMBER(_waitScript)); - persistMgr->transfer(TMEMBER(_waitTime)); - persistMgr->transfer(TMEMBER(_waitFrozen)); - - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_unbreakable)); - persistMgr->transfer(TMEMBER(_parentScript)); - - if (!persistMgr->_saving) _tracingMode = false; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = getEventPos(eventName); - if (!pos) return NULL; - - CScScript *thread = new CScScript(_gameRef, _engine); - if (thread) { - bool ret = thread->createThread(this, pos, eventName); - if (DID_SUCCEED(ret)) { - thread->_unbreakable = unbreakable; - _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); - return thread; - } else { - delete thread; - return NULL; - } - } else return NULL; - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getEventPos(const char *name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *eventName) { - return getEventPos(eventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *methodName) { - return getMethodPos(methodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::pause() { - if (_state == SCRIPT_PAUSED) { - _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return STATUS_FAILED; - } - - if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; - - _origState = _state; - _state = SCRIPT_PAUSED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::resume() { - if (_state != SCRIPT_PAUSED) return STATUS_OK; - - _state = _origState; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::getExternal(char *name) { - for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) - return &_externals[i]; - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { - - _gameRef->LOG(0, "External functions are not supported on this platform."); - stack->correctParams(0); - stack->pushNULL(); - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::copyParameters(CScStack *stack) { - int i; - int NumParams = stack->pop()->getInt(); - for (i = NumParams - 1; i >= 0; i--) { - _stack->push(stack->getAt(i)); - } - _stack->pushInt(NumParams); - - for (i = 0; i < NumParams; i++) stack->pop(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.getSize(); i++) { - CScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) - scr->finish(true); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int CScScript::dbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *CScScript::dbgGetFilename() { - return _filename; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else client->onScriptInit(this); - - return dbgSendVariables(client); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendVariables(IWmeDebugClient *client) { - // send script globals - _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::dbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetNumBreakpoints() { - return _breakpoints.getSize(); -} - -////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; - else return -1; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool isTracing) { - _tracingMode = isTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgGetTracingMode() { - return _tracingMode; -} - - -////////////////////////////////////////////////////////////////////////// -void CScScript::afterLoad() { - if (_buffer == NULL) { - byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); - if (!buffer) { - _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); - _state = SCRIPT_ERROR; - return; - } - - _buffer = new byte [_bufferSize]; - memcpy(_buffer, buffer, _bufferSize); - - delete _scriptStream; - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - - initTables(); - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScScript.h b/engines/wintermute/base/scriptables/ScScript.h deleted file mode 100644 index c031f8186f..0000000000 --- a/engines/wintermute/base/scriptables/ScScript.h +++ /dev/null @@ -1,183 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -#include "engines/wintermute/wme_debugger.h" - -namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { -public: - bool dbgSendScript(IWmeDebugClient *client); - bool dbgSendVariables(IWmeDebugClient *client); - - CBArray _breakpoints; - bool _tracingMode; - - CScScript *_parentScript; - bool _unbreakable; - bool finishThreads(); - bool copyParameters(CScStack *stack); - - void afterLoad(); - - CScValue *_operand; - CScValue *_reg1; - bool _freezable; - bool resume(); - bool pause(); - bool canHandleEvent(const char *eventName); - bool canHandleMethod(const char *methodName); - bool createThread(CScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(CScScript *original, const char *methodName); - CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); - uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) - void runtimeError(const char *fmt, ...); - bool run(); - bool finish(bool includingThreads = false); - bool sleep(uint32 duration); - bool waitForExclusive(CBObject *object); - bool waitFor(CBObject *object); - uint32 _waitTime; - bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - CScValue *getVar(char *name); - uint32 getFuncPos(const char *name); - uint32 getEventPos(const char *name); - uint32 getMethodPos(const char *name); - typedef struct { - uint32 magic; - uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; - } TScriptHeader; - - TScriptHeader _header; - - typedef struct { - char *name; - uint32 pos; - } TFunctionPos; - - typedef struct { - char *name; - uint32 pos; - } TMethodPos; - - typedef struct { - char *name; - uint32 pos; - } TEventPos; - - typedef struct { - char *name; - char *dll_name; - TCallType call_type; - TExternalType returns; - int nu_params; - TExternalType *params; - } TExternalFunction; - - - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; - int _currentLine; - bool executeInstruction(); - char *getString(); - uint32 getDWORD(); - double getFloat(); - void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); - uint32 _iP; -private: - void readHeader(); - uint32 _bufferSize; - byte *_buffer; -public: - Common::SeekableReadStream *_scriptStream; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); - char *_filename; - char **_symbols; - uint32 _numSymbols; - TFunctionPos *_functions; - TMethodPos *_methods; - TEventPos *_events; - uint32 _numExternals; - TExternalFunction *_externals; - uint32 _numFunctions; - uint32 _numMethods; - uint32 _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *getExternal(char *name); - bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); -private: - bool initScript(); - bool initTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int dbgGetLine(); - virtual const char *dbgGetFilename(); - virtual TScriptState dbgGetState(); - virtual int dbgGetNumBreakpoints(); - virtual int dbgGetBreakpoint(int Index); - - virtual bool dbgSetTracingMode(bool IsTracing); - virtual bool dbgGetTracingMode(); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScStack.cpp b/engines/wintermute/base/scriptables/ScStack.cpp deleted file mode 100644 index 252cd21dda..0000000000 --- a/engines/wintermute/base/scriptables/ScStack.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/ScStack.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/BGame.h" - -namespace WinterMute { - -IMPLEMENT_PERSISTENT(CScStack, false) - -////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { - -#if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); -#endif - - for (int i = 0; i < _values.getSize(); i++) { - delete _values[i]; - } - _values.removeAll(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::pop() { - if (_sP < 0) { - _gameRef->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::push(CScValue *val) { - _sP++; - - if (_sP < _values.getSize()) { - _values[_sP]->cleanup(); - _values[_sP]->copy(val); - } else { - CScValue *copyVal = new CScValue(_gameRef); - copyVal->copy(val); - _values.add(copyVal); - } -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getPushValue() { - _sP++; - - if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(_gameRef); - _values.add(val); - } - _values[_sP]->cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) return NULL; - else return _values[_sP]; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getAt(int index) { - index = _sP - index; - if (index < 0 || index >= _values.getSize()) return NULL; - else return _values[index]; -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expectedParams) { - uint32 nuParams = (uint32)pop()->getInt(); - - if (expectedParams < nuParams) { // too many params - while (expectedParams < nuParams) { - //Pop(); - delete _values[_sP - expectedParams]; - _values.removeAt(_sP - expectedParams); - nuParams--; - _sP--; - } - } else if (expectedParams > nuParams) { // need more params - while (expectedParams > nuParams) { - //Push(null_val); - CScValue *nullVal = new CScValue(_gameRef); - nullVal->setNULL(); - _values.insertAt(_sP - nuParams + 1, nullVal); - nuParams++; - _sP++; - - if (_values.getSize() > _sP + 1) { - delete _values[_values.getSize() - 1]; - _values.removeAt(_values.getSize() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNULL() { - /* - CScValue* val = new CScValue(_gameRef); - val->setNULL(); - Push(val); - delete val; - */ - getPushValue()->setNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushInt(int val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setInt(Val); - Push(val); - delete val; - */ - getPushValue()->setInt(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushFloat(double val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setFloat(Val); - Push(val); - delete val; - */ - getPushValue()->setFloat(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushBool(bool val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setBool(Val); - Push(val); - delete val; - */ - getPushValue()->setBool(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushString(const char *val) { - /* - CScValue* val = new CScValue(_gameRef); - val->setString(Val); - Push(val); - delete val; - */ - getPushValue()->setString(val); -} - - -////////////////////////////////////////////////////////////////////////// -void CScStack::pushNative(CBScriptable *val, bool persistent) { - /* - CScValue* val = new CScValue(_gameRef); - val->setNative(Val, Persistent); - Push(val); - delete val; - */ - - getPushValue()->setNative(val, persistent); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScStack::persist(CBPersistMgr *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_sP)); - _values.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScStack.h b/engines/wintermute/base/scriptables/ScStack.h deleted file mode 100644 index 22dae63060..0000000000 --- a/engines/wintermute/base/scriptables/ScStack.h +++ /dev/null @@ -1,66 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSTACK_H -#define WINTERMUTE_SCSTACK_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" - -namespace WinterMute { - -class CScValue; -class CBScriptable; - -class CScStack : public CBBase { -public: - CScValue *getAt(int Index); - CScValue *getPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *val, bool persistent); - void pushString(const char *val); - void pushBool(bool val); - void pushInt(int val); - void pushFloat(double val); - void pushNULL(); - void correctParams(uint32 expectedParams); - CScValue *getTop(); - void push(CScValue *val); - CScValue *pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; - int _sP; - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/ScValue.cpp b/engines/wintermute/base/scriptables/ScValue.cpp deleted file mode 100644 index f38a12fc7a..0000000000 --- a/engines/wintermute/base/scriptables/ScValue.cpp +++ /dev/null @@ -1,1054 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/BDynBuffer.h" -#include "engines/wintermute/base/BGame.h" -#include "engines/wintermute/base/scriptables/ScValue.h" -#include "engines/wintermute/base/scriptables/ScScript.h" -#include "engines/wintermute/utils/StringUtil.h" -#include "engines/wintermute/base/BScriptable.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CScValue, false) - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { - _type = VAL_BOOL; - _valBool = val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { - _type = VAL_INT; - _valInt = val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { - _type = VAL_FLOAT; - _valFloat = val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { - _type = VAL_STRING; - _valString = NULL; - setStringVal(val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool ignoreNatives) { - deleteProps(); - - if (_valString) delete [] _valString; - - if (!ignoreNatives) { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - _valNative = NULL; - } - } - } - - - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - - -////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); - - if (_type == VAL_STRING && strcmp(name, "Length") == 0) { - _gameRef->_scValue->_type = VAL_INT; - -#if 0 // TODO: Remove FreeType-dependency - if (_gameRef->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif - _gameRef->_scValue->setInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::utf8ToWide(_valString); - _gameRef->_scValue->setInt(wstr.size()); - } - - return _gameRef->_scValue; - } - - CScValue *ret = NULL; - - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); - - if (ret == NULL) { - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) ret = _valIter->_value; - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - delete _valIter->_value; - _valIter->_value = NULL; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) - return _valRef->setProp(name, val); - - bool ret = STATUS_FAILED; - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(name, val); - } - - if (DID_FAIL(ret)) { - CScValue *newVal = NULL; - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - newVal = _valIter->_value; - } - if (!newVal) - newVal = new CScValue(_gameRef); - else newVal->cleanup(); - - newVal->copy(val, copyWhole); - newVal->_isConstVar = setAsConst; - _valObject[name] = newVal; - - if (_type != VAL_NATIVE) _type = VAL_OBJECT; - - /* - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()){ - delete _valIter->_value; - _valIter->_value = NULL; - } - CScValue* val = new CScValue(_gameRef); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) - return _valRef->propExists(name); - _valIter = _valObject.find(name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::deleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool includingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNULL(); - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isNative(); - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isString(); - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isFloat(); - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isInt() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isInt(); - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isBool() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isBool(); - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::isObject() { - if (_type == VAL_VARIABLE_REF) - return _valRef->isObject(); - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getType(); - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setBool(bool val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setBool(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetBool(val); - return; - } - - _valBool = val; - _type = VAL_BOOL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setInt(int val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setInt(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetInt(val); - return; - } - - _valInt = val; - _type = VAL_INT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setFloat(double val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setFloat(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetFloat(val); - return; - } - - _valFloat = val; - _type = VAL_FLOAT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setString(const char *val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setString(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetString(val); - return; - } - - setStringVal(val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; -} - -void CScValue::setString(const Common::String &val) { - setString(val.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -void CScValue::setStringVal(const char *val) { - if (_valString) { - delete [] _valString; - _valString = NULL; - } - - if (val == NULL) { - _valString = NULL; - return; - } - - _valString = new char [strlen(val) + 1]; - if (_valString) { - strcpy(_valString, val); - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNULL() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNULL(); - return; - } - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; - } - _valNative = NULL; - deleteProps(); - - _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *val, bool persistent) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNative(val, persistent); - return; - } - - if (val == NULL) { - setNULL(); - } else { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != val) delete _valNative; - _valNative = NULL; - } - } - - _type = VAL_NATIVE; - _persistent = persistent; - - _valNative = val; - if (_valNative && !_persistent) _valNative->_refCount++; - } -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setObject(); - return; - } - - deleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *val) { - _valRef = val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getBool(); - - switch (_type) { - case VAL_BOOL: - return _valBool; - - case VAL_NATIVE: - return _valNative->scToBool(); - - case VAL_INT: - return (_valInt != 0); - - case VAL_FLOAT: - return (_valFloat != 0.0f); - - case VAL_STRING: - return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1 : 0; - - case VAL_NATIVE: - return _valNative->scToInt(); - - case VAL_INT: - return _valInt; - - case VAL_FLOAT: - return (int)_valFloat; - - case VAL_STRING: - return atoi(_valString); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) - return _valRef->getFloat(); - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1.0f : 0.0f; - - case VAL_NATIVE: - return _valNative->scToFloat(); - - case VAL_INT: - return (double)_valInt; - - case VAL_FLOAT: - return _valFloat; - - case VAL_STRING: - return atof(_valString); - - default: - return defaultVal; - } -} - -////////////////////////////////////////////////////////////////////////// -void *CScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getMemBuffer(); - - if (_type == VAL_NATIVE) - return _valNative->scToMemBuffer(); - else return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::getString() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getString(); - - switch (_type) { - case VAL_OBJECT: - setStringVal("[object]"); - break; - - case VAL_NULL: - setStringVal("[null]"); - break; - - case VAL_NATIVE: { - const char *strVal = _valNative->scToString(); - setStringVal(strVal); - return strVal; - break; - } - - case VAL_BOOL: - setStringVal(_valBool ? "yes" : "no"); - break; - - case VAL_INT: { - char dummy[50]; - sprintf(dummy, "%d", _valInt); - setStringVal(dummy); - break; - } - - case VAL_FLOAT: { - char dummy[50]; - sprintf(dummy, "%f", _valFloat); - setStringVal(dummy); - break; - } - - case VAL_STRING: - break; - - default: - setStringVal(""); - } - - return _valString; -} - - -////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::getNative() { - if (_type == VAL_VARIABLE_REF) - return _valRef->getNative(); - - if (_type == VAL_NATIVE) return _valNative; - else return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -TValType CScValue::getType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::copy(CScValue *orig, bool copyWhole) { - _gameRef = orig->_gameRef; - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; - _valNative = NULL; - } - } - - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; - - cleanup(true); - - _type = orig->_type; - _valBool = orig->_valBool; - _valInt = orig->_valInt; - _valFloat = orig->_valFloat; - setStringVal(orig->_valString); - - _valRef = orig->_valRef; - _persistent = orig->_persistent; - - _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; -//!!!! ref->native++ - - // copy properties - if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { - orig->_valIter = orig->_valObject.begin(); - while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(_gameRef); - _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); - orig->_valIter++; - } - } else _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void CScValue::setValue(CScValue *val) { - if (val->_type == VAL_VARIABLE_REF) { - setValue(val->_valRef); - return; - } - - // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { - switch (val->_type) { - case VAL_INT: - _valNative->scSetInt(val->getInt()); - break; - case VAL_FLOAT: - _valNative->scSetFloat(val->getFloat()); - break; - case VAL_BOOL: - _valNative->scSetBool(val->getBool()); - break; - case VAL_STRING: - _valNative->scSetString(val->getString()); - break; - default: - warning("CScValue::setValue - unhandled enum"); - break; - } - } - // otherwise just copy everything - else copy(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::persist(CBPersistMgr *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_persistent)); - persistMgr->transfer(TMEMBER(_isConstVar)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_valBool)); - persistMgr->transfer(TMEMBER(_valFloat)); - persistMgr->transfer(TMEMBER(_valInt)); - persistMgr->transfer(TMEMBER(_valNative)); - - int size; - const char *str; - if (persistMgr->_saving) { - size = _valObject.size(); - persistMgr->transfer("", &size); - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - str = _valIter->_key.c_str(); - persistMgr->transfer("", &str); - persistMgr->transfer("", &_valIter->_value); - - _valIter++; - } - } else { - CScValue *val; - persistMgr->transfer("", &size); - for (int i = 0; i < size; i++) { - persistMgr->transfer("", &str); - persistMgr->transfer("", &val); - - _valObject[str] = val; - delete [] str; - } - } - - persistMgr->transfer(TMEMBER(_valRef)); - persistMgr->transfer(TMEMBER(_valString)); - - /* - FILE* f = fopen("c:\\val.log", "a+"); - switch(_type) - { - case VAL_STRING: - fprintf(f, "str %s\n", _valString); - break; - - case VAL_INT: - fprintf(f, "int %d\n", _valInt); - break; - - case VAL_BOOL: - fprintf(f, "bool %d\n", _valBool); - break; - - case VAL_NULL: - fprintf(f, "null\n"); - break; - - case VAL_NATIVE: - fprintf(f, "native\n"); - break; - - case VAL_VARIABLE_REF: - fprintf(f, "ref\n"); - break; - - case VAL_OBJECT: - fprintf(f, "obj\n"); - break; - - case VAL_FLOAT: - fprintf(f, "float\n"); - break; - - } - fclose(f); - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - buffer->putTextIndent(indent, "PROPERTY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); - buffer->putTextIndent(indent, "}\n\n"); - - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::compare(CScValue *val1, CScValue *val2) { - // both natives? - if (val1->isNative() && val2->isNative()) { - // same class? - if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { - return val1->getNative()->scCompare(val2->getNative()); - } else return strcmp(val1->getString(), val2->getString()); - } - - // both objects? - if (val1->isObject() && val2->isObject()) return -1; - - - // null states - if (val1->isNULL() && !val2->isNULL()) return -1; - else if (!val1->isNULL() && val2->isNULL()) return 1; - else if (val1->isNULL() && val2->isNULL()) return 0; - - // one of them is string? convert both to string - if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); - - // one of them is float? - if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) return -1; - else if (val1->getFloat() > val2->getFloat()) return 1; - else return 0; - } - - // otherwise compare as int's - if (val1->getInt() < val2->getInt()) return -1; - else if (val1->getInt() > val2->getInt()) return 1; - else return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::compareStrict(CScValue *val1, CScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return CScValue::compare(val1, val2); -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(_gameRef); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::dbgGetType() { - switch (getType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetValInt() { - return getInt(); -} - -////////////////////////////////////////////////////////////////////////// -double CScValue::dbgGetValFloat() { - return getFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetValBool() { - return getBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *CScValue::dbgGetValString() { - return getString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::dbgGetValNative() { - return getNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(int value) { - setInt(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(double value) { - setFloat(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(bool value) { - setBool(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(const char *value) { - setString(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal() { - setNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetNumProperties(); - else return _valObject.size(); -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) - return _valNative->_scProp->dbgGetProperty(index, name, value); - else { - int count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (count == index) { - *name = _valIter->_key.c_str(); - *value = _valIter->_value; - return true; - } - _valIter++; - count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) - return _valRef->dbgGetDescription(buf, bufSize); - - if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(buf, bufSize); - } else { - strncpy(buf, getString(), bufSize); - } - return true; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/ScValue.h b/engines/wintermute/base/scriptables/ScValue.h deleted file mode 100644 index c66a60c22a..0000000000 --- a/engines/wintermute/base/scriptables/ScValue.h +++ /dev/null @@ -1,141 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCVALUE_H -#define WINTERMUTE_SCVALUE_H - - -#include "engines/wintermute/base/BBase.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/wme_debugger.h" -#include "common/str.h" - -namespace WinterMute { - -class CScScript; -class CBScriptable; - -class CScValue : public CBBase, public IWmeDebugProp { -public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); - - static int compare(CScValue *val1, CScValue *val2); - static int compareStrict(CScValue *val1, CScValue *val2); - TValType getTypeTolerant(); - void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) - - bool _isConstVar; - bool saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *val); - bool _persistent; - bool propExists(const char *name); - void copy(CScValue *orig, bool copyWhole = false); - void setStringVal(const char *val); - TValType getType(); - bool getBool(bool defaultVal = false); - int getInt(int defaultVal = 0); - double getFloat(double defaultVal = 0.0f); - const char *getString(); - void *getMemBuffer(); - CBScriptable *getNative(); - bool deleteProp(const char *name); - void deleteProps(); - void CleanProps(bool includingNatives); - void setBool(bool val); - void setInt(int val); - void setFloat(double val); - void setString(const char *val); - void setString(const Common::String &val); - void setNULL(); - void setNative(CBScriptable *val, bool persistent = false); - void setObject(); - void setReference(CScValue *val); - bool isNULL(); - bool isNative(); - bool isString(); - bool isBool(); - bool isFloat(); - bool isInt(); - bool isObject(); - bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); - CScValue *getProp(const char *name); - CBScriptable *_valNative; - CScValue *_valRef; -protected: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; - - bool setProperty(const char *propName, int value); - bool setProperty(const char *propName, const char *value); - bool setProperty(const char *propName, double value); - bool setProperty(const char *propName, bool value); - bool setProperty(const char *propName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType dbgGetType(); - - // getters - virtual int dbgGetValInt(); - virtual double dbgGetValFloat(); - virtual bool dbgGetValBool(); - virtual const char *dbgGetValString(); - virtual IWmeDebugObject *dbgGetValNative(); - - // setters - virtual bool dbgSetVal(int value); - virtual bool dbgSetVal(double value); - virtual bool dbgSetVal(bool value); - virtual bool dbgSetVal(const char *value); - virtual bool dbgSetVal(); - - // properties - virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - - virtual bool dbgGetDescription(char *buf, int bufSize); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/SxObject.cpp b/engines/wintermute/base/scriptables/SxObject.cpp deleted file mode 100644 index ba961ed2ae..0000000000 --- a/engines/wintermute/base/scriptables/SxObject.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "SxObject.h" -#include "ScValue.h" -#include "ScStack.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(CSXObject, false) - -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { - return new CSXObject(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { - int numParams = stack->pop()->getInt(0); - for (int i = 0; i < numParams; i++) { - addScript(stack->pop()->getString()); - } -} - - -////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool CSXObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/SxObject.h b/engines/wintermute/base/scriptables/SxObject.h deleted file mode 100644 index b4ec7c6cde..0000000000 --- a/engines/wintermute/base/scriptables/SxObject.h +++ /dev/null @@ -1,47 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/base/BObject.h" - -namespace WinterMute { - -class CSXObject : public CBObject { -public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); - -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp new file mode 100644 index 0000000000..a9646e0045 --- /dev/null +++ b/engines/wintermute/base/scriptables/script.cpp @@ -0,0 +1,1461 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/memstream.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScScript, false) + +////////////////////////////////////////////////////////////////////////// +CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _scriptStream = NULL; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = Engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::~CScScript() { + cleanup(); +} + +void CScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.code_start = _scriptStream->readUint32LE(); + _header.func_table = _scriptStream->readUint32LE(); + _header.symbol_table = _scriptStream->readUint32LE(); + _header.event_table = _scriptStream->readUint32LE(); + _header.externals_table = _scriptStream->readUint32LE(); + _header.method_table = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); + + if (_header.magic != SCRIPT_MAGIC) { + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); + cleanup(); + return STATUS_FAILED; + } + + if (_header.version > SCRIPT_VERSION) { + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + cleanup(); + return STATUS_FAILED; + } + + initTables(); + + // init stacks + _scopeStack = new CScStack(_gameRef); + _callStack = new CScStack(_gameRef); + _thisStack = new CScStack(_gameRef); + _stack = new CScStack(_gameRef); + + _operand = new CScValue(_gameRef); + _reg1 = new CScValue(_gameRef); + + + // skip to the beginning + _iP = _header.code_start; + _scriptStream->seek(_iP); + _currentLine = 0; + + // init breakpoints + _engine->refreshScriptBreakpoints(this); + + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::initTables() { + uint32 OrigIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbol_table; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.func_table; + + _numFunctions = getDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (uint32 i = 0; i < _numFunctions; i++) { + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); + } + + + // load events table + _iP = _header.event_table; + + _numEvents = getDWORD(); + _events = new TEventPos[_numEvents]; + for (uint32 i = 0; i < _numEvents; i++) { + _events[i].pos = getDWORD(); + _events[i].name = getString(); + } + + + // load externals + if (_header.version >= 0x0101) { + _iP = _header.externals_table; + + _numExternals = getDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (uint32 i = 0; i < _numExternals; i++) { + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)getDWORD(); + } + } + } + } + + // load method table + _iP = _header.method_table; + + _numMethods = getDWORD(); + _methods = new TMethodPos[_numMethods]; + for (uint32 i = 0; i < _numMethods; i++) { + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); + } + + + _iP = OrigIP; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { + cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(filename) + 1]; + if (_filename) strcpy(_filename, filename); + + _buffer = new byte [size]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, buffer, size); + + _bufferSize = size; + + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // establish global variables table + _globals = new CScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[strlen(eventName) + 1]; + if (_threadEvent) strcpy(_threadEvent, eventName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = initIP; + _scriptStream->seek(_iP); + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::createMethodThread(CScScript *original, const char *methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) return STATUS_FAILED; + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[strlen(methodName) + 1]; + if (_threadEvent) strcpy(_threadEvent, methodName); + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) strcpy(_filename, original->_filename); + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) return STATUS_FAILED; + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) return res; + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = ip; + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::cleanup() { + if (_buffer) delete [] _buffer; + _buffer = NULL; + + if (_filename) delete [] _filename; + _filename = NULL; + + if (_symbols) delete [] _symbols; + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) delete _globals; + _globals = NULL; + + delete _scopeStack; + _scopeStack = NULL; + + delete _callStack; + _callStack = NULL; + + delete _thisStack; + _thisStack = NULL; + + delete _stack; + _stack = NULL; + + if (_functions) delete [] _functions; + _functions = NULL; + _numFunctions = 0; + + if (_methods) delete [] _methods; + _methods = NULL; + _numMethods = 0; + + if (_events) delete [] _events; + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (uint32 i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) delete [] _externals[i].params; + } + delete [] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only + + delete _scriptStream; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double CScScript::getFloat() { + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *CScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') _iP++; + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //CScValue* op = new CScValue(_gameRef); + _operand->cleanup(); + + CScValue *op1; + CScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = getDWORD(); + /* char *Temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); + + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; + else _state = SCRIPT_PERSISTENT; + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = getDWORD(); + + _operand->setInt(_iP); + _callStack->push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->pop()->getString(); + char *MethodName = new char[strlen(str) + 1]; + strcpy(MethodName, str); + + CScValue *var = _stack->pop(); + if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + + bool res = STATUS_FAILED; + bool TriedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + TriedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } + + if (DID_FAIL(res)) { + if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (!_unbreakable) { + _waitScript = var->getNative()->invokeMethodThread(MethodName); + if (!_waitScript) { + _stack->correctParams(0); + runtimeError("Error invoking method '%s'.", MethodName); + _stack->pushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->copyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->correctParams(0); + runtimeError("Cannot call method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + delete [] MethodName; + break; + } + /* + CScValue* val = var->getProp(MethodName); + if(val){ + dw = GetFuncPos(val->getString()); + if(dw==0){ + TExternalFunction* f = GetExternal(val->getString()); + if(f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); + } + } + else{ + _operand->setInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = STATUS_FAILED; + if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + + if (DID_FAIL(res)) { + _stack->correctParams(0); + runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + _stack->pushNULL(); + } + } + } + delete [] MethodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 SymbolIndex = getDWORD(); + + TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + if (f) { + externalCall(_stack, _thisStack, f); + } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + + break; + } + case II_SCOPE: + _operand->setNULL(); + _scopeStack->push(_operand); + + if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + + break; + + case II_CORRECT_STACK: + dw = getDWORD(); // params expected + _stack->correctParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->setObject(); + _stack->push(_operand); + break; + + case II_POP_EMPTY: + _stack->pop(); + break; + + case II_PUSH_VAR: { + CScValue *var = getVar(_symbols[getDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->setReference(var); + _stack->push(_operand); + } else _stack->push(var); + break; + } + + case II_PUSH_VAR_REF: { + CScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *VarName = _symbols[getDWORD()]; + CScValue *var = getVar(VarName); + if (var) { + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; + if (val->_type == VAL_NATIVE) var->setValue(val); + else { + var->copy(val); + } + } + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->push(_thisStack->getTop()); + break; + + case II_PUSH_INT: + _stack->pushInt((int)getDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->pushFloat(getFloat()); + break; + + + case II_PUSH_BOOL: + _stack->pushBool(getDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->pushString(getString()); + break; + + case II_PUSH_NULL: + _stack->pushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->setReference(_stack->getTop()); + _thisStack->push(_operand); + break; + + case II_PUSH_THIS: + _operand->setReference(getVar(_symbols[getDWORD()])); + _thisStack->push(_operand); + break; + + case II_POP_THIS: + _thisStack->pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *val = _stack->pop()->getProp(str); + if (val) _stack->push(val); + else _stack->pushNULL(); + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + CScValue *var = _stack->pop(); + CScValue *val = _stack->pop(); + + if (val == NULL) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else var->setProp(str, val); + + if (_gameRef->getDebugMgr()->_enabled) + _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + + break; + } + + case II_PUSH_REG1: + _stack->push(_reg1); + break; + + case II_POP_REG1: + _reg1->copy(_stack->pop()); + break; + + case II_JMP: + _iP = getDWORD(); + break; + + case II_JMP_FALSE: { + dw = getDWORD(); + //if(!_stack->pop()->getBool()) _iP = dw; + CScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!val->getBool()) _iP = dw; + } + break; + } + + case II_ADD: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); + delete [] tempStr; + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() + op2->getInt()); + else _operand->setFloat(op1->getFloat() + op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_SUB: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) + _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() - op2->getInt()); + else _operand->setFloat(op1->getFloat() - op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MUL: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); + else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + _operand->setInt(op1->getInt() * op2->getInt()); + else _operand->setFloat(op1->getFloat() * op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_DIV: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getFloat() == 0.0f) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); + else _operand->setFloat(op1->getFloat() / op2->getFloat()); + + _stack->push(_operand); + + break; + + case II_MODULO: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getInt() == 0) + runtimeError("Division by zero."); + + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + _operand->setNULL(); + else _operand->setInt(op1->getInt() % op2->getInt()); + + _stack->push(_operand); + + break; + + case II_NOT: + op1 = _stack->pop(); + //if(op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) _operand->setBool(true); + else _operand->setBool(!op1->getBool()); + _stack->push(_operand); + + break; + + case II_AND: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() && op2->getBool()); + } + _stack->push(_operand); + break; + + case II_OR: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() || op2->getBool()); + } + _stack->push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() == op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) == 0); + _stack->push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if(op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); + } + else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); + } + else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() != op2->getInt()); + } + */ + + _operand->setBool(CScValue::compare(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_CMP_L: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); + } + else _operand->setBool(op1->getInt() < op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) < 0); + _stack->push(_operand); + break; + + case II_CMP_G: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); + } + else _operand->setBool(op1->getInt() > op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) > 0); + _stack->push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); + } + else _operand->setBool(op1->getInt() <= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) <= 0); + _stack->push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); + } + else _operand->setBool(op1->getInt() >= op2->getInt()); + */ + + _operand->setBool(CScValue::compare(op1, op2) >= 0); + _stack->push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _stack->push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + if (_gameRef->getDebugMgr()->_enabled) { + _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (_breakpoints[i] == _currentLine) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + if (_tracingMode) { + _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); + sleep(0); + break; + } + } + } + break; + + } + default: + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = STATUS_FAILED; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getFuncPos(const char *name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (strcmp(name, _functions[i].name) == 0) + return _functions[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getMethodPos(const char *name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (strcmp(name, _methods[i].name) == 0) + return _methods[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScScript::getVar(char *name) { + CScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->getTop()->propExists(name)) + ret = _scopeStack->getTop()->getProp(name); + } + + // script globals + if (ret == NULL) { + if (_globals->propExists(name)) + ret = _globals->getProp(name); + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->propExists(name)) + ret = _engine->_globals->getProp(name); + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + CScValue *val = new CScValue(_gameRef); + CScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); + ret = _scopeStack->getTop()->getProp(name); + } else { + _globals->setProp(name, val); + ret = _globals->getProp(name); + } + delete val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitFor(CBObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::waitForExclusive(CBObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = CBPlatform::getTime() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else _state = SCRIPT_FINISHED; + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void CScScript::runtimeError(const char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); + + if (!_gameRef->_suppressScriptErrors) + _gameRef->quickMessage("Script runtime error. View log for details."); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->_saving) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + persistMgr->transfer(TMEMBER(bufferSize)); + } + } else { + persistMgr->transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + initTables(); + } else { + _buffer = NULL; + _scriptStream = NULL; + } + } + + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->_saving) _tracingMode = false; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { + //if(_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) return NULL; + + CScScript *thread = new CScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + return thread; + } else { + delete thread; + return NULL; + } + } else return NULL; + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CScScript::getEventPos(const char *name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleEvent(const char *eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::canHandleMethod(const char *methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::pause() { + if (_state == SCRIPT_PAUSED) { + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return STATUS_FAILED; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + + _origState = _state; + _state = SCRIPT_PAUSED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::resume() { + if (_state != SCRIPT_PAUSED) return STATUS_OK; + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CScScript::TExternalFunction *CScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) + return &_externals[i]; + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::copyParameters(CScStack *stack) { + int i; + int NumParams = stack->pop()->getInt(); + for (i = NumParams - 1; i >= 0; i--) { + _stack->push(stack->getAt(i)); + } + _stack->pushInt(NumParams); + + for (i = 0; i < NumParams; i++) stack->pop(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::finishThreads() { + for (int i = 0; i < _engine->_scripts.getSize(); i++) { + CScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + scr->finish(true); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int CScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *CScScript::dbgGetFilename() { + return _filename; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendScript(IWmeDebugClient *client) { + if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + else client->onScriptInit(this); + + return dbgSendVariables(client); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSendVariables(IWmeDebugClient *client) { + // send script globals + _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); + + // send scope variables + if (_scopeStack->_sP >= 0) { + for (int i = 0; i <= _scopeStack->_sP; i++) { + // CScValue *Scope = _scopeStack->GetAt(i); + //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +TScriptState CScScript::dbgGetState() { + return _state; +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetNumBreakpoints() { + return _breakpoints.getSize(); +} + +////////////////////////////////////////////////////////////////////////// +int CScScript::dbgGetBreakpoint(int index) { + if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; + else return -1; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgSetTracingMode(bool isTracing) { + _tracingMode = isTracing; + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScScript::dbgGetTracingMode() { + return _tracingMode; +} + + +////////////////////////////////////////////////////////////////////////// +void CScScript::afterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); + if (!buffer) { + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + + initTables(); + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h new file mode 100644 index 0000000000..899e1f3098 --- /dev/null +++ b/engines/wintermute/base/scriptables/script.h @@ -0,0 +1,183 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +#include "engines/wintermute/wme_debugger.h" + +namespace WinterMute { +class CBScriptHolder; +class CBObject; +class CScEngine; +class CScStack; +class CScScript : public CBBase, public IWmeDebugScript { +public: + bool dbgSendScript(IWmeDebugClient *client); + bool dbgSendVariables(IWmeDebugClient *client); + + CBArray _breakpoints; + bool _tracingMode; + + CScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(CScStack *stack); + + void afterLoad(); + + CScValue *_operand; + CScValue *_reg1; + bool _freezable; + bool resume(); + bool pause(); + bool canHandleEvent(const char *eventName); + bool canHandleMethod(const char *methodName); + bool createThread(CScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(CScScript *original, const char *methodName); + CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(CScScript, CBBase) + void runtimeError(const char *fmt, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(CBObject *object); + bool waitFor(CBObject *object); + uint32 _waitTime; + bool _waitFrozen; + CBObject *_waitObject; + CScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + CScValue *getVar(char *name); + uint32 getFuncPos(const char *name); + uint32 getEventPos(const char *name); + uint32 getMethodPos(const char *name); + typedef struct { + uint32 magic; + uint32 version; + uint32 code_start; + uint32 func_table; + uint32 symbol_table; + uint32 event_table; + uint32 externals_table; + uint32 method_table; + } TScriptHeader; + + TScriptHeader _header; + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + CScStack *_callStack; + CScStack *_thisStack; + CScStack *_scopeStack; + CScStack *_stack; + CScValue *_globals; + CScEngine *_engine; + int _currentLine; + bool executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); + void cleanup(); + bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + CScScript(CBGame *inGame, CScEngine *Engine); + virtual ~CScScript(); + char *_filename; + char **_symbols; + uint32 _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + bool _thread; + bool _methodThread; + char *_threadEvent; + CBScriptHolder *_owner; + CScScript::TExternalFunction *getExternal(char *name); + bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); +private: + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); + virtual TScriptState dbgGetState(); + virtual int dbgGetNumBreakpoints(); + virtual int dbgGetBreakpoint(int Index); + + virtual bool dbgSetTracingMode(bool IsTracing); + virtual bool dbgGetTracingMode(); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp new file mode 100644 index 0000000000..387093ac4a --- /dev/null +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -0,0 +1,712 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_file_manager.h" + + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { + _gameRef->LOG(0, "Initializing scripting engine..."); + + if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); + else _gameRef->LOG(0, " Script compiler is NOT available"); + + _globals = new CScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + CScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + CScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); + _globals->setProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + + _currentScript = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +CScEngine::~CScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + saveBreakpoints(); + + disableProfiling(); + + cleanup(); + + for (int i = 0; i < _breakpoints.getSize(); i++) { + delete _breakpoints[i]; + _breakpoints[i] = NULL; + } + _breakpoints.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::cleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + + _scripts.removeAll(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { + CBGame *gameRef = (CBGame *)data; + return gameRef->_fileManager->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::closeFile(void *data, byte *buffer) { + delete [] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) return NULL; + + // add new script + CScScript *script = new CScScript(_gameRef, this); + bool ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { + _gameRef->LOG(ret, "Error running script '%s'...", filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + CScValue val(_gameRef); + if (owner)val.setNative(owner, true); + else val.setNULL(); + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + _gameRef->getDebugMgr()->onScriptInit(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { + // is script in cache? + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { + _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + return NULL; + } + + // needs to be compiled? + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; + } else { + if (!_compilerAvailable) { + _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + delete [] buffer; + return NULL; + } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { + int index = 0; + uint32 MinTime = CBPlatform::getTime(); + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= MinTime) { + MinTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete [] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tick() { + if (_scripts.getSize() == 0) + return STATUS_OK; + + + // resolve waiting scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + { + if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + { + if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + */ + if (_gameRef->validObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); + } else _scripts[i]->finish(); + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + } else { + if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->pushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); + _scripts[i]->run(); + _scripts[i]->_waitScript->finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + default: + //warning("CScEngine::Tick - Unhandled enum"); + break; + } // switch + } // for each script + + + // execute scripts + for (int i = 0; i < _scripts.getSize(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 StartTime = CBPlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + } + + // normal script + else { + uint32 startTime = 0; + bool isProfiling = _isProfiling; + if (isProfiling) startTime = CBPlatform::getTime(); + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (!_scripts[i]->_unbreakable) continue; + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + _scripts[i]->finish(); + _currentScript = NULL; + } + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeFinishedScripts() { + // remove finished scripts + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + numRunning++; + break; + case SCRIPT_WAITING: + numWaiting++; + break; + case SCRIPT_PERSISTENT: + numPersistent++; + break; + default: + warning("CScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) *running = numRunning; + if (waiting) *waiting = numWaiting; + if (persistent) *persistent = numPersistent; + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetObject(CBObject *Object) { + // terminate all scripts waiting for this object + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + + bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resetScript(CScScript *script) { + // terminate all scripts waiting for this script + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::persist(CBPersistMgr *persistMgr) { + if (!persistMgr->_saving) cleanup(); + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::editorCleanup() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.removeAt(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::pauseAll() { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] != _currentScript) _scripts[i]->pause(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::resumeAll() { + for (int i = 0; i < _scripts.getSize(); i++) + _scripts[i]->resume(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::isValidScript(CScScript *script) { + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i] == script) return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { + // send global variables + _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); + + // process normal scripts first + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + _scripts[i]->dbgSendScript(client); + } + + // and threads later + for (int i = 0; i < _scripts.getSize(); i++) { + if (_scripts[i]->_thread || _scripts[i]->_methodThread) + _scripts[i]->dbgSendScript(client); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + CScBreakpoint *bp = NULL; + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + bp = _breakpoints[i]; + break; + } + } + if (bp == NULL) { + bp = new CScBreakpoint(scriptFilename); + _breakpoints.add(bp); + } + + for (int i = 0; i < bp->_lines.getSize(); i++) { + if (bp->_lines[i] == line) return STATUS_OK; + } + bp->_lines.add(line); + + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + if (_breakpoints[i]->_lines[j] == line) { + _breakpoints[i]->_lines.removeAt(j); + if (_breakpoints[i]->_lines.getSize() == 0) { + delete _breakpoints[i]; + _breakpoints.removeAt(i); + } + // refresh changes + refreshScriptBreakpoints(); + + return STATUS_OK; + } + } + break; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + for (int i = 0; i < _scripts.getSize(); i++) { + refreshScriptBreakpoints(_scripts[i]); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::refreshScriptBreakpoints(CScScript *script) { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + if (!script || !script->_filename) return STATUS_FAILED; + + for (int i = 0; i < _breakpoints.getSize(); i++) { + if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { + script->_breakpoints.copy(_breakpoints[i]->_lines); + return STATUS_OK; + } + } + if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::saveBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + + char text[512]; + char key[100]; + + int count = 0; + for (int i = 0; i < _breakpoints.getSize(); i++) { + for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { + count++; + sprintf(key, "Breakpoint%d", count); + sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); + + _gameRef->_registry->writeString("Debug", key, text); + } + } + _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CScEngine::loadBreakpoints() { + if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + + char key[100]; + + int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + for (int i = 1; i <= count; i++) { + /* uint32 BufSize = 512; */ + sprintf(key, "Breakpoint%d", i); + AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + + char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + + if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + delete[] path; + delete[] line; + path = NULL; + line = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) return; + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::enableProfiling() { + if (_isProfiling) return; + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = CBPlatform::getTime(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::disableProfiling() { + if (!_isProfiling) return; + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); tit++) { + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h new file mode 100644 index 0000000000..81dc13a73c --- /dev/null +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -0,0 +1,147 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/wme_debugger.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" + +namespace WinterMute { + +#define MAX_CACHED_SCRIPTS 20 +class CScScript; +class CScValue; +class CBObject; +class CBScriptHolder; +class CScEngine : public CBBase { +public: + class CScCachedScript { + public: + CScCachedScript(const char *filename, byte *buffer, uint32 size) { + _timestamp = CBPlatform::getTime(); + _buffer = new byte[size]; + if (_buffer) memcpy(_buffer, buffer, size); + _size = size; + _filename = filename; + }; + + ~CScCachedScript() { + if (_buffer) delete [] _buffer; + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *filename) { + _filename = filename; + } + + ~CScBreakpoint() { + _lines.removeAll(); + } + + Common::String _filename; + CBArray _lines; + }; + + + + +public: + bool dbgSendScripts(IWmeDebugClient *client); + + CBArray _breakpoints; + bool addBreakpoint(const char *scriptFilename, int line); + bool removeBreakpoint(const char *scriptFilename, int line); + bool refreshScriptBreakpoints(); + bool refreshScriptBreakpoints(CScScript *script); + bool saveBreakpoints(); + bool loadBreakpoints(); + + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(CScScript *script); + + CScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(CBObject *Object); + bool resetScript(CScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(CScEngine, CBBase) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + CScValue *_globals; + CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + CScEngine(CBGame *inGame); + virtual ~CScEngine(); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); + + CBArray _scripts; + + void enableProfiling(); + void disableProfiling(); + bool getIsProfiling() { + return _isProfiling; + } + + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp new file mode 100644 index 0000000000..a1b8249cb1 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -0,0 +1,238 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXArray, false) + +CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { + return new CSXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); + + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) _length = stack->pop()->getInt(0); + else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { + _length = 0; + _values = new CScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +CSXArray::~CSXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXArray::scToString() { + static char dummy[32768]; // TODO: Get rid of static. + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + CScValue *val = _values->getProp(propName); + if (val) { + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); + } + } + + if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + } + return dummy; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Push") == 0) { + int numParams = stack->pop()->getInt(0); + char paramName[20]; + + for (int i = 0; i < numParams; i++) { + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); + } + stack->pushInt(_length); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Pop") == 0) { + + stack->correctParams(0); + + if (_length > 0) { + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); + _length--; + } else stack->pushNULL(); + + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXArray::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char ParamName[20]; + if (validNumber(name, ParamName)) { + return _values->getProp(ParamName); + } else return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length") == 0) { + int OrigLength = _length; + _length = MAX(value->getInt(0), 0); + + char PropName[20]; + if (_length < OrigLength) { + for (int i = _length; i < OrigLength; i++) { + sprintf(PropName, "%d", i); + _values->deleteProp(PropName); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + int Index = atoi(paramName); + if (Index >= _length) _length = Index + 1; + return _values->setProp(paramName, value); + } else return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::persist(CBPersistMgr *persistMgr) { + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::validNumber(const char *origStr, char *outStr) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else return false; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXArray::push(CScValue *val) { + char paramName[20]; + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h new file mode 100644 index 0000000000..b873416572 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -0,0 +1,54 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXArray : public CBScriptable { +public: + bool push(CScValue *Val); + bool validNumber(const char *origStr, char *outStr); + DECLARE_PERSISTENT(CSXArray, CBScriptable) + CSXArray(CBGame *inGame, CScStack *stack); + CSXArray(CBGame *inGame); + virtual ~CSXArray(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + int _length; + CScValue *_values; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp new file mode 100644 index 0000000000..211c0d34f0 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -0,0 +1,297 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_date.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXDate, false) + +CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { + return new CSXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + CScValue *valYear = stack->pop(); + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { + g_system->getTimeAndDate(_tm); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXDate::~CSXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXDate::scToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); +#if 0 + return asctime(&_tm); +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetYear") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMonth") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDate") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHours") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMinutes") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_min); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSeconds") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWeekday") == 0) { + stack->correctParams(0); + warning("GetWeekday returns a wrong value on purpose"); + stack->pushInt(_tm.tm_mday % 7); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetYear") == 0) { + stack->correctParams(1); + _tm.tm_year = stack->pop()->getInt() - 1900; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMonth") == 0) { + stack->correctParams(1); + _tm.tm_mon = stack->pop()->getInt() - 1; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDate") == 0) { + stack->correctParams(1); + _tm.tm_mday = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHours") == 0) { + stack->correctParams(1); + _tm.tm_hour = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMinutes") == 0) { + stack->correctParams(1); + _tm.tm_min = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSeconds") == 0) { + stack->correctParams(1); + _tm.tm_sec = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->correctParams(0); + g_system->getTimeAndDate(_tm); + stack->pushNULL(); + return STATUS_OK; + } + + else + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXDate::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int CSXDate::scCompare(CBScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((CSXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h new file mode 100644 index 0000000000..82f6af1f1d --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -0,0 +1,55 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + +#include "common/system.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXDate : public CBScriptable { +public: + int scCompare(CBScriptable *Value); + DECLARE_PERSISTENT(CSXDate, CBScriptable) + CSXDate(CBGame *inGame, CScStack *Stack); + virtual ~CSXDate(); + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + char *_string; + TimeDate _tm; +private: + Common::String _strRep; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp new file mode 100644 index 0000000000..58c0416b43 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -0,0 +1,779 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/system/sys_class.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_ext_file.h" + +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXFile, false) + +CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { + return new CSXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + CScValue *Val = stack->pop(); + + _filename = NULL; + if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +CSXFile::~CSXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void CSXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void CSXFile::close() { + if (_readFile) { + _gameRef->_fileManager->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXFile::scToString() { + if (_filename) return _filename; + else return "[file object]"; +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + CBUtils::setString(&_filename, filename); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->correctParams(1); + close(); + _mode = stack->pop()->getInt(1); + if (_mode < 1 || _mode > 3) { + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); + _mode = 1; + } + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) { + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + if (strcmp(name, "OpenAsText") == 0) { + if (_mode == 2) _writeFile = openForWrite(_filename, false); + else _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) _writeFile = openForWrite(_filename, true); + else _writeFile = openForAppend(_filename, true); + } + + if (!_writeFile) { + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + close(); + } else _textMode = strcmp(name, "OpenAsText") == 0; + } + + if (_readFile || _writeFile) stack->pushBool(true); + else stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + close(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPosition") == 0) { + stack->correctParams(1); + if (_mode == 0) { + script->runtimeError("File.%s: File is not open", name); + stack->pushBool(false); + } else { + int Pos = stack->pop()->getInt(); + stack->pushBool(setPos(Pos)); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(0); + close(); + stack->pushBool(CBPlatform::deleteFile(_filename) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Copy") == 0) { + stack->correctParams(2); + const char *Dest = stack->pop()->getString(); + bool Overwrite = stack->pop()->getBool(true); + + close(); + stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadLine") == 0) { + stack->correctParams(0); + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + bool foundNewLine = false; + bool ret = STATUS_FAILED; + do { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + buf[counter] = '\0'; + foundNewLine = true; + break; + } else if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } while (DID_SUCCEED(ret)); + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (!foundNewLine && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadText") == 0) { + stack->correctParams(1); + int textLen = stack->pop()->getInt(); + + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + + bool ret = STATUS_FAILED; + while (counter < (uint32)textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) break; + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) continue; + else { + buf[counter] = b; + counter++; + } + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (textLen > 0 && counter == 0) stack->pushNULL(); + else stack->pushString((char *)buf); + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->correctParams(1); + const char *line = stack->pop()->getString(); + if (!_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in text mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadBool") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadByte") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadShort") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadFloat") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + float val; + (*(uint32*)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); + else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadString") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); + } + delete [] str; + } else stack->pushNULL(); + } else stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteByte") == 0) { + stack->correctParams(1); + byte val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteShort") == 0) { + stack->correctParams(1); + int16 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint16LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->correctParams(1); + int32 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint32LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteFloat") == 0) { + stack->correctParams(1); + float val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + uint32 *ptr = (uint32*)&val; + _writeFile->writeUint32LE(*ptr); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); + stack->correctParams(1); + double val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteString") == 0) { + stack->correctParams(1); + const char *val = stack->pop()->getString(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + + uint32 size = strlen(val); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); + + stack->pushBool(true); + + return STATUS_OK; + } + + + else return CBScriptable::scCallMethod(script, stack, thisStack, name); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXFile::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Position") == 0) { + _scValue->setInt(getPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(getLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextMode") == 0) { + _scValue->setBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccessMode") == 0) { + _scValue->setInt(_mode); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getPos() { + if (_mode == 1 && _readFile) + return _readFile->pos(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) + return _readFile->seek(pos, whence); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } + else return false; +} + +////////////////////////////////////////////////////////////////////////// +uint32 CSXFile::getLength() { + if (_mode == 1 && _readFile) + return _readFile->size(); + else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("CSXFile - reading length for WriteFile not supported"); + return 0; +/* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXFile::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->_saving) { + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); + } else { + persistMgr->transfer(TMEMBER(pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = _gameRef->_fileManager->openFile(_filename); + if (!_readFile) + close(); + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) + _writeFile = openForWrite(_filename, false); + else + _writeFile = openForAppend(_filename, false); + } else { + if (_mode == 2) + _writeFile = openForWrite(_filename, true); + else + _writeFile = openForAppend(_filename, true); + } + if (_writeFile) + close(); + } + setPos(pos); + } + } + + return STATUS_OK; +} + +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h new file mode 100644 index 0000000000..5a6811fe57 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/base/base_scriptable.h" +#include "common/stream.h" + +namespace WinterMute { + +class CBFile; + +class CSXFile : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXFile, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXFile(CBGame *inGame, CScStack *Stack); + virtual ~CSXFile(); +private: + Common::SeekableReadStream *_readFile; + Common::WriteStream *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void close(); + void cleanup(); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 Pos, int whence = SEEK_SET); + char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp new file mode 100644 index 0000000000..22b08087b7 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -0,0 +1,295 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/persistent.h" +#include "common/math.h" +#include + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(CSXMath, true) + +CBScriptable *makeSXMath(CBGame *inGame) { + return new CSXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +CSXMath::~CSXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Abs") == 0) { + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Acos") == 0) { + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Asin") == 0) { + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan") == 0) { + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan2") == 0) { + stack->correctParams(2); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); + stack->pushFloat(atan2(y, x)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ceil") == 0) { + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cos") == 0) { + stack->correctParams(1); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cosh") == 0) { + stack->correctParams(1); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exp") == 0) { + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Floor") == 0) { + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log") == 0) { + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log10") == 0) { + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pow") == 0) { + stack->correctParams(2); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); + + stack->pushFloat(pow(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sin") == 0) { + stack->correctParams(1); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sinh") == 0) { + stack->correctParams(1); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tan") == 0) { + stack->correctParams(1); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tanh") == 0) { + stack->correctParams(1); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sqrt") == 0) { + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DegToRad") == 0) { + stack->correctParams(1); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RadToDeg") == 0) { + stack->correctParams(1); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMath::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PI") == 0) { + _scValue->setFloat(M_PI); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double CSXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMath::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h new file mode 100644 index 0000000000..422521233f --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -0,0 +1,53 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXMath : public CBScriptable { +public: + DECLARE_PERSISTENT(CSXMath, CBScriptable) + CSXMath(CBGame *inGame); + virtual ~CSXMath(); + virtual CScValue *scGetProperty(const char *name); + virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + +private: + double degreeToRadian(double value); + double radianToDegree(double value); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp new file mode 100644 index 0000000000..df2bf188ff --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -0,0 +1,508 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" +#include "common/file.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXMemBuffer, false) + +CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { + return new CSXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int NewSize = stack->pop()->getInt(); + resize(MAX(0, NewSize)); +} + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { + _size = 0; + _buffer = Buffer; +} + + +////////////////////////////////////////////////////////////////////////// +CSXMemBuffer::~CSXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *CSXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void CSXMemBuffer::cleanup() { + if (_size) free(_buffer); + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::resize(int newSize) { + int oldSize = _size; + + if (_size == 0) { + _buffer = malloc(newSize); + if (_buffer) _size = newSize; + } else { + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; + } else return STATUS_FAILED; + } else { + _buffer = newBuf; + _size = newSize; + } + } + + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { + if (_buffer == NULL) { + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) + return true; + + if (start < 0 || length == 0 || start + length > _size) { + script->runtimeError("Set/Get method call is out of bounds"); + return false; + } else + return true; +} + +////////////////////////////////////////////////////////////////////////// +const char *CSXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSize") == 0) { + stack->correctParams(1); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (DID_SUCCEED(resize(newSize))) + stack->pushBool(true); + else + stack->pushBool(false); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBool") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) + stack->pushNULL(); + else + stack->pushBool(*(bool *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetByte") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) + stack->pushNULL(); + else + stack->pushInt(*(byte *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetShort") == 0) { + stack->correctParams(1); + int Start = stack->pop()->getInt(); + if (!checkBounds(script, Start, sizeof(short))) + stack->pushNULL(); + else + stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) + stack->pushNULL(); + else + stack->pushInt(*(int *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFloat") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) + stack->pushNULL(); + else + stack->pushFloat(*(float *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDouble") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) + stack->pushNULL(); + else + stack->pushFloat(*(double *)((byte *)_buffer + start)); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); + + // find end of string + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + length = i - start; + break; + } + } + } + + if (!checkBounds(script, start, length)) + stack->pushNULL(); + else { + char *str = new char[length + 1]; + strncpy(str, (const char *)_buffer + start, length); + str[length] = '\0'; + stack->pushString(str); + delete [] str; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPointer") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) + stack->pushNULL(); + else { + void *pointer = *(void **)((byte *)_buffer + start); + CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + stack->pushNative(buf, false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBool") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); + + if (!checkBounds(script, start, sizeof(bool))) + stack->pushBool(false); + else { + *(bool *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetByte") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(byte))) + stack->pushBool(false); + else { + *(byte *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetShort") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(short))) + stack->pushBool(false); + else { + *(short *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(int))) + stack->pushBool(false); + else { + *(int *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFloat") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(float))) + stack->pushBool(false); + else { + *(float *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDouble") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(double))) + stack->pushBool(false); + else { + *(double *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); + + if (!checkBounds(script, start, strlen(val) + 1)) + stack->pushBool(false); + else { + memcpy((byte *)_buffer + start, val, strlen(val) + 1); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPointer") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + /* CScValue *Val = */ stack->pop(); + + if (!checkBounds(script, start, sizeof(void *))) + stack->pushBool(false); + else { + /* + int Pointer = (int)Val->getMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + stack->pushBool(true); + */ + // TODO fix + stack->pushBool(false); + + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->correctParams(0); + if (_buffer && _size) { + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); + } + stack->pushNULL(); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXMemBuffer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Size") == 0) { + _scValue->setInt(_size); + return _scValue; + } + + else return CBScriptable::scGetProperty(name); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if(strcmp(name, "Length")==0){ + int OrigLength = _length; + _length = max(value->getInt(0), 0); + + char PropName[20]; + if(_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return CBScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->_saving) { + if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + } else { + if (_size > 0) { + _buffer = malloc(_size); + persistMgr->getBytes((byte *)_buffer, _size); + } else _buffer = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXMemBuffer::scCompare(CBScriptable *val) { + if (_buffer == val->scToMemBuffer()) return 0; + else return 1; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h new file mode 100644 index 0000000000..a9d78e50e4 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXMemBuffer : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + const char *scToString(); + CSXMemBuffer(CBGame *inGame, CScStack *stack); + CSXMemBuffer(CBGame *inGame, void *buffer); + virtual ~CSXMemBuffer(); + virtual void *scToMemBuffer(); + int _size; +private: + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(CScScript *script, int start, int length); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp new file mode 100644 index 0000000000..cb0d32d1a3 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -0,0 +1,67 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_object.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CSXObject, false) + +CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { + return new CSXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { + addScript(stack->pop()->getString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +CSXObject::~CSXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXObject::persist(CBPersistMgr *persistMgr) { + CBObject::persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h new file mode 100644 index 0000000000..b4e869d5b3 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -0,0 +1,47 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/base/base_object.h" + +namespace WinterMute { + +class CSXObject : public CBObject { +public: + DECLARE_PERSISTENT(CSXObject, CBObject) + CSXObject(CBGame *inGame, CScStack *Stack); + virtual ~CSXObject(); + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp new file mode 100644 index 0000000000..bd7541fadd --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -0,0 +1,404 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/script_ext_string.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" +#include "engines/wintermute/utils/string_util.h" +#include "common/tokenizer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CSXString, false) + +CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { + return new CSXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + CScValue *val = stack->pop(); + + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + setStringVal(val->getString()); + } + + if (_capacity == 0) setStringVal(""); +} + + +////////////////////////////////////////////////////////////////////////// +CSXString::~CSXString() { + if (_string) delete [] _string; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *CSXString::scToString() { + if (_string) return _string; + else return "[null string]"; +} + + +////////////////////////////////////////////////////////////////////////// +void CSXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Substring") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); + + if (end < start) CBUtils::swap(&start, &end); + + //try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + // } catch (std::exception &) { + // stack->pushNULL(); + // } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Substr") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + + CScValue *val = stack->pop(); + int len = val->getInt(); + + if (!val->isNULL() && len <= 0) { + stack->pushString(""); + return STATUS_OK; + } + + if (val->isNULL()) len = strlen(_string) - start; + +// try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); +// } catch (std::exception &) { +// stack->pushNULL(); +// } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToUpperCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toUppercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToLowerCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + str.toLowercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + else + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IndexOf") == 0) { + stack->correctParams(2); + + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString toFind; + if (_gameRef->_textEncoding == TEXT_UTF8) + toFind = StringUtil::utf8ToWide(strToFind); + else + toFind = StringUtil::ansiToWide(strToFind); + + int indexOf = StringUtil::indexOf(str, toFind, index); + stack->pushInt(indexOf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Split") == 0) { + stack->correctParams(1); + CScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) strcpy(separators, val->getString()); + + CSXArray *array = new CSXArray(_gameRef); + if (!array) { + stack->pushNULL(); + return STATUS_OK; + } + + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) + str = StringUtil::utf8ToWide(_string); + else + str = StringUtil::ansiToWide(_string); + + WideString delims; + if (_gameRef->_textEncoding == TEXT_UTF8) + delims = StringUtil::utf8ToWide(separators); + else + delims = StringUtil::ansiToWide(separators); + + Common::Array parts; + + + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size());*/ + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (_gameRef->_textEncoding == TEXT_UTF8) + val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + else + val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CSXString::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(_string); + _scValue->setInt(wstr.size()); + } else + _scValue->setInt(strlen(_string)); + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Capacity") == 0) { + _scValue->setInt(_capacity); + return _scValue; + } + + else return _scValue; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::scSetProperty(const char *name, CScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Capacity") == 0) { + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); + else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); + delete[] _string; + _string = newStr; + _capacity = newCap; + } + } + return STATUS_OK; + } + + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CSXString::persist(CBPersistMgr *persistMgr) { + + CBScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->_saving) { + if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + persistMgr->getBytes((byte *)_string, _capacity); + } else _string = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int CSXString::scCompare(CBScriptable *val) { + return strcmp(_string, ((CSXString *)val)->_string); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h new file mode 100644 index 0000000000..52a1524dde --- /dev/null +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -0,0 +1,58 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +class CSXString : public CBScriptable { +public: + virtual int scCompare(CBScriptable *Val); + DECLARE_PERSISTENT(CSXString, CBScriptable) + CScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, CScValue *value); + bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + void scSetString(const char *val); + const char *scToString(); + void setStringVal(const char *val); + + CSXString(CBGame *inGame, CScStack *Stack); + virtual ~CSXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp new file mode 100644 index 0000000000..188cb2d15c --- /dev/null +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -0,0 +1,226 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_game.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CScStack, false) + +////////////////////////////////////////////////////////////////////////// +CScStack::CScStack(CBGame *inGame): CBBase(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +CScStack::~CScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); +#endif + + for (int i = 0; i < _values.getSize(); i++) { + delete _values[i]; + } + _values.removeAll(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::push(CScValue *val) { + _sP++; + + if (_sP < _values.getSize()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + CScValue *copyVal = new CScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getPushValue() { + _sP++; + + if (_sP >= _values.getSize()) { + CScValue *val = new CScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getTop() { + if (_sP < 0 || _sP >= _values.getSize()) return NULL; + else return _values[_sP]; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= _values.getSize()) return NULL; + else return _values[index]; +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.removeAt(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + CScValue *nullVal = new CScValue(_gameRef); + nullVal->setNULL(); + _values.insertAt(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if (_values.getSize() > _sP + 1) { + delete _values[_values.getSize() - 1]; + _values.removeAt(_values.getSize() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNULL() { + /* + CScValue* val = new CScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushInt(int val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushFloat(double val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushBool(bool val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushString(const char *val) { + /* + CScValue* val = new CScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void CScStack::pushNative(CBScriptable *val, bool persistent) { + /* + CScValue* val = new CScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScStack::persist(CBPersistMgr *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_sP)); + _values.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h new file mode 100644 index 0000000000..6460f901fe --- /dev/null +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -0,0 +1,66 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace WinterMute { + +class CScValue; +class CBScriptable; + +class CScStack : public CBBase { +public: + CScValue *getAt(int Index); + CScValue *getPushValue(); + DECLARE_PERSISTENT(CScStack, CBBase) + void pushNative(CBScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); + void pushNULL(); + void correctParams(uint32 expectedParams); + CScValue *getTop(); + void push(CScValue *val); + CScValue *pop(); + CScStack(CBGame *inGame); + virtual ~CScStack(); + CBArray _values; + int _sP; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp new file mode 100644 index 0000000000..da47ed299f --- /dev/null +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -0,0 +1,1054 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(CScValue, false) + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame): CBBase(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::cleanup(bool ignoreNatives) { + deleteProps(); + + if (_valString) delete [] _valString; + + if (!ignoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +CScValue::~CScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +CScValue *CScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { + _gameRef->_scValue->_type = VAL_INT; + +#if 0 // TODO: Remove FreeType-dependency + if (_gameRef->_textEncoding == TEXT_ANSI) { +#else + if (true) { +#endif + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + CScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + + if (ret == NULL) { + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) ret = _valIter->_value; + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) + return _valRef->setProp(name, val); + + bool ret = STATUS_FAILED; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scSetProperty(name, val); + } + + if (DID_FAIL(ret)) { + CScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) + newVal = new CScValue(_gameRef); + else newVal->cleanup(); + + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; + + if (_type != VAL_NATIVE) _type = VAL_OBJECT; + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + CScValue* val = new CScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) + return _valRef->propExists(name); + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(CScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNULL(); + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isNative(); + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isString(); + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isFloat(); + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isInt() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isInt(); + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isBool() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isBool(); + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::isObject() { + if (_type == VAL_VARIABLE_REF) + return _valRef->isObject(); + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getType(); + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setBool(bool val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setBool(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetBool(val); + return; + } + + _valBool = val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setInt(int val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setInt(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetInt(val); + return; + } + + _valInt = val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setFloat(double val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setFloat(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetFloat(val); + return; + } + + _valFloat = val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setString(const char *val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setString(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetString(val); + return; + } + + setStringVal(val); + if (_valString) _type = VAL_STRING; + else _type = VAL_NULL; +} + +void CScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void CScValue::setStringVal(const char *val) { + if (_valString) { + delete [] _valString; + _valString = NULL; + } + + if (val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(val) + 1]; + if (_valString) { + strcpy(_valString, val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) delete _valNative; + } + _valNative = NULL; + deleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setNative(CBScriptable *val, bool persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNative(val, persistent); + return; + } + + if (val == NULL) { + setNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != val) delete _valNative; + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = persistent; + + _valNative = val; + if (_valNative && !_persistent) _valNative->_refCount++; + } +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setReference(CScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getBool(); + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->scToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::getInt(int defaultVal) { + if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->scToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +double CScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) + return _valRef->getFloat(); + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->scToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return defaultVal; + } +} + +////////////////////////////////////////////////////////////////////////// +void *CScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getMemBuffer(); + + if (_type == VAL_NATIVE) + return _valNative->scToMemBuffer(); + else return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::getString() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getString(); + + switch (_type) { + case VAL_OBJECT: + setStringVal("[object]"); + break; + + case VAL_NULL: + setStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; + break; + } + + case VAL_BOOL: + setStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + setStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + setStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + setStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +CBScriptable *CScValue::getNative() { + if (_type == VAL_VARIABLE_REF) + return _valRef->getNative(); + + if (_type == VAL_NATIVE) return _valNative; + else return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +TValType CScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::copy(CScValue *orig, bool copyWhole) { + _gameRef = orig->_gameRef; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) delete _valNative; + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + + cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + setStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) _valNative->_refCount++; +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void CScValue::setValue(CScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { + case VAL_INT: + _valNative->scSetInt(val->getInt()); + break; + case VAL_FLOAT: + _valNative->scSetFloat(val->getFloat()); + break; + case VAL_BOOL: + _valNative->scSetBool(val->getBool()); + break; + case VAL_STRING: + _valNative->scSetString(val->getString()); + break; + default: + warning("CScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else copy(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::persist(CBPersistMgr *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (persistMgr->_saving) { + size = _valObject.size(); + persistMgr->transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); + + _valIter++; + } + } else { + CScValue *val; + persistMgr->transfer("", &size); + for (int i = 0; i < size; i++) { + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); + + _valObject[str] = val; + delete [] str; + } + } + + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); + + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int CScValue::compare(CScValue *val1, CScValue *val2) { + // both natives? + if (val1->isNative() && val2->isNative()) { + // same class? + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else return strcmp(val1->getString(), val2->getString()); + } + + // both objects? + if (val1->isObject() && val2->isObject()) return -1; + + + // null states + if (val1->isNULL() && !val2->isNULL()) return -1; + else if (!val1->isNULL() && val2->isNULL()) return 1; + else if (val1->isNULL() && val2->isNULL()) return 0; + + // one of them is string? convert both to string + if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + + // one of them is float? + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) return -1; + else if (val1->getFloat() > val2->getFloat()) return 1; + else return 0; + } + + // otherwise compare as int's + if (val1->getInt() < val2->getInt()) return -1; + else if (val1->getInt() > val2->getInt()) return 1; + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::compareStrict(CScValue *val1, CScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; + else return CScValue::compare(val1, val2); +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, int value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, const char *value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, double value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName, bool value) { + CScValue *val = new CScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool CScValue::setProperty(const char *propName) { + CScValue *val = new CScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugProp +////////////////////////////////////////////////////////////////////////// +EWmeDebuggerPropType CScValue::dbgGetType() { + switch (getType()) { + case VAL_NULL: + return WME_DBGPROP_NULL; + case VAL_STRING: + return WME_DBGPROP_STRING; + case VAL_INT: + return WME_DBGPROP_INT; + case VAL_BOOL: + return WME_DBGPROP_BOOL; + case VAL_FLOAT: + return WME_DBGPROP_FLOAT; + case VAL_OBJECT: + return WME_DBGPROP_OBJECT; + case VAL_NATIVE: + return WME_DBGPROP_NATIVE; + default: + return WME_DBGPROP_UNKNOWN; + } +} + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetValInt() { + return getInt(); +} + +////////////////////////////////////////////////////////////////////////// +double CScValue::dbgGetValFloat() { + return getFloat(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetValBool() { + return getBool(); +} + +////////////////////////////////////////////////////////////////////////// +const char *CScValue::dbgGetValString() { + return getString(); +} + +////////////////////////////////////////////////////////////////////////// +IWmeDebugObject *CScValue::dbgGetValNative() { + return getNative(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(int value) { + setInt(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(double value) { + setFloat(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(bool value) { + setBool(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal(const char *value) { + setString(value); + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgSetVal() { + setNULL(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +int CScValue::dbgGetNumProperties() { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetNumProperties(); + else return _valObject.size(); +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { + if (_valNative && _valNative->_scProp) + return _valNative->_scProp->dbgGetProperty(index, name, value); + else { + int count = 0; + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (count == index) { + *name = _valIter->_key.c_str(); + *value = _valIter->_value; + return true; + } + _valIter++; + count++; + } + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CScValue::dbgGetDescription(char *buf, int bufSize) { + if (_type == VAL_VARIABLE_REF) + return _valRef->dbgGetDescription(buf, bufSize); + + if (_type == VAL_NATIVE) { + _valNative->scDebuggerDesc(buf, bufSize); + } else { + strncpy(buf, getString(), bufSize); + } + return true; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h new file mode 100644 index 0000000000..eaee3ed773 --- /dev/null +++ b/engines/wintermute/base/scriptables/script_value.h @@ -0,0 +1,141 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/wme_debugger.h" +#include "common/str.h" + +namespace WinterMute { + +class CScScript; +class CBScriptable; + +class CScValue : public CBBase, public IWmeDebugProp { +public: + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + + static int compare(CScValue *val1, CScValue *val2); + static int compareStrict(CScValue *val1, CScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(CScValue, CBBase) + + bool _isConstVar; + bool saveAsText(CBDynBuffer *buffer, int indent); + void setValue(CScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(CScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); + const char *getString(); + void *getMemBuffer(); + CBScriptable *getNative(); + bool deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(CBScriptable *val, bool persistent = false); + void setObject(); + void setReference(CScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); + CScValue *getProp(const char *name); + CBScriptable *_valNative; + CScValue *_valRef; +protected: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + CScValue(CBGame *inGame); + CScValue(CBGame *inGame, bool Val); + CScValue(CBGame *inGame, int Val); + CScValue(CBGame *inGame, double Val); + CScValue(CBGame *inGame, const char *Val); + virtual ~CScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); + + +// IWmeDebugProp interface implementation +public: + virtual EWmeDebuggerPropType dbgGetType(); + + // getters + virtual int dbgGetValInt(); + virtual double dbgGetValFloat(); + virtual bool dbgGetValBool(); + virtual const char *dbgGetValString(); + virtual IWmeDebugObject *dbgGetValNative(); + + // setters + virtual bool dbgSetVal(int value); + virtual bool dbgSetVal(double value); + virtual bool dbgSetVal(bool value); + virtual bool dbgSetVal(const char *value); + virtual bool dbgSetVal(); + + // properties + virtual int dbgGetNumProperties(); + virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); + + virtual bool dbgGetDescription(char *buf, int bufSize); +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp new file mode 100644 index 0000000000..e1819e3c65 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -0,0 +1,288 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" + +namespace WinterMute { + +IMPLEMENT_PERSISTENT(CBSound, false) + +////////////////////////////////////////////////////////////////////////// +CBSound::CBSound(CBGame *inGame): CBBase(inGame) { + _sound = NULL; + _soundFilename = NULL; + + _soundType = Audio::Mixer::kSFXSoundType; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + + +////////////////////////////////////////////////////////////////////////// +CBSound::~CBSound() { + if (_sound) _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + + delete[] _soundFilename; + _soundFilename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + delete[] _soundFilename; + _soundFilename = NULL; + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = new char[strlen(filename) + 1]; + strcpy(_soundFilename, filename); + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setSoundSimple() { + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) _sound->setPosition(_soundPosition); + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) return _sound->resume(); + else return STATUS_OK; + } else return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getLength() { + if (_sound) return _sound->getLength(); + else return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) _sound->_freezePaused = true; + return _sound->pause(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::persist(CBPersistMgr *persistMgr) { + if (persistMgr->_saving && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) + _soundPosition = _sound->getPosition(); + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->_saving) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::isPaused() { + return _sound && _soundPaused; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPositionTime(uint32 time) { + if (!_sound) return STATUS_FAILED; + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) + _soundPosition = 0; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSound::getPositionTime() { + if (!_sound) return 0; + + if (!_sound->isPlaying()) + return 0; + else return _sound->getPosition(); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolumePercent(int percent) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(percent * 255 / 100); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->setPrivateVolume(volume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPrivateVolume(int volume) { + if (!_sound) + return STATUS_FAILED; + else return _sound->_privateVolume = volume; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolumePercent() { + if (!_sound) + return 0; + else return _sound->_privateVolume * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +int CBSound::getVolume() { + if (!_sound) + return 0; + else return _sound->_privateVolume; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setLoopStart(uint32 pos) { + if (!_sound) + return STATUS_FAILED; + else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSound::setPan(float pan) { + if (_sound) + return _sound->setPan(pan); + else return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { + if (!_sound) + return STATUS_OK; + + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + bool ret = _sound->applyFX(type, param1, param2, param3, param4); + + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; + + return ret; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h new file mode 100644 index 0000000000..ef52194090 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound.h @@ -0,0 +1,88 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUND_H +#define WINTERMUTE_BSOUND_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "audio/mixer.h" + +namespace WinterMute { + +class CBSoundBuffer; +class CBSound : public CBBase { +public: + bool setPan(float pan); + int _soundPrivateVolume; + int getVolume(); + int getVolumePercent(); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); + uint32 getPositionTime(); + bool setPositionTime(uint32 time); + bool _soundPaused; + bool _soundFreezePaused; + bool isPlaying(); + bool isPaused(); + bool _soundPlaying; + bool _soundLooping; + uint32 _soundLoopStart; + uint32 _soundPosition; + DECLARE_PERSISTENT(CBSound, CBBase) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + char *_soundFilename; + bool setSoundSimple(); + bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + CBSound(CBGame *inGame); + virtual ~CBSound(); + + bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); + +private: + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + CBSoundBuffer *_sound; + +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp new file mode 100644 index 0000000000..a868f99823 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -0,0 +1,383 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" +#include "common/system.h" +#include "common/substream.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = NULL; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer::~CBSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; + + delete[] _filename; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { + _streamed = Streamed; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { + warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +#if 0 + if (_stream) { + BASS_StreamFree(_stream); + _stream = NULL; + } +#endif + + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = _gameRef->_fileManager->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + Common::String strFilename(filename); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); + } else if (strFilename.hasSuffix(".wav")) { + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + } + } + } else { + warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + } + if (!_stream) { + return STATUS_FAILED; + } + CBUtils::setString(&_filename, filename); + + return STATUS_OK; +#if 0 + BASS_FILEPROCS fileProc; + fileProc.close = CBSoundBuffer::FileCloseProc; + fileProc.read = CBSoundBuffer::FileReadProc; + fileProc.seek = CBSoundBuffer::FileSeekProc; + fileProc.length = CBSoundBuffer::FileLenProc; + + _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); + if (!_stream) { + _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); + return STATUS_FAILED; + } + + CBUtils::setString(&_filename, filename); + + /* + bool res; + bool NewlyCreated = false; + + if(!_soundBuffer || ForceReload || _streamed){ + if(!_file) _file = _gameRef->_fileManager->openFile(filename); + if(!_file){ + _gameRef->LOG(0, "Error opening sound file '%s'", filename); + return STATUS_FAILED; + } + // switch to streamed for big files + if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + } + + // create buffer + if(!_soundBuffer){ + NewlyCreated = true; + + res = InitializeBuffer(_file); + if(DID_FAIL(res)){ + _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); + return res; + } + } + + + + // store filename + if(!_filename){ + _filename = new char[strlen(filename)+1]; + strcpy(_filename, filename); + } + + // close file (if not streaming) + if(!_streamed && _file){ + _gameRef->_fileManager->closeFile(_file); + _file = NULL; + } + */ + + return STATUS_OK; +#endif +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::play(bool looping, uint32 startSample) { + if (startSample != 0) { + warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); + } + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; + if (looping) { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setLooping(bool looping) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + _looping = looping; +#if 0 + + + if (_stream) { + BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); + } +#endif +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::resume() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setVolume(int volume) { + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; + if (_stream && _handle) { + byte vol = (byte)(_volume); + g_system->getMixer()->setChannelVolume(*_handle, vol); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 CBSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPosition(uint32 pos) { + warning("CBSoundBuffer::SetPosition - not implemented yet"); +#if 0 + if (_stream) { + QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); + BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); + } +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; +#if 0 + if (_stream) { + if (_sync) { + BASS_ChannelRemoveSync(_stream, _sync); + _sync = NULL; + } + if (_loopStart > 0) { + QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + } + } +#endif + return STATUS_OK; +} +#if 0 +////////////////////////////////////////////////////////////////////////// +void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + CBSoundBuffer *soundBuf = static_cast(user); + QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); + + if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) + BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); +} +#endif +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("CBSoundBuffer::ApplyFX - not implemented yet"); + switch (type) { + case SFX_ECHO: + break; + + case SFX_REVERB: + break; + + default: + break; + } + return STATUS_OK; +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h new file mode 100644 index 0000000000..a491bd49ad --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -0,0 +1,100 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDBUFFER_H +#define WINTERMUTE_BSOUNDBUFFER_H + + +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace WinterMute { + +class CBFile; +class CBSoundBuffer : public CBBase { +public: + + CBSoundBuffer(CBGame *inGame); + virtual ~CBSoundBuffer(); + + + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); + bool isPlaying(); + + void setLooping(bool looping); + + uint32 getPosition(); + bool setPosition(uint32 pos); + uint32 getLength(); + + bool setLoopStart(uint32 pos); + uint32 getLoopStart() const { + return _loopStart; + } + + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); + void updateVolume(); + + void setType(Audio::Mixer::SoundType Type); + + bool loadFromFile(const char *filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + Common::SeekableReadStream *_file; + char *_filename; + bool _streamed; + + int _privateVolume; +private: + int _volume; +}; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp new file mode 100644 index 0000000000..c2174dea6a --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -0,0 +1,292 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" + +namespace WinterMute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(CBSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundMgr::~CBSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::cleanup() { + for (uint32 i = 0; i < _sounds.size(); i++) + delete _sounds[i]; + _sounds.clear(); +#if 0 + BASS_Free(); +#endif + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void CBSoundMgr::saveSettings() { + if (_soundAvailable) { + _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _soundAvailable = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::initLoop() { + if (!_soundAvailable) + return STATUS_OK; +#if 0 + + BASS_Update(500); +#endif + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { + if (!_soundAvailable) + return NULL; + + CBSoundBuffer *sound; + + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (_gameRef->_fileManager->hasFile(newFile)) { + filename = newFile.c_str(); + } + } + + sound = new CBSoundBuffer(_gameRef); + if (!sound) return NULL; + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(filename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", filename); + delete sound; + return NULL; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { + if (!sound) + return STATUS_FAILED; + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i] == sound) { + delete _sounds[i]; + _sounds.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { + if (!_soundAvailable) + return STATUS_OK; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); + break; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); + break; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); + break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); + } + g_wintermute->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { + int volume = 0; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); + break; + default: + error("Sound-type not set"); + break; + } + + return (byte)(volume * 100 / 255); +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (uint32 i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte CBSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::pauseAll(bool includingMusic) { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + _sounds[i]->pause(); + _sounds[i]->_freezePaused = true; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool CBSoundMgr::resumeAll() { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float CBSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)_gameRef->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h new file mode 100644 index 0000000000..2c05bbfcb8 --- /dev/null +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -0,0 +1,69 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BSOUNDMGR_H +#define WINTERMUTE_BSOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace WinterMute { +class CBSoundBuffer; +class CBSoundMgr : public CBBase { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + byte getMasterVolumePercent(); + byte getMasterVolume(); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); + byte getVolumePercent(Audio::Mixer::SoundType type); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); + uint32 _volumeOriginal; + int _volumeMaster; + bool removeSound(CBSoundBuffer *sound); + CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initLoop(); + bool initialize(); + bool _soundAvailable; + CBSoundMgr(CBGame *inGame); + virtual ~CBSoundMgr(); + Common::Array _sounds; + void saveSettings(); +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 6e780b04dccdff3f09a760d4bc492a896418f486 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 19:37:05 +0200 Subject: WINTERMUTE: Fix a few Upper_case filenames that got missed in the last commit. --- engines/wintermute/base/base_debugger.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/base_point.cpp | 2 +- engines/wintermute/base/base_region.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp index f56f08dab2..8adeea2b1f 100644 --- a/engines/wintermute/base/base_debugger.cpp +++ b/engines/wintermute/base/base_debugger.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/base_debugger.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 712f64eb6f..b34e89e41a 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" #include "common/util.h" diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index d5e9c99dcf..00c852e02d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_Fader.h" +#include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/font/base_font_storage.h" diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 12ab07912b..711eebfc98 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -#include "engines/wintermute/base/base_Debugger.h" +#include "engines/wintermute/base/base_debugger.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 6887349a7a..e878f34387 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 5de1fb9eef..0c35d99bd9 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_BREGION_H #define WINTERMUTE_BREGION_H -#include "engines/wintermute/base/base_Point.h" +#include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" namespace WinterMute { diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 11ebafd329..b3b05b6e65 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/math/Matrix4.h" +#include "engines/wintermute/math/matrix4.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/base_game.h" -- cgit v1.2.3 From b5a07fef8ebf29f7f44b15d9b34799c7e115fdad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 21:01:47 +0200 Subject: WINTERMUTE: Get rid of the C-prefix for class-definitions. --- engines/wintermute/base/base.cpp | 16 +- engines/wintermute/base/base.h | 18 +- engines/wintermute/base/base_active_rect.cpp | 22 +- engines/wintermute/base/base_active_rect.h | 22 +- engines/wintermute/base/base_debugger.cpp | 66 +-- engines/wintermute/base/base_debugger.h | 34 +- engines/wintermute/base/base_dynamic_buffer.cpp | 34 +- engines/wintermute/base/base_dynamic_buffer.h | 6 +- engines/wintermute/base/base_fader.cpp | 28 +- engines/wintermute/base/base_fader.h | 8 +- engines/wintermute/base/base_file_manager.cpp | 78 ++-- engines/wintermute/base/base_file_manager.h | 16 +- engines/wintermute/base/base_frame.cpp | 70 +-- engines/wintermute/base/base_frame.h | 36 +- engines/wintermute/base/base_game.cpp | 468 ++++++++++----------- engines/wintermute/base/base_game.h | 138 +++--- engines/wintermute/base/base_keyboard_state.cpp | 42 +- engines/wintermute/base/base_keyboard_state.h | 14 +- engines/wintermute/base/base_named_object.cpp | 10 +- engines/wintermute/base/base_named_object.h | 10 +- engines/wintermute/base/base_object.cpp | 94 ++--- engines/wintermute/base/base_object.h | 40 +- engines/wintermute/base/base_parser.cpp | 26 +- engines/wintermute/base/base_parser.h | 8 +- .../wintermute/base/base_persistence_manager.cpp | 86 ++-- engines/wintermute/base/base_persistence_manager.h | 6 +- engines/wintermute/base/base_point.cpp | 10 +- engines/wintermute/base/base_point.h | 10 +- engines/wintermute/base/base_quick_msg.cpp | 6 +- engines/wintermute/base/base_quick_msg.h | 6 +- engines/wintermute/base/base_region.cpp | 66 +-- engines/wintermute/base/base_region.h | 20 +- engines/wintermute/base/base_registry.cpp | 34 +- engines/wintermute/base/base_registry.h | 6 +- engines/wintermute/base/base_save_thumb_helper.cpp | 10 +- engines/wintermute/base/base_save_thumb_helper.h | 12 +- engines/wintermute/base/base_script_holder.cpp | 70 +-- engines/wintermute/base/base_script_holder.h | 24 +- engines/wintermute/base/base_scriptable.cpp | 50 +-- engines/wintermute/base/base_scriptable.h | 44 +- engines/wintermute/base/base_sprite.cpp | 92 ++-- engines/wintermute/base/base_sprite.h | 32 +- engines/wintermute/base/base_string_table.cpp | 22 +- engines/wintermute/base/base_string_table.h | 6 +- engines/wintermute/base/base_sub_frame.cpp | 68 +-- engines/wintermute/base/base_sub_frame.h | 26 +- engines/wintermute/base/base_surface_storage.cpp | 34 +- engines/wintermute/base/base_surface_storage.h | 16 +- .../wintermute/base/base_transition_manager.cpp | 18 +- engines/wintermute/base/base_transition_manager.h | 6 +- engines/wintermute/base/base_viewport.cpp | 20 +- engines/wintermute/base/base_viewport.h | 12 +- engines/wintermute/base/file/BPkgFile.cpp | 7 +- engines/wintermute/base/file/BPkgFile.h | 4 +- engines/wintermute/base/file/base_disk_file.cpp | 2 +- engines/wintermute/base/file/base_disk_file.h | 2 +- engines/wintermute/base/file/base_file.cpp | 8 +- engines/wintermute/base/file/base_file.h | 6 +- engines/wintermute/base/file/base_file_entry.cpp | 4 +- engines/wintermute/base/file/base_file_entry.h | 10 +- engines/wintermute/base/file/base_package.cpp | 14 +- engines/wintermute/base/file/base_package.h | 6 +- engines/wintermute/base/file/base_resources.cpp | 2 +- engines/wintermute/base/file/base_resources.h | 2 +- .../wintermute/base/file/base_save_thumb_file.cpp | 14 +- .../wintermute/base/file/base_save_thumb_file.h | 6 +- engines/wintermute/base/font/base_font.cpp | 36 +- engines/wintermute/base/font/base_font.h | 12 +- engines/wintermute/base/font/base_font_bitmap.cpp | 44 +- engines/wintermute/base/font/base_font_bitmap.h | 14 +- engines/wintermute/base/font/base_font_storage.cpp | 20 +- engines/wintermute/base/font/base_font_storage.h | 16 +- .../wintermute/base/font/base_font_truetype.cpp | 78 ++-- engines/wintermute/base/font/base_font_truetype.h | 30 +- engines/wintermute/base/gfx/base_image.cpp | 20 +- engines/wintermute/base/gfx/base_image.h | 10 +- engines/wintermute/base/gfx/base_renderer.cpp | 54 +-- engines/wintermute/base/gfx/base_renderer.h | 24 +- engines/wintermute/base/gfx/base_surface.cpp | 34 +- engines/wintermute/base/gfx/base_surface.h | 6 +- .../base/gfx/osystem/base_render_osystem.cpp | 78 ++-- .../base/gfx/osystem/base_render_osystem.h | 20 +- .../base/gfx/osystem/base_surface_osystem.cpp | 72 ++-- .../base/gfx/osystem/base_surface_osystem.h | 8 +- engines/wintermute/base/particles/part_emitter.cpp | 112 ++--- engines/wintermute/base/particles/part_emitter.h | 34 +- engines/wintermute/base/particles/part_force.cpp | 6 +- engines/wintermute/base/particles/part_force.h | 8 +- .../wintermute/base/particles/part_particle.cpp | 42 +- engines/wintermute/base/particles/part_particle.h | 20 +- engines/wintermute/base/scriptables/script.cpp | 158 +++---- engines/wintermute/base/scriptables/script.h | 62 +-- .../wintermute/base/scriptables/script_engine.cpp | 110 ++--- .../wintermute/base/scriptables/script_engine.h | 38 +- .../base/scriptables/script_ext_array.cpp | 34 +- .../wintermute/base/scriptables/script_ext_array.h | 20 +- .../base/scriptables/script_ext_date.cpp | 28 +- .../wintermute/base/scriptables/script_ext_date.h | 16 +- .../base/scriptables/script_ext_file.cpp | 56 +-- .../wintermute/base/scriptables/script_ext_file.h | 16 +- .../base/scriptables/script_ext_math.cpp | 22 +- .../wintermute/base/scriptables/script_ext_math.h | 12 +- .../base/scriptables/script_ext_mem_buffer.cpp | 42 +- .../base/scriptables/script_ext_mem_buffer.h | 20 +- .../base/scriptables/script_ext_object.cpp | 14 +- .../base/scriptables/script_ext_object.h | 8 +- .../base/scriptables/script_ext_string.cpp | 44 +- .../base/scriptables/script_ext_string.h | 16 +- .../wintermute/base/scriptables/script_stack.cpp | 50 +-- engines/wintermute/base/scriptables/script_stack.h | 26 +- .../wintermute/base/scriptables/script_value.cpp | 158 +++---- engines/wintermute/base/scriptables/script_value.h | 50 +-- engines/wintermute/base/sound/base_sound.cpp | 46 +- engines/wintermute/base/sound/base_sound.h | 12 +- .../wintermute/base/sound/base_sound_buffer.cpp | 62 +-- engines/wintermute/base/sound/base_sound_buffer.h | 8 +- .../wintermute/base/sound/base_sound_manager.cpp | 44 +- engines/wintermute/base/sound/base_sound_manager.h | 18 +- 118 files changed, 2097 insertions(+), 2094 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 5fabe94312..4b62a7553a 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -35,27 +35,27 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBBase::CBBase(CBGame *gameOwner) { +BaseClass::BaseClass(BaseGame *gameOwner) { _gameRef = gameOwner; _persistable = true; } ////////////////////////////////////////////////////////////////////////// -CBBase::CBBase() { +BaseClass::BaseClass() { _gameRef = NULL; _persistable = true; } ////////////////////////////////////////////////////////////////////// -CBBase::~CBBase() { +BaseClass::~BaseClass() { _editorProps.clear(); } ////////////////////////////////////////////////////////////////////////// -const char *CBBase::getEditorProp(const char *propName, const char *initVal) { +const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { _editorPropsIter = _editorProps.find(propName); if (_editorPropsIter != _editorProps.end()) return _editorPropsIter->_value.c_str(); @@ -65,7 +65,7 @@ const char *CBBase::getEditorProp(const char *propName, const char *initVal) { ////////////////////////////////////////////////////////////////////////// -bool CBBase::setEditorProp(const char *propName, const char *propValue) { +bool BaseClass::setEditorProp(const char *propName, const char *propValue) { if (propName == NULL) return STATUS_FAILED; if (propValue == NULL) { @@ -84,7 +84,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBBase::parseEditorProperty(byte *buffer, bool complete) { +bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(EDITOR_PROPERTY) TOKEN_TABLE(NAME) @@ -98,7 +98,7 @@ bool CBBase::parseEditorProperty(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { @@ -159,7 +159,7 @@ bool CBBase::parseEditorProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -bool CBBase::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { _editorPropsIter = _editorProps.begin(); while (_editorPropsIter != _editorProps.end()) { buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index e8c87f1f9e..0265ce97d5 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -37,21 +37,21 @@ namespace WinterMute { -class CBGame; -class CBDynBuffer; +class BaseGame; +class BaseDynamicBuffer; -class CBBase { +class BaseClass { public: bool _persistable; bool setEditorProp(const char *propName, const char *propValue); const char *getEditorProp(const char *propName, const char *initVal = NULL); - CBBase(TDynamicConstructor, TDynamicConstructor) {}; + BaseClass(TDynamicConstructor, TDynamicConstructor) {}; bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(CBDynBuffer *buffer, int indent = 0); - CBBase(); - CBGame *_gameRef; - CBBase(CBGame *GameOwner); - virtual ~CBBase(); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + BaseClass(); + BaseGame *_gameRef; + BaseClass(BaseGame *GameOwner); + virtual ~BaseClass(); Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 5895b1acd5..493b35bf12 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -35,8 +35,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); +BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); _owner = NULL; _frame = NULL; _region = NULL; @@ -48,10 +48,10 @@ CBActiveRect::CBActiveRect(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): CBBase(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): BaseClass(inGame) { _owner = owner; _frame = frame; - CBPlatform::setRect(&_rect, x, y, x + width, y + height); + BasePlatform::setRect(&_rect, x, y, x + width, y + height); _zoomX = zoomX; _zoomY = zoomY; _precise = precise; @@ -61,11 +61,11 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBSubFrame *frame, i } ////////////////////////////////////////////////////////////////////// -CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY): CBBase(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY): BaseClass(inGame) { _owner = owner; _region = region; - CBPlatform::copyRect(&_rect, ®ion->_rect); - CBPlatform::offsetRect(&_rect, -offsetX, -offsetY); + BasePlatform::copyRect(&_rect, ®ion->_rect); + BasePlatform::offsetRect(&_rect, -offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; @@ -77,7 +77,7 @@ CBActiveRect::CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, in ////////////////////////////////////////////////////////////////////// -CBActiveRect::~CBActiveRect() { +BaseActiveRect::~BaseActiveRect() { _owner = NULL; _frame = NULL; _region = NULL; @@ -85,11 +85,11 @@ CBActiveRect::~CBActiveRect() { ////////////////////////////////////////////////////////////////////////// -void CBActiveRect::clipRect() { +void BaseActiveRect::clipRect() { Rect32 rc; bool customViewport; _gameRef->getCurrentViewportRect(&rc, &customViewport); - CBRenderer *Rend = _gameRef->_renderer; + BaseRenderer *Rend = _gameRef->_renderer; if (!customViewport) { rc.left -= Rend->_drawOffsetX; @@ -101,7 +101,7 @@ void CBActiveRect::clipRect() { if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; - CBPlatform::intersectRect(&_rect, &_rect, &rc); + BasePlatform::intersectRect(&_rect, &_rect, &rc); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 7c9e8d4a39..0885b0e13e 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -33,25 +33,25 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CBRegion; -class CBSubFrame; -class CBObject; -class CBActiveRect: CBBase { +class BaseRegion; +class BaseSubFrame; +class BaseObject; +class BaseActiveRect: BaseClass { public: void clipRect(); bool _precise; float _zoomX; float _zoomY; - CBSubFrame *_frame; - CBObject *_owner; - CBRegion *_region; + BaseSubFrame *_frame; + BaseObject *_owner; + BaseRegion *_region; int _offsetX; int _offsetY; Rect32 _rect; - CBActiveRect(CBGame *inGameOwner = NULL); - CBActiveRect(CBGame *inGameOwner, CBObject *owner, CBSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - CBActiveRect(CBGame *inGame, CBObject *owner, CBRegion *region, int offsetX, int offsetY); - virtual ~CBActiveRect(); + BaseActiveRect(BaseGame *inGameOwner = NULL); + BaseActiveRect(BaseGame *inGameOwner, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY); + virtual ~BaseActiveRect(); }; diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp index 8adeea2b1f..ef4f1ce686 100644 --- a/engines/wintermute/base/base_debugger.cpp +++ b/engines/wintermute/base/base_debugger.cpp @@ -31,172 +31,172 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBDebugger::CBDebugger(CBGame *inGame) : CBBase(inGame) { +BaseDebugger::BaseDebugger(BaseGame *inGame) : BaseClass(inGame) { _enabled = false; } ////////////////////////////////////////////////////////////////////////// -CBDebugger::~CBDebugger(void) { +BaseDebugger::~BaseDebugger(void) { } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::initialize() { +bool BaseDebugger::initialize() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::shutdown() { +bool BaseDebugger::shutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameInit() { +bool BaseDebugger::onGameInit() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameShutdown() { +bool BaseDebugger::onGameShutdown() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onGameTick() { +bool BaseDebugger::onGameTick() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onLog(unsigned int errorCode, const char *text) { +bool BaseDebugger::onLog(unsigned int errorCode, const char *text) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptInit(CScScript *script) { +bool BaseDebugger::onScriptInit(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool BaseDebugger::onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name) { +bool BaseDebugger::onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdown(CScScript *script) { +bool BaseDebugger::onScriptShutdown(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeLine(CScScript *script, int Line) { +bool BaseDebugger::onScriptChangeLine(ScScript *script, int Line) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptChangeScope(CScScript *script, CScValue *scope) { +bool BaseDebugger::onScriptChangeScope(ScScript *script, ScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptShutdownScope(CScScript *script, CScValue *scope) { +bool BaseDebugger::onScriptShutdownScope(ScScript *script, ScValue *scope) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName) { +bool BaseDebugger::onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onVariableChangeValue(CScValue *var, CScValue *value) { +bool BaseDebugger::onVariableChangeValue(ScValue *var, ScValue *value) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::onScriptHitBreakpoint(CScScript *script) { +bool BaseDebugger::onScriptHitBreakpoint(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// // IWmeDebugServer interface implementation -bool CBDebugger::attachClient(IWmeDebugClient *client) { +bool BaseDebugger::attachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::detachClient(IWmeDebugClient *client) { +bool BaseDebugger::detachClient(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::queryData(IWmeDebugClient *client) { +bool BaseDebugger::queryData(IWmeDebugClient *client) { return false; } ////////////////////////////////////////////////////////////////////////// -int CBDebugger::getPropInt(const char *propName) { +int BaseDebugger::getPropInt(const char *propName) { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBDebugger::getPropFloat(const char *propName) { +double BaseDebugger::getPropFloat(const char *propName) { return 0.0; } ////////////////////////////////////////////////////////////////////////// -const char *CBDebugger::getPropString(const char *propName) { +const char *BaseDebugger::getPropString(const char *propName) { return ""; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::getPropBool(const char *propName) { +bool BaseDebugger::getPropBool(const char *propName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, int propValue) { +bool BaseDebugger::setProp(const char *propName, int propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, double propValue) { +bool BaseDebugger::setProp(const char *propName, double propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, const char *propValue) { +bool BaseDebugger::setProp(const char *propName, const char *propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::setProp(const char *propName, bool propValue) { +bool BaseDebugger::setProp(const char *propName, bool propValue) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { +bool BaseDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::addBreakpoint(const char *scriptFilename, int line) { +bool BaseDebugger::addBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::removeBreakpoint(const char *scriptFilename, int line) { +bool BaseDebugger::removeBreakpoint(const char *scriptFilename, int line) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBDebugger::continueExecution() { +bool BaseDebugger::continueExecution() { return false; } diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h index 35ea56eafe..7266e073d8 100644 --- a/engines/wintermute/base/base_debugger.h +++ b/engines/wintermute/base/base_debugger.h @@ -36,12 +36,12 @@ // TODO: The entire debugger should possibly be removed namespace WinterMute { -class CScScript; -class CScValue; -class CBDebugger : public CBBase, public IWmeDebugServer { +class ScScript; +class ScValue; +class BaseDebugger : public BaseClass, public IWmeDebugServer { public: - CBDebugger(CBGame *inGame); - virtual ~CBDebugger(void); + BaseDebugger(BaseGame *inGame); + virtual ~BaseDebugger(void); // initialization bool _enabled; @@ -53,18 +53,18 @@ public: bool onGameShutdown(); bool onGameTick(); bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(CScScript *script); - bool onScriptEventThreadInit(CScScript *script, CScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(CScScript *script, CScScript *parentScript, const char *name); - - bool onScriptShutdown(CScScript *script); - bool onScriptChangeLine(CScScript *script, int line); - bool onScriptChangeScope(CScScript *script, CScValue *scope); - bool onScriptShutdownScope(CScScript *script, CScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, CScScript *script, CScValue *scope, CScValue *var, const char *variableName); - bool onVariableChangeValue(CScValue *var, CScValue *value); - - bool onScriptHitBreakpoint(CScScript *script); + bool onScriptInit(ScScript *script); + bool onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name); + bool onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name); + + bool onScriptShutdown(ScScript *script); + bool onScriptChangeLine(ScScript *script, int line); + bool onScriptChangeScope(ScScript *script, ScValue *scope); + bool onScriptShutdownScope(ScScript *script, ScValue *scope); + bool onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName); + bool onVariableChangeValue(ScValue *var, ScValue *value); + + bool onScriptHitBreakpoint(ScScript *script); // IWmeDebugServer interface virtual bool attachClient(IWmeDebugClient *client); diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 7453838219..8d6f88c9fe 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy): BaseClass(inGame) { _buffer = NULL; _size = 0; _realSize = 0; @@ -46,13 +46,13 @@ CBDynBuffer::CBDynBuffer(CBGame *inGame, uint32 initSize, uint32 growBy): CBBase ////////////////////////////////////////////////////////////////////////// -CBDynBuffer::~CBDynBuffer() { +BaseDynamicBuffer::~BaseDynamicBuffer() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::cleanup() { +void BaseDynamicBuffer::cleanup() { if (_buffer) free(_buffer); _buffer = NULL; _size = 0; @@ -63,20 +63,20 @@ void CBDynBuffer::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getSize() { +uint32 BaseDynamicBuffer::getSize() { return _size; } ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::init(uint32 initSize) { +bool BaseDynamicBuffer::init(uint32 initSize) { cleanup(); if (initSize == 0) initSize = _initSize; _buffer = (byte *)malloc(initSize); if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::Init - Error allocating %d bytes", initSize); + _gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); return STATUS_FAILED; } @@ -88,14 +88,14 @@ bool CBDynBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { if (!_initialized) init(); while (_offset + size > _realSize) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { - _gameRef->LOG(0, "CBDynBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + _gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return STATUS_FAILED; } } @@ -109,11 +109,11 @@ bool CBDynBuffer::putBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { if (!_initialized) init(); if (_offset + size > _size) { - _gameRef->LOG(0, "CBDynBuffer::GetBytes - Buffer underflow"); + _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); return STATUS_FAILED; } @@ -125,13 +125,13 @@ bool CBDynBuffer::getBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putDWORD(uint32 val) { +void BaseDynamicBuffer::putDWORD(uint32 val) { putBytes((byte *)&val, sizeof(uint32)); } ////////////////////////////////////////////////////////////////////////// -uint32 CBDynBuffer::getDWORD() { +uint32 BaseDynamicBuffer::getDWORD() { uint32 ret; getBytes((byte *)&ret, sizeof(uint32)); return ret; @@ -139,7 +139,7 @@ uint32 CBDynBuffer::getDWORD() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putString(const char *val) { +void BaseDynamicBuffer::putString(const char *val) { if (!val) putString("(null)"); else { putDWORD(strlen(val) + 1); @@ -149,7 +149,7 @@ void CBDynBuffer::putString(const char *val) { ////////////////////////////////////////////////////////////////////////// -char *CBDynBuffer::getString() { +char *BaseDynamicBuffer::getString() { uint32 len = getDWORD(); char *ret = (char *)(_buffer + _offset); _offset += len; @@ -160,7 +160,7 @@ char *CBDynBuffer::getString() { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putText(const char *fmt, ...) { +void BaseDynamicBuffer::putText(const char *fmt, ...) { va_list va; va_start(va, fmt); @@ -171,7 +171,7 @@ void CBDynBuffer::putText(const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { +void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { va_list va; putText("%*s", indent, ""); @@ -183,7 +183,7 @@ void CBDynBuffer::putTextIndent(int indent, const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBDynBuffer::putTextForm(const char *format, va_list argptr) { +void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { char buff[32768]; vsprintf(buff, format, argptr); putBytes((byte *)buff, strlen(buff)); diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 5795fe5bd1..0567f874df 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBDynBuffer : public CBBase { +class BaseDynamicBuffer : public BaseClass { public: bool _initialized; void putText(const char *fmt, ...); @@ -50,8 +50,8 @@ public: void cleanup(); uint32 _size; byte *_buffer; - CBDynBuffer(CBGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~CBDynBuffer(); + BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~BaseDynamicBuffer(); private: uint32 _realSize; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index b34e89e41a..4dcdf82347 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -38,10 +38,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFader, false) +IMPLEMENT_PERSISTENT(BaseFader, false) ////////////////////////////////////////////////////////////////////////// -CBFader::CBFader(CBGame *inGame): CBObject(inGame) { +BaseFader::BaseFader(BaseGame *inGame): BaseObject(inGame) { _active = false; _red = _green = _blue = 0; _currentAlpha = 0x00; @@ -54,20 +54,20 @@ CBFader::CBFader(CBGame *inGame): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CBFader::~CBFader() { +BaseFader::~BaseFader() { } ////////////////////////////////////////////////////////////////////////// -bool CBFader::update() { +bool BaseFader::update() { if (!_active) return STATUS_OK; int alphaDelta = _targetAlpha - _sourceAlpha; uint32 time; - if (_system) time = CBPlatform::getTime() - _startTime; + if (_system) time = BasePlatform::getTime() - _startTime; else time = _gameRef->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; @@ -84,7 +84,7 @@ bool CBFader::update() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::display() { +bool BaseFader::display() { if (!_active) return STATUS_OK; if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); @@ -93,7 +93,7 @@ bool CBFader::display() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::deactivate() { +bool BaseFader::deactivate() { _active = false; _ready = true; return STATUS_OK; @@ -101,7 +101,7 @@ bool CBFader::deactivate() { ////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { +bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -115,7 +115,7 @@ bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::getTime(); + if (_system) _startTime = BasePlatform::getTime(); else _startTime = _gameRef->_timer; return STATUS_OK; @@ -123,7 +123,7 @@ bool CBFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { ////////////////////////////////////////////////////////////////////////// -bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { +bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _ready = false; _active = true; @@ -138,7 +138,7 @@ bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = CBPlatform::getTime(); + if (_system) _startTime = BasePlatform::getTime(); else _startTime = _gameRef->_timer; @@ -147,15 +147,15 @@ bool CBFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { ////////////////////////////////////////////////////////////////////////// -uint32 CBFader::getCurrentColor() { +uint32 BaseFader::getCurrentColor() { return BYTETORGBA(_red, _green, _blue, _currentAlpha); } ////////////////////////////////////////////////////////////////////////// -bool CBFader::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool BaseFader::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_blue)); diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 679f5d0903..36dd8a1d53 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBFader : public CBObject { +class BaseFader : public BaseObject { public: bool _system; uint32 getCurrentColor(); @@ -43,9 +43,9 @@ public: bool deactivate(); bool display(); bool update(); - DECLARE_PERSISTENT(CBFader, CBObject) - CBFader(CBGame *inGame); - virtual ~CBFader(); + DECLARE_PERSISTENT(BaseFader, BaseObject) + BaseFader(BaseGame *inGame); + virtual ~BaseFader(); bool _active; byte _red; byte _green; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1cb0464a1f..a2c81b8a8c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -58,7 +58,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { +BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { _basePath = NULL; initPaths(); @@ -67,13 +67,13 @@ CBFileManager::CBFileManager(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBFileManager::~CBFileManager() { +BaseFileManager::~BaseFileManager() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::cleanup() { +bool BaseFileManager::cleanup() { // delete registered paths for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; @@ -114,7 +114,7 @@ bool CBFileManager::cleanup() { #define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// -byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { +byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; Common::SeekableReadStream *file = openFile(filename); @@ -153,14 +153,14 @@ byte *CBFileManager::readWholeFile(const Common::String &filename, uint32 *size, return buffer; } -Common::SeekableReadStream *CBFileManager::loadSaveGame(const Common::String &filename) { +Common::SeekableReadStream *BaseFileManager::loadSaveGame(const Common::String &filename) { Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); Common::InSaveFile *file = saveMan->openForLoading(filename); return file; } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { +bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { // TODO warning("Implement SaveFile"); @@ -173,7 +173,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 #if 0 RestoreCurrentDir(); - CBUtils::CreatePath(filename, false); + BaseUtils::CreatePath(filename, false); FILE *f = fopen(filename, "wb"); if (!f) { @@ -223,7 +223,7 @@ bool CBFileManager::saveFile(const Common::String &filename, byte *buffer, uint3 ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { +bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (uint32 i = 0; i < _packages.size(); i++) { if (_packages[i]->_cD > 0) _packages[i]->close(); @@ -235,7 +235,7 @@ bool CBFileManager::requestCD(int cd, char *packageFile, const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::addPath(TPathType type, const Common::String &path) { +bool BaseFileManager::addPath(TPathType type, const Common::String &path) { if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); @@ -245,7 +245,7 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { strcpy(buffer, path.c_str()); if (!slashed) strcat(buffer, "\\"); - //CBPlatform::strlwr(buffer); + //BasePlatform::strlwr(buffer); switch (type) { case PATH_SINGLE: @@ -260,7 +260,7 @@ bool CBFileManager::addPath(TPathType type, const Common::String &path) { } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::reloadPaths() { +bool BaseFileManager::reloadPaths() { // delete registered paths for (uint32 i = 0; i < _singlePaths.size(); i++) delete [] _singlePaths[i]; @@ -276,7 +276,7 @@ bool CBFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::initPaths() { +bool BaseFileManager::initPaths() { restoreCurrentDir(); AnsiString pathList; @@ -284,10 +284,10 @@ bool CBFileManager::initPaths() { // single files paths pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_SINGLE, path); } @@ -301,10 +301,10 @@ bool CBFileManager::initPaths() { addPath(PATH_PACKAGE, "./"); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = CBUtils::strNumEntries(pathList.c_str(), ';'); + numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); for (int i = 0; i < numPaths; i++) { - char *path = CBUtils::strEntry(i, pathList.c_str(), ';'); + char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { addPath(PATH_PACKAGE, path); } @@ -318,7 +318,7 @@ bool CBFileManager::initPaths() { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackages() { +bool BaseFileManager::registerPackages() { restoreCurrentDir(); _gameRef->LOG(0, "Scanning packages..."); @@ -365,7 +365,7 @@ bool CBFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { // FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); @@ -411,7 +411,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } for (uint32 i = 0; i < hdr.NumDirs; i++) { - CBPackage *pkg = new CBPackage(_gameRef); + BasePackage *pkg = new BasePackage(_gameRef); if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; @@ -450,7 +450,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search name[nameLength - 1] = '\0'; - CBPlatform::strupr(name); + BasePlatform::strupr(name); offset = package->readUint32LE(); offset += absoluteOffset; @@ -464,7 +464,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } _filesIter = _files.find(name); if (_filesIter == _files.end()) { - CBFileEntry *file = new CBFileEntry(_gameRef); + BaseFileEntry *file = new BaseFileEntry(_gameRef); file->_package = pkg; file->_offset = offset; file->_length = length; @@ -492,7 +492,7 @@ bool CBFileManager::registerPackage(const Common::String &filename , bool search } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::isValidPackage(const AnsiString &fileName) const { +bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); // check for device-type specific packages @@ -503,7 +503,7 @@ bool CBFileManager::isValidPackage(const AnsiString &fileName) const { } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openPackage(const Common::String &name) { +Common::File *BaseFileManager::openPackage(const Common::String &name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? //RestoreCurrentDir(); @@ -524,14 +524,14 @@ Common::File *CBFileManager::openPackage(const Common::String &name) { if (ret->isOpen()) { return ret; } - warning("CBFileManager::OpenPackage - Couldn't load file %s", name.c_str()); + warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; } ////////////////////////////////////////////////////////////////////////// -Common::File *CBFileManager::openSingleFile(const Common::String &name) { +Common::File *BaseFileManager::openSingleFile(const Common::String &name) { restoreCurrentDir(); Common::File *ret = NULL; @@ -556,7 +556,7 @@ Common::File *CBFileManager::openSingleFile(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) { +bool BaseFileManager::getFullPath(const Common::String &filename, char *fullname) { restoreCurrentDir(); Common::File f; @@ -586,12 +586,12 @@ bool CBFileManager::getFullPath(const Common::String &filename, char *fullname) ////////////////////////////////////////////////////////////////////////// -CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { +BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { char *upc_name = new char[strlen(filename.c_str()) + 1]; strcpy(upc_name, filename.c_str()); - CBPlatform::strupr(upc_name); + BasePlatform::strupr(upc_name); - CBFileEntry *ret = NULL; + BaseFileEntry *ret = NULL; _filesIter = _files.find(upc_name); if (_filesIter != _files.end()) ret = _filesIter->_value; @@ -600,7 +600,7 @@ CBFileEntry *CBFileManager::getPackageEntry(const Common::String &filename) { return ret; } -bool CBFileManager::hasFile(const Common::String &filename) { +bool BaseFileManager::hasFile(const Common::String &filename) { //TODO: Do this in a much simpler fashion Common::SeekableReadStream *stream = openFile(filename, true, false); if (!stream) { @@ -611,7 +611,7 @@ bool CBFileManager::hasFile(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { +Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { if (strcmp(filename.c_str(), "") == 0) return NULL; //_gameRef->LOG(0, "open file: %s", filename); /*#ifdef __WIN32__ @@ -631,7 +631,7 @@ Common::SeekableReadStream *CBFileManager::openFile(const Common::String &filena ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::closeFile(Common::SeekableReadStream *File) { +bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { for (uint32 i = 0; i < _openFiles.size(); i++) { if (_openFiles[i] == File) { delete _openFiles[i]; @@ -644,13 +644,13 @@ bool CBFileManager::closeFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &filename) { +Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { restoreCurrentDir(); Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - CBSaveThumbFile *SaveThumbFile = new CBSaveThumbFile(_gameRef); + BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); } @@ -666,7 +666,7 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ret = openPkgFile(filename, this); if (ret) return ret; - ret = CBResources::getFile(filename); + ret = BaseResources::getFile(filename); if (ret) return ret; warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); @@ -675,19 +675,19 @@ Common::SeekableReadStream *CBFileManager::openFileRaw(const Common::String &fil ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::restoreCurrentDir() { +bool BaseFileManager::restoreCurrentDir() { if (!_basePath) return STATUS_OK; else { /*if (!chdir(_basePath)) return STATUS_OK; else return STATUS_FAILED;*/ - warning("CBFileManager::RestoreCurrentDir - ignored"); + warning("BaseFileManager::RestoreCurrentDir - ignored"); return STATUS_OK; } } ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::setBasePath(const Common::String &path) { +bool BaseFileManager::setBasePath(const Common::String &path) { cleanup(); if (path.c_str()) { @@ -703,7 +703,7 @@ bool CBFileManager::setBasePath(const Common::String &path) { ////////////////////////////////////////////////////////////////////////// -bool CBFileManager::findPackageSignature(Common::File *f, uint32 *offset) { +bool BaseFileManager::findPackageSignature(Common::File *f, uint32 *offset) { byte buf[32768]; byte signature[8]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 1bf3156ebe..469108bee8 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -38,8 +38,8 @@ class File; } namespace WinterMute { -class CBFile; -class CBFileManager: CBBase { +class BaseFile; +class BaseFileManager: BaseClass { public: bool findPackageSignature(Common::File *f, uint32 *offset); bool cleanup(); @@ -51,7 +51,7 @@ public: bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - CBFileEntry *getPackageEntry(const Common::String &filename); + BaseFileEntry *getPackageEntry(const Common::String &filename); Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); bool registerPackages(); @@ -65,17 +65,17 @@ public: Common::SeekableReadStream *loadSaveGame(const Common::String &filename); bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - CBFileManager(CBGame *inGame = NULL); - virtual ~CBFileManager(); + BaseFileManager(BaseGame *inGame = NULL); + virtual ~BaseFileManager(); Common::Array _singlePaths; Common::Array _packagePaths; - Common::Array _packages; + Common::Array _packages; Common::Array _openFiles; - Common::HashMap _files; + Common::HashMap _files; private: bool registerPackage(const Common::String &filename, bool searchSignature = false); - Common::HashMap::iterator _filesIter; + Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; }; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 468ad29858..2a729a882a 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -42,10 +42,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBFrame, false) +IMPLEMENT_PERSISTENT(BaseFrame, false) ////////////////////////////////////////////////////////////////////// -CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { +BaseFrame::BaseFrame(BaseGame *inGame): BaseScriptable(inGame, true) { _delay = 0; _moveX = _moveY = 0; @@ -58,7 +58,7 @@ CBFrame::CBFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////// -CBFrame::~CBFrame() { +BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; @@ -75,7 +75,7 @@ CBFrame::~CBFrame() { ////////////////////////////////////////////////////////////////////// -bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { +bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { bool res; for (int i = 0; i < _subframes.getSize(); i++) { @@ -87,7 +87,7 @@ bool CBFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoo ////////////////////////////////////////////////////////////////////////// -bool CBFrame::oneTimeDisplay(CBObject *owner, bool muted) { +bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { if (_sound && !muted) { if (owner) owner->updateOneSound(_sound); _sound->play(); @@ -131,7 +131,7 @@ TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF(KILL_SOUND) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(DELAY) TOKEN_TABLE(IMAGE) @@ -158,7 +158,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; @@ -170,7 +170,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { bool decoration = false; bool mirrorX = false; bool mirrorY = false; - CBPlatform::setRectEmpty(&rect); + BasePlatform::setRectEmpty(&rect); char *surface_file = NULL; while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { @@ -237,7 +237,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_SUBFRAME: { - CBSubFrame *subframe = new CBSubFrame(_gameRef); + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; @@ -250,7 +250,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { delete _sound; _sound = NULL; } - _sound = new CBSound(_gameRef); + _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); delete _sound; @@ -290,7 +290,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (surface_file != NULL) { if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); @@ -305,7 +305,7 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); } - if (CBPlatform::isRectEmpty(&rect)) sub->setDefaultRect(); + if (BasePlatform::isRectEmpty(&rect)) sub->setDefaultRect(); else sub->_rect = rect; sub->_hotspotX = hotspotX; @@ -325,15 +325,15 @@ bool CBFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::setRectEmpty(rect); + BasePlatform::setRectEmpty(rect); Rect32 subRect; for (int i = 0; i < _subframes.getSize(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, rect, &subRect); + BasePlatform::unionRect(rect, rect, &subRect); } return true; } @@ -341,7 +341,7 @@ bool CBFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float sc ////////////////////////////////////////////////////////////////////////// -bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); @@ -369,7 +369,7 @@ bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); buffer->putTextIndent(indent, "}\n\n"); @@ -379,8 +379,8 @@ bool CBFrame::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CBFrame::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool BaseFrame::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); _applyEvent.persist(persistMgr); persistMgr->transfer(TMEMBER(_delay)); @@ -399,7 +399,7 @@ bool CBFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetSound @@ -417,12 +417,12 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "SetSound") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); delete _sound; _sound = NULL; if (!val->isNULL()) { - _sound = new CBSound(_gameRef); + _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { stack->pushBool(false); delete _sound; @@ -451,14 +451,14 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteSubframe") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { - CBSubFrame *sub = (CBSubFrame *)val->getNative(); + BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); for (int i = 0; i < _subframes.getSize(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; @@ -476,11 +476,11 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddSubframe") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); sub->setDefaultRect(); @@ -499,11 +499,11 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta int index = stack->pop()->getInt(); if (index < 0) index = 0; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); } @@ -565,14 +565,14 @@ bool CBFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } } ////////////////////////////////////////////////////////////////////////// -CScValue *CBFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); +ScValue *BaseFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new ScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -642,13 +642,13 @@ CScValue *CBFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } } ////////////////////////////////////////////////////////////////////////// -bool CBFrame::scSetProperty(const char *name, CScValue *value) { +bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// @@ -692,13 +692,13 @@ bool CBFrame::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// else { if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return CBScriptable::scSetProperty(name, value); + else return BaseScriptable::scSetProperty(name, value); } } ////////////////////////////////////////////////////////////////////////// -const char *CBFrame::scToString() { +const char *BaseFrame::scToString() { return "[frame]"; } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index f3dec4e16f..dcbf74bc47 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -33,37 +33,37 @@ #include "engines/wintermute/coll_templ.h" namespace WinterMute { -class CBSound; -class CBSubFrame; -class CBObject; -class CScScript; -class CScStack; -class CBFrame: public CBScriptable { +class BaseSound; +class BaseSubFrame; +class BaseObject; +class ScScript; +class ScStack; +class BaseFrame: public BaseScriptable { public: bool _killSound; bool _keyframe; - bool oneTimeDisplay(CBObject *owner, bool muted = false); - DECLARE_PERSISTENT(CBFrame, CBScriptable) - CBSound *_sound; + bool oneTimeDisplay(BaseObject *owner, bool muted = false); + DECLARE_PERSISTENT(BaseFrame, BaseScriptable) + BaseSound *_sound; bool _editorExpanded; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(CBDynBuffer *buffer, int indent); + bool saveAsText(BaseDynamicBuffer *buffer, int indent); int _moveY; int _moveX; uint32 _delay; - CBArray _subframes; - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + BaseArray _subframes; + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - CBFrame(CBGame *inGame); - virtual ~CBFrame(); + BaseFrame(BaseGame *inGame); + virtual ~BaseFrame(); - CBArray _applyEvent; + BaseArray _applyEvent; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 00c852e02d..0adc938895 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -74,11 +74,11 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBGame, true) +IMPLEMENT_PERSISTENT(BaseGame, true) ////////////////////////////////////////////////////////////////////// -CBGame::CBGame(): CBObject(this) { +BaseGame::BaseGame(): BaseObject(this) { _shuttingDown = false; _state = GAME_RUNNING; @@ -143,8 +143,8 @@ CBGame::CBGame(): CBObject(this) { _useD3D = false; - _registry = new CBRegistry(this); - _stringTable = new CBStringTable(this); + _registry = new BaseRegistry(this); + _stringTable = new BaseStringTable(this); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { _music[i] = NULL; @@ -205,7 +205,7 @@ CBGame::CBGame(): CBObject(this) { _indicatorHeight = 8; _richSavedGames = false; _savedGameExt = NULL; - CBUtils::setString(&_savedGameExt, "dsv"); + BaseUtils::setString(&_savedGameExt, "dsv"); _musicCrossfadeRunning = false; _musicCrossfadeStartTime = 0; @@ -222,7 +222,7 @@ CBGame::CBGame(): CBObject(this) { _loadImageX = _loadImageY = 0; _localSaveDir = NULL; - CBUtils::setString(&_localSaveDir, "saves"); + BaseUtils::setString(&_localSaveDir, "saves"); _saveDirChecked = false; _loadingIcon = NULL; @@ -238,7 +238,7 @@ CBGame::CBGame(): CBObject(this) { _lastCursor = NULL; - CBPlatform::setRectEmpty(&_mouseLockRect); + BasePlatform::setRectEmpty(&_mouseLockRect); _suppressScriptErrors = false; _lastMiniUpdate = 0; @@ -270,7 +270,7 @@ CBGame::CBGame(): CBObject(this) { ////////////////////////////////////////////////////////////////////// -CBGame::~CBGame() { +BaseGame::~BaseGame() { _shuttingDown = true; LOG(0, ""); @@ -330,12 +330,12 @@ CBGame::~CBGame() { _stringTable = NULL; DEBUG_DebugDisable(); - CBPlatform::outputDebugString("--- shutting down normally ---\n"); + BasePlatform::outputDebugString("--- shutting down normally ---\n"); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::cleanup() { +bool BaseGame::cleanup() { delete _loadingIcon; _loadingIcon = NULL; @@ -414,50 +414,50 @@ bool CBGame::cleanup() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize1() { +bool BaseGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { - _surfaceStorage = new CBSurfaceStorage(this); + _surfaceStorage = new BaseSurfaceStorage(this); if (_surfaceStorage == NULL) break; - _fontStorage = new CBFontStorage(this); + _fontStorage = new BaseFontStorage(this); if (_fontStorage == NULL) break; - _fileManager = new CBFileManager(this); + _fileManager = new BaseFileManager(this); if (_fileManager == NULL) break; - _soundMgr = new CBSoundMgr(this); + _soundMgr = new BaseSoundMgr(this); if (_soundMgr == NULL) break; - _debugMgr = new CBDebugger(this); + _debugMgr = new BaseDebugger(this); if (_debugMgr == NULL) break; - _mathClass = new CSXMath(this); + _mathClass = new SXMath(this); if (_mathClass == NULL) break; - _scEngine = new CScEngine(this); + _scEngine = new ScEngine(this); if (_scEngine == NULL) break; - _videoPlayer = new CVidPlayer(this); + _videoPlayer = new VideoPlayer(this); if (_videoPlayer == NULL) break; - _transMgr = new CBTransitionMgr(this); + _transMgr = new BaseTransitionMgr(this); if (_transMgr == NULL) break; - _keyboardState = new CBKeyboardState(this); + _keyboardState = new BaseKeyboardState(this); if (_keyboardState == NULL) break; - _fader = new CBFader(this); + _fader = new BaseFader(this); if (_fader == NULL) break; registerObject(_fader); @@ -483,7 +483,7 @@ bool CBGame::initialize1() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize2() { // we know whether we are going to be accelerated +bool BaseGame::initialize2() { // we know whether we are going to be accelerated _renderer = makeOSystemRenderer(this); if (_renderer == NULL) return STATUS_FAILED; @@ -492,7 +492,7 @@ bool CBGame::initialize2() { // we know whether we are going to be accelerated ////////////////////////////////////////////////////////////////////// -bool CBGame::initialize3() { // renderer is initialized +bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; @@ -505,7 +505,7 @@ bool CBGame::initialize3() { // renderer is initialized ////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugEnable(const char *filename) { +void BaseGame::DEBUG_DebugEnable(const char *filename) { _debugDebugMode = true; /* time_t timeNow; @@ -532,14 +532,14 @@ void CBGame::DEBUG_DebugEnable(const char *filename) { LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); - AnsiString platform = CBPlatform::getPlatformName(); + AnsiString platform = BasePlatform::getPlatformName(); LOG(0, "Platform: %s", platform.c_str()); LOG(0, ""); } ////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DebugDisable() { +void BaseGame::DEBUG_DebugDisable() { if (_debugLogFile != NULL) { LOG(0, "********** DEBUG LOG CLOSED ********************************************"); //fclose((FILE *)_debugLogFile); @@ -550,7 +550,7 @@ void CBGame::DEBUG_DebugDisable() { ////////////////////////////////////////////////////////////////////// -void CBGame::LOG(bool res, const char *fmt, ...) { +void BaseGame::LOG(bool res, const char *fmt, ...) { uint32 secs = g_system->getMillis() / 1000; uint32 hours = secs / 3600; secs = secs % 3600; @@ -580,17 +580,17 @@ void CBGame::LOG(bool res, const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -void CBGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { +void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { _engineLogCallback = callback; _engineLogCallbackData = data; } ////////////////////////////////////////////////////////////////////// -bool CBGame::initLoop() { +bool BaseGame::initLoop() { _viewportSP = -1; - _currentTime = CBPlatform::getTime(); + _currentTime = BasePlatform::getTime(); getDebugMgr()->onGameTick(); _renderer->initLoop(); @@ -645,35 +645,35 @@ bool CBGame::initLoop() { ////////////////////////////////////////////////////////////////////// -bool CBGame::initInput() { +bool BaseGame::initInput() { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CBGame::getSequence() { +int BaseGame::getSequence() { return ++_sequence; } ////////////////////////////////////////////////////////////////////////// -void CBGame::setOffset(int offsetX, int offsetY) { +void BaseGame::setOffset(int offsetX, int offsetY) { _offsetX = offsetX; _offsetY = offsetY; } ////////////////////////////////////////////////////////////////////////// -void CBGame::getOffset(int *offsetX, int *offsetY) { +void BaseGame::getOffset(int *offsetX, int *offsetY) { if (offsetX != NULL) *offsetX = _offsetX; if (offsetY != NULL) *offsetY = _offsetY; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadFile(const char *filename) { +bool BaseGame::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -740,7 +740,7 @@ TOKEN_DEF(GUID) TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadBuffer(byte *buffer, bool complete) { +bool BaseGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(GAME) TOKEN_TABLE(TEMPLATE) @@ -778,7 +778,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { @@ -819,7 +819,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_CURSOR: delete _cursor; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { delete _cursor; _cursor = NULL; @@ -830,7 +830,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_ACTIVE_CURSOR: delete _activeCursor; _activeCursor = NULL; - _activeCursor = new CBSprite(_gameRef); + _activeCursor = new BaseSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { delete _activeCursor; _activeCursor = NULL; @@ -840,7 +840,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { case TOKEN_NONINTERACTIVE_CURSOR: delete _cursorNoninteractive; - _cursorNoninteractive = new CBSprite(_gameRef); + _cursorNoninteractive = new BaseSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -908,7 +908,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SAVE_IMAGE: - CBUtils::setString(&_saveImageName, (char *)params); + BaseUtils::setString(&_saveImageName, (char *)params); break; case TOKEN_SAVE_IMAGE_X: @@ -920,7 +920,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOAD_IMAGE: - CBUtils::setString(&_loadImageName, (char *)params); + BaseUtils::setString(&_loadImageName, (char *)params); break; case TOKEN_LOAD_IMAGE_X: @@ -932,7 +932,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_LOCAL_SAVE_DIR: - CBUtils::setString(&_localSaveDir, (char *)params); + BaseUtils::setString(&_localSaveDir, (char *)params); break; case TOKEN_COMPAT_KILL_METHOD_THREADS: @@ -960,7 +960,7 @@ bool CBGame::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // LOG ////////////////////////////////////////////////////////////////////////// @@ -975,7 +975,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Caption") == 0) { - bool res = CBObject::scCallMethod(script, stack, thisStack, name); + bool res = BaseObject::scCallMethod(script, stack, thisStack, name); setWindowTitle(); return res; } @@ -1010,7 +1010,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "LoadStringTable") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); bool ClearOld; if (Val->isNULL()) ClearOld = true; @@ -1029,8 +1029,8 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *) obj)) stack->pushBool(true); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *) obj)) stack->pushBool(true); else stack->pushBool(false); return STATUS_OK; @@ -1053,8 +1053,8 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "UnloadObject") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); - CBObject *obj = (CBObject *)val->getNative(); + ScValue *val = stack->pop(); + BaseObject *obj = (BaseObject *)val->getNative(); unregisterObject(obj); if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); @@ -1067,7 +1067,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "LoadWindow") == 0) { stack->correctParams(1); - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { _windows.add(win); registerObject(win); @@ -1085,7 +1085,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ExpandString") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); char *str = new char[strlen(val->getString()) + 1]; strcpy(str, val->getString()); _stringTable->expand(&str); @@ -1106,10 +1106,10 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac } const char *filename = stack->pop()->getString(); - CScValue *valLooping = stack->pop(); + ScValue *valLooping = stack->pop(); bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - CScValue *valLoopStart = stack->pop(); + ScValue *valLoopStart = stack->pop(); uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); @@ -1311,7 +1311,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int length = 0; const char *filename = stack->pop()->getString(); - CBSound *sound = new CBSound(_gameRef); + BaseSound *sound = new BaseSound(_gameRef); if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { length = sound->getLength(); delete sound; @@ -1336,7 +1336,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac p.x = x + _renderer->_drawOffsetX; p.y = y + _renderer->_drawOffsetY; - CBPlatform::setCursorPos(p.x, p.y); + BasePlatform::setCursorPos(p.x, p.y); stack->pushNULL(); return STATUS_OK; @@ -1352,10 +1352,10 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int right = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - if (right < left) CBUtils::swap(&left, &right); - if (bottom < top) CBUtils::swap(&top, &bottom); + if (right < left) BaseUtils::swap(&left, &right); + if (bottom < top) BaseUtils::swap(&top, &bottom); - CBPlatform::setRect(&_mouseLockRect, left, top, right, bottom); + BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); stack->pushNULL(); return STATUS_OK; @@ -1377,7 +1377,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(6); const char *filename = stack->pop()->getString(); warning("PlayVideo: %s - not implemented yet", filename); - CScValue *valType = stack->pop(); + ScValue *valType = stack->pop(); int Type; if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; else Type = valType->getInt(); @@ -1386,7 +1386,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int yVal = stack->pop()->getInt(); bool FreezeMusic = stack->pop()->getBool(true); - CScValue *valSub = stack->pop(); + ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) @@ -1414,7 +1414,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(7); const char *filename = stack->pop()->getString(); - CScValue *valType = stack->pop(); + ScValue *valType = stack->pop(); int type; if (valType->isNULL()) type = (int)VID_PLAY_STRETCH; @@ -1425,13 +1425,13 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac bool freezeMusic = stack->pop()->getBool(true); bool dropFrames = stack->pop()->getBool(true); - CScValue *valSub = stack->pop(); + ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; delete _theoraPlayer; - _theoraPlayer = new CVidTheoraPlayer(this); + _theoraPlayer = new VideoTheoraPlayer(this); if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { _theoraPlayer->_dontDropFrames = !dropFrames; if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { @@ -1776,7 +1776,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac stack->correctParams(1); char filename[MAX_PATH_LENGTH]; - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int fileNum = 0; @@ -1789,7 +1789,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac } bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); + BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; @@ -1809,7 +1809,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac int sizeY = stack->pop()->getInt(_renderer->_height); bool ret = false; - CBImage *image = _gameRef->_renderer->takeScreenshot(); + BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->resize(sizeX, sizeY)); if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); @@ -1825,9 +1825,9 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "CreateWindow") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); - CUIWindow *win = new CUIWindow(_gameRef); + UIWindow *win = new UIWindow(_gameRef); _windows.add(win); registerObject(win); if (!val->isNULL()) win->setName(val->getString()); @@ -1840,7 +1840,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); - CBObject *obj = (CBObject *)stack->pop()->getNative(); + BaseObject *obj = (BaseObject *)stack->pop()->getNative(); for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == obj) { unregisterObject(_windows[i]); @@ -1876,7 +1876,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); _loadImageX = stack->pop()->getInt(); _loadImageY = stack->pop()->getInt(); @@ -1884,7 +1884,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac delete[] _loadImageName; _loadImageName = NULL; } else { - CBUtils::setString(&_loadImageName, val->getString()); + BaseUtils::setString(&_loadImageName, val->getString()); } stack->pushNULL(); return STATUS_OK; @@ -1895,7 +1895,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); _saveImageX = stack->pop()->getInt(); _saveImageY = stack->pop()->getInt(); @@ -1903,7 +1903,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac delete[] _saveImageName; _saveImageName = NULL; } else { - CBUtils::setString(&_saveImageName, val->getString()); + BaseUtils::setString(&_saveImageName, val->getString()); } stack->pushNULL(); return STATUS_OK; @@ -1976,7 +1976,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac _loadingIconPersistent = stack->pop()->getBool(); delete _loadingIcon; - _loadingIcon = new CBSprite(this); + _loadingIcon = new BaseSprite(this); if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { delete _loadingIcon; _loadingIcon = NULL; @@ -2035,7 +2035,7 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "StoreSaveThumbnail") == 0) { stack->correctParams(0); delete _cachedThumbnail; - _cachedThumbnail = new CBSaveThumbHelper(this); + _cachedThumbnail = new BaseSaveThumbHelper(this); if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { delete _cachedThumbnail; _cachedThumbnail = NULL; @@ -2143,12 +2143,12 @@ bool CBGame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStac return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBGame::scGetProperty(const char *name) { +ScValue *BaseGame::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -2185,7 +2185,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)CBPlatform::getTime()); + _scValue->setInt((int)BasePlatform::getTime()); return _scValue; } @@ -2504,7 +2504,7 @@ CScValue *CBGame::scGetProperty(const char *name) { // Platform (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Platform") == 0) { - _scValue->setString(CBPlatform::getPlatformName().c_str()); + _scValue->setString(BasePlatform::getPlatformName().c_str()); return _scValue; } @@ -2534,12 +2534,12 @@ CScValue *CBGame::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::scSetProperty(const char *name, CScValue *value) { +bool BaseGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -2571,7 +2571,7 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { // Caption ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - bool res = CBObject::scSetProperty(name, value); + bool res = BaseObject::scSetProperty(name, value); setWindowTitle(); return res; } @@ -2580,8 +2580,8 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { // MainObject ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { - CBScriptable *obj = value->getNative(); - if (obj == NULL || validObject((CBObject *)obj)) _mainObject = (CBObject *)obj; + BaseScriptable *obj = value->getNative(); + if (obj == NULL || validObject((BaseObject *)obj)) _mainObject = (BaseObject *)obj; return STATUS_OK; } @@ -2729,12 +2729,12 @@ bool CBGame::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBGame::scToString() { +const char *BaseGame::scToString() { return "[game object]"; } @@ -2742,7 +2742,7 @@ const char *CBGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayQuickMsg() { +bool BaseGame::displayQuickMsg() { if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; // update @@ -2767,17 +2767,17 @@ bool CBGame::displayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessage(const char *text) { +void BaseGame::quickMessage(const char *text) { if (_quickMessages.getSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.removeAt(0); } - _quickMessages.add(new CBQuickMsg(_gameRef, text)); + _quickMessages.add(new BaseQuickMsg(_gameRef, text)); } ////////////////////////////////////////////////////////////////////////// -void CBGame::quickMessageForm(char *fmt, ...) { +void BaseGame::quickMessageForm(char *fmt, ...) { char buff[256]; va_list va; @@ -2790,19 +2790,19 @@ void CBGame::quickMessageForm(char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::registerObject(CBObject *object) { +bool BaseGame::registerObject(BaseObject *object) { _regObjects.add(object); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::unregisterObject(CBObject *object) { +bool BaseGame::unregisterObject(BaseObject *object) { if (!object) return STATUS_OK; // is it a window? for (int i = 0; i < _windows.getSize(); i++) { - if ((CBObject *)_windows[i] == object) { + if ((BaseObject *)_windows[i] == object) { _windows.removeAt(i); // get new focused window @@ -2822,7 +2822,7 @@ bool CBGame::unregisterObject(CBObject *object) { for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { _regObjects.removeAt(i); - if (!_loadInProgress) CSysClassRegistry::getInstance()->enumInstances(invalidateValues, "CScValue", (void *)object); + if (!_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); delete object; return STATUS_OK; } @@ -2833,11 +2833,11 @@ bool CBGame::unregisterObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -void CBGame::invalidateValues(void *value, void *data) { - CScValue *val = (CScValue *)value; +void BaseGame::invalidateValues(void *value, void *data) { + ScValue *val = (ScValue *)value; if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((CBScriptable *)data)->_refCount == 1) { - ((CBScriptable *)data)->_refCount++; + if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { + ((BaseScriptable *)data)->_refCount++; } val->setNative(NULL); val->setNULL(); @@ -2847,7 +2847,7 @@ void CBGame::invalidateValues(void *value, void *data) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::validObject(CBObject *object) { +bool BaseGame::validObject(BaseObject *object) { if (!object) return false; if (object == this) return true; @@ -2859,8 +2859,8 @@ bool CBGame::validObject(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name) { - CScValue *thisObj; +bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// // LOG @@ -2947,8 +2947,8 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac else if (strcmp(name, "WaitFor") == 0) { stack->correctParams(1); - CBScriptable *obj = stack->pop()->getNative(); - if (validObject((CBObject *)obj)) script->waitForExclusive((CBObject *)obj); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *)obj)) script->waitForExclusive((BaseObject *)obj); stack->pushNULL(); } @@ -2961,7 +2961,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int from = stack->pop()->getInt(); int to = stack->pop()->getInt(); - stack->pushInt(CBUtils::randomInt(from, to)); + stack->pushInt(BaseUtils::randomInt(from, to)); } ////////////////////////////////////////////////////////////////////////// @@ -2983,7 +2983,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int g = stack->pop()->getInt(); int b = stack->pop()->getInt(); int a; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isNULL()) a = 255; else a = val->getInt(); @@ -2999,7 +2999,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac int s = stack->pop()->getInt(); int l = stack->pop()->getInt(); - stack->pushInt(CBUtils::HSLtoRGB(h, s, l)); + stack->pushInt(BaseUtils::HSLtoRGB(h, s, l)); } ////////////////////////////////////////////////////////////////////////// @@ -3050,7 +3050,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(H); } @@ -3062,7 +3062,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(S); } @@ -3074,7 +3074,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac uint32 rgb = (uint32)stack->pop()->getInt(); byte H, S, L; - CBUtils::RGBtoHSL(rgb, &H, &S, &L); + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); stack->pushInt(L); } @@ -3143,7 +3143,7 @@ bool CBGame::ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStac ////////////////////////////////////////////////////////////////////////// -bool CBGame::showCursor() { +bool BaseGame::showCursor() { if (_cursorHidden) return STATUS_OK; if (!_interactive && _gameRef->_state == GAME_RUNNING) { @@ -3160,7 +3160,7 @@ bool CBGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { +bool BaseGame::SaveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -3172,7 +3172,7 @@ bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; if (!quickSave) { @@ -3188,8 +3188,8 @@ bool CBGame::SaveGame(int slot, const char *desc, bool quickSave) { } } - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3206,8 +3206,8 @@ save_finish: // TODO: Remove gotos ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", CBUtils::GetUsedMemMB()); +bool BaseGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); _loading = false; _scheduledLoadSlot = -1; @@ -3220,7 +3220,7 @@ bool CBGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadGame(const char *filename) { +bool BaseGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); getDebugMgr()->onGameShutdown(); @@ -3241,13 +3241,13 @@ bool CBGame::loadGame(const char *filename) { _loadInProgress = true; _indicatorDisplay = true; _indicatorProgress = 0; - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); _debugAbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = CSysClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; // data initialization after load initAfterLoad(); @@ -3269,19 +3269,19 @@ load_finish: delete _saveLoadImage; _saveLoadImage = NULL; - //_gameRef->LOG(0, "Load end %d", CBUtils::GetUsedMemMB()); + //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); return ret; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::initAfterLoad() { - CSysClassRegistry::getInstance()->enumInstances(afterLoadRegion, "CBRegion", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "CBSubFrame", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadSound, "CBSound", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadFont, "CBFontTT", NULL); - CSysClassRegistry::getInstance()->enumInstances(afterLoadScript, "CScScript", NULL); +bool BaseGame::initAfterLoad() { + SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); _scEngine->refreshScriptBreakpoints(); @@ -3289,35 +3289,35 @@ bool CBGame::initAfterLoad() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadRegion(void *region, void *data) { - ((CBRegion *)region)->createRegion(); +void BaseGame::afterLoadRegion(void *region, void *data) { + ((BaseRegion *)region)->createRegion(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSubFrame(void *subframe, void *data) { - ((CBSubFrame *)subframe)->setSurfaceSimple(); +void BaseGame::afterLoadSubFrame(void *subframe, void *data) { + ((BaseSubFrame *)subframe)->setSurfaceSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadSound(void *sound, void *data) { - ((CBSound *)sound)->setSoundSimple(); +void BaseGame::afterLoadSound(void *sound, void *data) { + ((BaseSound *)sound)->setSoundSimple(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadFont(void *font, void *data) { - ((CBFont *)font)->afterLoad(); +void BaseGame::afterLoadFont(void *font, void *data) { + ((BaseFont *)font)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -void CBGame::afterLoadScript(void *script, void *data) { - ((CScScript *)script)->afterLoad(); +void BaseGame::afterLoadScript(void *script, void *data) { + ((ScScript *)script)->afterLoad(); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayWindows(bool inGame) { +bool BaseGame::displayWindows(bool inGame) { bool res; // did we lose focus? focus topmost window @@ -3345,7 +3345,7 @@ bool CBGame::displayWindows(bool inGame) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { +bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3354,7 +3354,7 @@ bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 l delete _music[channel]; _music[channel] = NULL; - _music[channel] = new CBSound(_gameRef); + _music[channel] = new BaseSound(_gameRef); if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { if (_musicStartTime[channel]) { _music[channel]->setPositionTime(_musicStartTime[channel]); @@ -3371,7 +3371,7 @@ bool CBGame::playMusic(int channel, const char *filename, bool looping, uint32 l ////////////////////////////////////////////////////////////////////////// -bool CBGame::stopMusic(int channel) { +bool BaseGame::stopMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3387,7 +3387,7 @@ bool CBGame::stopMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::pauseMusic(int channel) { +bool BaseGame::pauseMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3399,7 +3399,7 @@ bool CBGame::pauseMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::resumeMusic(int channel) { +bool BaseGame::resumeMusic(int channel) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3411,7 +3411,7 @@ bool CBGame::resumeMusic(int channel) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::setMusicStartTime(int channel, uint32 time) { +bool BaseGame::setMusicStartTime(int channel, uint32 time) { if (channel >= NUM_MUSIC_CHANNELS) { _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); return STATUS_FAILED; @@ -3424,7 +3424,7 @@ bool CBGame::setMusicStartTime(int channel, uint32 time) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::loadSettings(const char *filename) { +bool BaseGame::loadSettings(const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(SETTINGS) TOKEN_TABLE(GAME) @@ -3447,7 +3447,7 @@ bool CBGame::loadSettings(const char *filename) { byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); if (origBuffer == NULL) { - _gameRef->LOG(0, "CBGame::LoadSettings failed for file '%s'", filename); + _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; } @@ -3456,7 +3456,7 @@ bool CBGame::loadSettings(const char *filename) { byte *buffer = origBuffer; byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); @@ -3520,7 +3520,7 @@ bool CBGame::loadSettings(const char *filename) { break; case TOKEN_SAVED_GAME_EXT: - CBUtils::setString(&_savedGameExt, (char *)params); + BaseUtils::setString(&_savedGameExt, (char *)params); break; case TOKEN_GUID: @@ -3547,11 +3547,11 @@ bool CBGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::persist(CBPersistMgr *persistMgr) { +bool BaseGame::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(); - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_activeObject)); persistMgr->transfer(TMEMBER(_capturedObject)); @@ -3640,8 +3640,8 @@ bool CBGame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::focusWindow(CUIWindow *Window) { - CUIWindow *Prev = _focusedWindow; +bool BaseGame::focusWindow(UIWindow *Window) { + UIWindow *Prev = _focusedWindow; for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == Window) { @@ -3662,7 +3662,7 @@ bool CBGame::focusWindow(CUIWindow *Window) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::freeze(bool includingMusic) { +bool BaseGame::freeze(bool includingMusic) { if (_freezeLevel == 0) { _scEngine->pauseAll(); _soundMgr->pauseAll(includingMusic); @@ -3678,7 +3678,7 @@ bool CBGame::freeze(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::unfreeze() { +bool BaseGame::unfreeze() { if (_freezeLevel == 0) return STATUS_OK; _freezeLevel--; @@ -3694,7 +3694,7 @@ bool CBGame::unfreeze() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::handleKeypress(Common::Event *event, bool printable) { +bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (isVideoPlaying()) { if (event->kbd.keycode == Common::KEYCODE_ESCAPE) stopVideo(); @@ -3735,13 +3735,13 @@ bool CBGame::handleKeypress(Common::Event *event, bool printable) { return false; } -void CBGame::handleKeyRelease(Common::Event *event) { +void BaseGame::handleKeyRelease(Common::Event *event) { _keyboardState->handleKeyRelease(event); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::handleMouseWheel(int Delta) { +bool BaseGame::handleMouseWheel(int Delta) { bool handled = false; if (_focusedWindow) { handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); @@ -3771,7 +3771,7 @@ bool CBGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { +bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { if (verMajor) *verMajor = DCGF_VER_MAJOR; if (verMinor) *verMinor = DCGF_VER_MINOR; @@ -3783,7 +3783,7 @@ bool CBGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *ex ////////////////////////////////////////////////////////////////////////// -void CBGame::setWindowTitle() { +void BaseGame::setWindowTitle() { if (_renderer) { char title[512]; strcpy(title, _caption[0]); @@ -3795,13 +3795,13 @@ void CBGame::setWindowTitle() { if (_textEncoding == TEXT_UTF8) { utf8Title = Utf8String(title); } else { - warning("CBGame::SetWindowTitle -Ignoring textencoding"); + warning("BaseGame::SetWindowTitle -Ignoring textencoding"); utf8Title = Utf8String(title); /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } #if 0 - CBRenderOSystem *renderer = static_cast(_renderer); + BaseRenderOSystem *renderer = static_cast(_renderer); // TODO SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); @@ -3811,10 +3811,10 @@ void CBGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotFilename(int slot, char *buffer) { +bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { AnsiString dataDir = getDataDir(); //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String filename = pm->getFilenameForSlot(slot); delete pm; strcpy(buffer, filename.c_str()); @@ -3823,7 +3823,7 @@ bool CBGame::getSaveSlotFilename(int slot, char *buffer) { } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDataDir() { +AnsiString BaseGame::getDataDir() { AnsiString userDir = PathUtil::getUserDirectory(); AnsiString baseDir = _registry->getBasePath(); return PathUtil::combine(userDir, baseDir); @@ -3831,12 +3831,12 @@ AnsiString CBGame::getDataDir() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getSaveSlotDescription(int slot, char *buffer) { +bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; _debugAbsolutePathWarning = false; @@ -3855,11 +3855,11 @@ bool CBGame::getSaveSlotDescription(int slot, char *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::isSaveSlotUsed(int slot) { +bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - warning("CBGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); + warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); if (!File) return false; delete File; @@ -3868,10 +3868,10 @@ bool CBGame::isSaveSlotUsed(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::emptySaveSlot(int slot) { +bool BaseGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - CBPersistMgr *pm = new CBPersistMgr(this); + BasePersistenceManager *pm = new BasePersistenceManager(this); g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return STATUS_OK; @@ -3879,7 +3879,7 @@ bool CBGame::emptySaveSlot(int slot) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::setActiveObject(CBObject *obj) { +bool BaseGame::setActiveObject(BaseObject *obj) { // not-active when game is frozen if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { obj = NULL; @@ -3899,7 +3899,7 @@ bool CBGame::setActiveObject(CBObject *obj) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::pushViewport(CBViewport *viewport) { +bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); else _viewportStack[_viewportSP] = viewport; @@ -3911,7 +3911,7 @@ bool CBGame::pushViewport(CBViewport *viewport) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::popViewport() { +bool BaseGame::popViewport() { _viewportSP--; if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); @@ -3926,14 +3926,14 @@ bool CBGame::popViewport() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { +bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (rect == NULL) return STATUS_FAILED; else { if (_viewportSP >= 0) { - CBPlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); if (custom) *custom = true; } else { - CBPlatform::setRect(rect, _renderer->_drawOffsetX, + BasePlatform::setRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); @@ -3946,7 +3946,7 @@ bool CBGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { +bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; @@ -3960,42 +3960,42 @@ bool CBGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// -bool CBGame::windowLoadHook(CUIWindow *win, char **buf, char **params) { +bool BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name) { +bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -void CBGame::setInteractive(bool state) { +void BaseGame::setInteractive(bool state) { _interactive = state; if (_transMgr) _transMgr->_origInteractive = state; } ////////////////////////////////////////////////////////////////////////// -void CBGame::resetMousePos() { +void BaseGame::resetMousePos() { Common::Point p; p.x = _mousePos.x + _renderer->_drawOffsetX; p.y = _mousePos.y + _renderer->_drawOffsetY; - CBPlatform::setCursorPos(p.x, p.y); + BasePlatform::setCursorPos(p.x, p.y); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContent(bool doUpdate, bool displayAll) { +bool BaseGame::displayContent(bool doUpdate, bool displayAll) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayContentSimple() { +bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); if (_indicatorDisplay) displayIndicator(); @@ -4005,10 +4005,10 @@ bool CBGame::displayContentSimple() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayIndicator() { +bool BaseGame::displayIndicator() { if (_saveLoadImage) { Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } @@ -4023,7 +4023,7 @@ bool CBGame::displayIndicator() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::updateMusicCrossfade() { +bool BaseGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) return STATUS_OK; @@ -4055,7 +4055,7 @@ bool CBGame::updateMusicCrossfade() { if (_musicCrossfadeSwap) { // swap channels - CBSound *dummy = _music[_musicCrossfadeChannel1]; + BaseSound *dummy = _music[_musicCrossfadeChannel1]; int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; @@ -4078,7 +4078,7 @@ bool CBGame::updateMusicCrossfade() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::resetContent() { +bool BaseGame::resetContent() { _scEngine->clearGlobals(); //_timer = 0; //_liveTimer = 0; @@ -4087,12 +4087,12 @@ bool CBGame::resetContent() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::DEBUG_DumpClassRegistry() { +void BaseGame::DEBUG_DumpClassRegistry() { warning("DEBUG_DumpClassRegistry - untested"); Common::DumpFile *f = new Common::DumpFile; f->open("zz_class_reg_dump.log"); - CSysClassRegistry::getInstance()->dumpClasses(f); + SystemClassRegistry::getInstance()->dumpClasses(f); f->close(); delete f; @@ -4101,7 +4101,7 @@ void CBGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::invalidateDeviceObjects() { +bool BaseGame::invalidateDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->invalidateDeviceObjects(); } @@ -4110,7 +4110,7 @@ bool CBGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::restoreDeviceObjects() { +bool BaseGame::restoreDeviceObjects() { for (int i = 0; i < _regObjects.getSize(); i++) { _regObjects[i]->restoreDeviceObjects(); } @@ -4118,11 +4118,11 @@ bool CBGame::restoreDeviceObjects() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::setWaitCursor(const char *filename) { +bool BaseGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; - _cursorNoninteractive = new CBSprite(_gameRef); + _cursorNoninteractive = new BaseSprite(_gameRef); if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; @@ -4131,14 +4131,14 @@ bool CBGame::setWaitCursor(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isVideoPlaying() { +bool BaseGame::isVideoPlaying() { if (_videoPlayer->isPlaying()) return true; if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; return false; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::stopVideo() { +bool BaseGame::stopVideo() { if (_videoPlayer->isPlaying()) _videoPlayer->stop(); if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); @@ -4150,7 +4150,7 @@ bool CBGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// -bool CBGame::drawCursor(CBSprite *cursor) { +bool BaseGame::drawCursor(BaseSprite *cursor) { if (!cursor) return STATUS_FAILED; if (cursor != _lastCursor) { cursor->reset(); @@ -4162,7 +4162,7 @@ bool CBGame::drawCursor(CBSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// -bool CBGame::onActivate(bool activate, bool refreshMouse) { +bool BaseGame::onActivate(bool activate, bool refreshMouse) { if (_shuttingDown || !_renderer) return STATUS_OK; _renderer->_active = activate; @@ -4180,7 +4180,7 @@ bool CBGame::onActivate(bool activate, bool refreshMouse) { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDown() { +bool BaseGame::onMouseLeftDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); @@ -4192,16 +4192,16 @@ bool CBGame::onMouseLeftDown() { if (_activeObject != NULL) _capturedObject = _activeObject; _mouseLeftDown = true; - CBPlatform::setCapture(/*_renderer->_window*/); + BasePlatform::setCapture(/*_renderer->_window*/); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftUp() { +bool BaseGame::onMouseLeftUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - CBPlatform::releaseCapture(); + BasePlatform::releaseCapture(); _capturedObject = NULL; _mouseLeftDown = false; @@ -4215,7 +4215,7 @@ bool CBGame::onMouseLeftUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseLeftDblClick() { +bool BaseGame::onMouseLeftDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); @@ -4230,7 +4230,7 @@ bool CBGame::onMouseLeftDblClick() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDblClick() { +bool BaseGame::onMouseRightDblClick() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); @@ -4245,7 +4245,7 @@ bool CBGame::onMouseRightDblClick() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightDown() { +bool BaseGame::onMouseRightDown() { if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); @@ -4258,7 +4258,7 @@ bool CBGame::onMouseRightDown() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseRightUp() { +bool BaseGame::onMouseRightUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); @@ -4271,7 +4271,7 @@ bool CBGame::onMouseRightUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleDown() { +bool BaseGame::onMouseMiddleDown() { if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); @@ -4286,7 +4286,7 @@ bool CBGame::onMouseMiddleDown() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onMouseMiddleUp() { +bool BaseGame::onMouseMiddleUp() { if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); @@ -4299,7 +4299,7 @@ bool CBGame::onMouseMiddleUp() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onPaint() { +bool BaseGame::onPaint() { if (_renderer && _renderer->_windowed && _renderer->_ready) { _renderer->initLoop(); displayContent(false, true); @@ -4310,7 +4310,7 @@ bool CBGame::onPaint() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onWindowClose() { +bool BaseGame::onWindowClose() { if (canHandleEvent("QuitGame")) { if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); return STATUS_OK; @@ -4318,7 +4318,7 @@ bool CBGame::onWindowClose() { } ////////////////////////////////////////////////////////////////////////// -bool CBGame::displayDebugInfo() { +bool BaseGame::displayDebugInfo() { char str[100]; if (_debugShowFPS) { @@ -4359,15 +4359,15 @@ bool CBGame::displayDebugInfo() { } ////////////////////////////////////////////////////////////////////////// -CBDebugger *CBGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new CBDebugger(this); +BaseDebugger *BaseGame::getDebugMgr() { + if (!_debugMgr) _debugMgr = new BaseDebugger(this); return _debugMgr; } ////////////////////////////////////////////////////////////////////////// -void CBGame::getMousePos(Point32 *pos) { - CBPlatform::getCursorPos(pos); +void BaseGame::getMousePos(Point32 *pos) { + BasePlatform::getCursorPos(pos); pos->x -= _renderer->_drawOffsetX; pos->y -= _renderer->_drawOffsetY; @@ -4386,7 +4386,7 @@ void CBGame::getMousePos(Point32 *pos) { */ if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!CBPlatform::ptInRect(&_mouseLockRect, *pos)) { + if (!BasePlatform::ptInRect(&_mouseLockRect, *pos)) { pos->x = MAX(_mouseLockRect.left, pos->x); pos->y = MAX(_mouseLockRect.top, pos->y); @@ -4398,52 +4398,52 @@ void CBGame::getMousePos(Point32 *pos) { newPos.x += _renderer->_drawOffsetX; newPos.y += _renderer->_drawOffsetY; - CBPlatform::setCursorPos(newPos.x, newPos.y); + BasePlatform::setCursorPos(newPos.x, newPos.y); } } } ////////////////////////////////////////////////////////////////////////// -bool CBGame::miniUpdate() { +bool BaseGame::miniUpdate() { if (!_miniUpdateEnabled) return STATUS_OK; - if (CBPlatform::getTime() - _lastMiniUpdate > 200) { + if (BasePlatform::getTime() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = CBPlatform::getTime(); + _lastMiniUpdate = BasePlatform::getTime(); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::onScriptShutdown(CScScript *script) { +bool BaseGame::onScriptShutdown(ScScript *script) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isLeftDoubleClick() { +bool BaseGame::isLeftDoubleClick() { return isDoubleClick(0); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isRightDoubleClick() { +bool BaseGame::isRightDoubleClick() { return isDoubleClick(1); } ////////////////////////////////////////////////////////////////////////// -bool CBGame::isDoubleClick(int buttonIndex) { +bool BaseGame::isDoubleClick(int buttonIndex) { uint32 maxDoubleCLickTime = 500; int maxMoveX = 4; int maxMoveY = 4; Point32 pos; - CBPlatform::getCursorPos(&pos); + BasePlatform::getCursorPos(&pos); int moveX = abs(pos.x - _lastClick[buttonIndex].posX); int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - if (_lastClick[buttonIndex].time == 0 || CBPlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = CBPlatform::getTime(); + if (_lastClick[buttonIndex].time == 0 || BasePlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = BasePlatform::getTime(); _lastClick[buttonIndex].posX = pos.x; _lastClick[buttonIndex].posY = pos.y; return false; @@ -4454,7 +4454,7 @@ bool CBGame::isDoubleClick(int buttonIndex) { } ////////////////////////////////////////////////////////////////////////// -void CBGame::autoSaveOnExit() { +void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); _registry->saveValues(); @@ -4465,12 +4465,12 @@ void CBGame::autoSaveOnExit() { } ////////////////////////////////////////////////////////////////////////// -void CBGame::addMem(int bytes) { +void BaseGame::addMem(int bytes) { _usedMem += bytes; } ////////////////////////////////////////////////////////////////////////// -AnsiString CBGame::getDeviceType() const { +AnsiString BaseGame::getDeviceType() const { return "computer"; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 711eebfc98..77fa6b3a8b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -41,33 +41,33 @@ namespace WinterMute { typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); -class CBSoundMgr; -class CBFader; -class CBFont; -class CBFileManager; -class CBTransitionMgr; -class CScEngine; -class CBFontStorage; -class CBStringTable; -class CBQuickMsg; -class CUIWindow; -class CBViewport; -class CBRenderer; -class CBRegistry; -class CBSaveThumbHelper; -class CBSurfaceStorage; -class CSXMath; -class CBKeyboardState; -class CVidPlayer; -class CVidTheoraPlayer; +class BaseSoundMgr; +class BaseFader; +class BaseFont; +class BaseFileManager; +class BaseTransitionMgr; +class ScEngine; +class BaseFontStorage; +class BaseStringTable; +class BaseQuickMsg; +class UIWindow; +class BaseViewport; +class BaseRenderer; +class BaseRegistry; +class BaseSaveThumbHelper; +class BaseSurfaceStorage; +class SXMath; +class BaseKeyboardState; +class VideoPlayer; +class VideoTheoraPlayer; #define NUM_MUSIC_CHANNELS 5 -class CBGame: public CBObject { +class BaseGame: public BaseObject { public: - DECLARE_PERSISTENT(CBGame, CBObject) + DECLARE_PERSISTENT(BaseGame, BaseObject) - virtual bool onScriptShutdown(CScScript *script); + virtual bool onScriptShutdown(ScScript *script); virtual bool onActivate(bool activate, bool refreshMouse); virtual bool onMouseLeftDown(); @@ -105,7 +105,7 @@ public: TTextEncoding _textEncoding; bool _textRTL; - CBSprite *_loadingIcon; + BaseSprite *_loadingIcon; int _loadingIconX; int _loadingIconY; int _loadingIconPersistent; @@ -136,7 +136,7 @@ protected: int _loadImageX; int _loadImageY; - CBSurface *_saveLoadImage; + BaseSurface *_saveLoadImage; bool displayIndicator(); bool _reportTextureFormat; @@ -157,32 +157,32 @@ public: int _offsetX; float _offsetPercentX; float _offsetPercentY; - CBObject *_mainObject; + BaseObject *_mainObject; bool initInput(); bool initLoop(); uint32 _currentTime; uint32 _deltaTime; - CBFont *_systemFont; - CBFont *_videoFont; + BaseFont *_systemFont; + BaseFont *_videoFont; bool initialize1(); bool initialize2(); bool initialize3(); - CBFileManager *_fileManager; - CBTransitionMgr *_transMgr; - CBDebugger *getDebugMgr(); + BaseFileManager *_fileManager; + BaseTransitionMgr *_transMgr; + BaseDebugger *getDebugMgr(); void LOG(bool res, const char *fmt, ...); - CBRenderer *_renderer; - CBSoundMgr *_soundMgr; - CScEngine *_scEngine; - CSXMath *_mathClass; - CBSurfaceStorage *_surfaceStorage; - CBFontStorage *_fontStorage; - CBGame(); + BaseRenderer *_renderer; + BaseSoundMgr *_soundMgr; + ScEngine *_scEngine; + SXMath *_mathClass; + BaseSurfaceStorage *_surfaceStorage; + BaseFontStorage *_fontStorage; + BaseGame(); - virtual ~CBGame(); + virtual ~BaseGame(); void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *filename = NULL); bool _debugDebugMode; @@ -192,13 +192,13 @@ public: int _sequence; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); - CBArray _quickMessages; - CBArray _windows; - CBArray _viewportStack; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; int _viewportSP; - CBStringTable *_stringTable; + BaseStringTable *_stringTable; int _settingsResWidth; int _settingsResHeight; char *_settingsGameFile; @@ -215,15 +215,15 @@ protected: bool _settingsRequireSound; bool _settingsAllowDesktopRes; int _settingsTLMode; - CBFader *_fader; + BaseFader *_fader; virtual bool invalidateDeviceObjects(); virtual bool restoreDeviceObjects(); public: - virtual bool ExternalCall(CScScript *script, CScStack *stack, CScStack *thisStack, char *name); + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); // compatibility bits bool _compatKillMethodThreads; @@ -262,11 +262,11 @@ protected: public: bool unfreeze(); bool freeze(bool includingMusic = true); - bool focusWindow(CUIWindow *window); - CVidPlayer *_videoPlayer; - CVidTheoraPlayer *_theoraPlayer; + bool focusWindow(UIWindow *window); + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; bool _loadInProgress; - CUIWindow *_focusedWindow; + UIWindow *_focusedWindow; bool _editorForceScripts; protected: static void afterLoadRegion(void *region, void *data); @@ -283,7 +283,7 @@ public: bool pauseMusic(int channel); bool stopMusic(int channel); bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - CBSound *_music[NUM_MUSIC_CHANNELS]; + BaseSound *_music[NUM_MUSIC_CHANNELS]; bool _musicCrossfadeRunning; bool _musicCrossfadeSwap; uint32 _musicCrossfadeStartTime; @@ -291,7 +291,7 @@ public: int _musicCrossfadeChannel1; int _musicCrossfadeChannel2; bool displayWindows(bool inGame = false); - CBRegistry *_registry; + BaseRegistry *_registry; bool _useD3D; virtual bool cleanup(); virtual bool loadGame(int slot); @@ -299,9 +299,9 @@ public: virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - CBSprite *_cursorNoninteractive; - CBObject *_activeObject; - CBKeyboardState *_keyboardState; + BaseSprite *_cursorNoninteractive; + BaseObject *_activeObject; + BaseKeyboardState *_keyboardState; bool _interactive; TGameState _state; TGameState _origState; @@ -314,11 +314,11 @@ public: uint32 _liveTimerDelta; uint32 _liveTimerLast; - CBObject *_capturedObject; + BaseObject *_capturedObject; Point32 _mousePos; - bool validObject(CBObject *object); - bool unregisterObject(CBObject *object); - bool registerObject(CBObject *object); + bool validObject(BaseObject *object); + bool unregisterObject(BaseObject *object); + bool registerObject(BaseObject *object); void quickMessage(const char *text); void quickMessageForm(char *fmt, ...); bool displayQuickMsg(); @@ -328,7 +328,7 @@ public: bool isVideoPlaying(); bool stopVideo(); - CBArray _regObjects; + BaseArray _regObjects; public: virtual bool displayContent(bool update = true, bool displayAll = false); virtual bool displayContentSimple(); @@ -336,18 +336,18 @@ public: void resetMousePos(); int _subtitlesSpeed; void setInteractive(bool state); - virtual bool windowLoadHook(CUIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(CUIWindow *win, CScScript *script, CScStack *stack, const char *name); + virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); bool popViewport(); - bool pushViewport(CBViewport *Viewport); - bool setActiveObject(CBObject *Obj); - CBSprite *_lastCursor; - bool drawCursor(CBSprite *Cursor); + bool pushViewport(BaseViewport *Viewport); + bool setActiveObject(BaseObject *Obj); + BaseSprite *_lastCursor; + bool drawCursor(BaseSprite *Cursor); virtual bool initAfterLoad(); - CBSaveThumbHelper *_cachedThumbnail; + BaseSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); @@ -356,7 +356,7 @@ public: AnsiString getDeviceType() const; private: - CBDebugger *_debugMgr; + BaseDebugger *_debugMgr; struct LastClickInfo { LastClickInfo() { diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 240f642b7f..ad014762d4 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -35,10 +35,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBKeyboardState, false) +IMPLEMENT_PERSISTENT(BaseKeyboardState, false) ////////////////////////////////////////////////////////////////////////// -CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame): BaseScriptable(inGame) { _currentPrintable = false; _currentCharCode = 0; _currentKeyData = 0; @@ -54,17 +54,17 @@ CBKeyboardState::CBKeyboardState(CBGame *inGame): CBScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBKeyboardState::~CBKeyboardState() { +BaseKeyboardState::~BaseKeyboardState() { delete[] _keyStates; } -void CBKeyboardState::handleKeyPress(Common::Event *event) { +void BaseKeyboardState::handleKeyPress(Common::Event *event) { if (event->type == Common::EVENT_KEYDOWN) { _keyStates[event->kbd.keycode] = true; } } -void CBKeyboardState::handleKeyRelease(Common::Event *event) { +void BaseKeyboardState::handleKeyRelease(Common::Event *event) { if (event->type == Common::EVENT_KEYUP) { _keyStates[event->kbd.keycode] = false; } @@ -73,13 +73,13 @@ void CBKeyboardState::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // IsKeyDown ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "IsKeyDown") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); int vKey; if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { @@ -98,12 +98,12 @@ bool CBKeyboardState::scCallMethod(CScScript *script, CScStack *stack, CScStack return STATUS_OK; } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBKeyboardState::scGetProperty(const char *name) { +ScValue *BaseKeyboardState::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -168,12 +168,12 @@ CScValue *CBKeyboardState::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { +bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -184,18 +184,18 @@ bool CBKeyboardState::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBKeyboardState::scToString() { +const char *BaseKeyboardState::scToString() { return "[keyboard state]"; } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::readKey(Common::Event *event) { +bool BaseKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || @@ -215,9 +215,9 @@ bool CBKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { +bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { //if(!persistMgr->_saving) cleanup(); - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); persistMgr->transfer(TMEMBER(_currentCharCode)); @@ -237,25 +237,25 @@ bool CBKeyboardState::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isShiftDown() { +bool BaseKeyboardState::isShiftDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_SHIFT); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isControlDown() { +bool BaseKeyboardState::isControlDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_CTRL); } ////////////////////////////////////////////////////////////////////////// -bool CBKeyboardState::isAltDown() { +bool BaseKeyboardState::isAltDown() { int mod = g_system->getEventManager()->getModifierState(); return (mod & Common::KBD_ALT); } ////////////////////////////////////////////////////////////////////////// -uint32 CBKeyboardState::keyCodeToVKey(Common::Event *event) { +uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { if (event->type != Common::EVENT_KEYDOWN) return 0; switch (event->kbd.keycode) { @@ -275,7 +275,7 @@ enum VKeyCodes { }; ////////////////////////////////////////////////////////////////////////// -Common::KeyCode CBKeyboardState::vKeyToKeyCode(uint32 vkey) { +Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { case VK_SPACE: diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index bdf268c601..8c4b1afb59 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -37,7 +37,7 @@ namespace WinterMute { -class CBKeyboardState : public CBScriptable { +class BaseKeyboardState : public BaseScriptable { public: uint32 _currentKeyData; uint32 _currentCharCode; @@ -47,9 +47,9 @@ public: bool _currentAlt; bool _currentControl; - DECLARE_PERSISTENT(CBKeyboardState, CBScriptable) - CBKeyboardState(CBGame *inGame); - virtual ~CBKeyboardState(); + DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) + BaseKeyboardState(BaseGame *inGame); + virtual ~BaseKeyboardState(); bool readKey(Common::Event *event); void handleKeyPress(Common::Event *event); @@ -59,9 +59,9 @@ public: static bool isAltDown(); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index da76fb2047..97b9f53353 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -32,30 +32,30 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(CBGame *inGame) : CBBase(inGame) { +BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject() : CBBase() { +BaseNamedObject::BaseNamedObject() : BaseClass() { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::CBNamedObject(TDynamicConstructor, TDynamicConstructor) { +BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { _name = NULL; } ////////////////////////////////////////////////////////////////////////// -CBNamedObject::~CBNamedObject(void) { +BaseNamedObject::~BaseNamedObject(void) { delete[] _name; _name = NULL; } ////////////////////////////////////////////////////////////////////// -void CBNamedObject::setName(const char *name) { +void BaseNamedObject::setName(const char *name) { delete[] _name; _name = new char [strlen(name) + 1]; diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index c03d1417a3..f7b496ead8 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -34,12 +34,12 @@ namespace WinterMute { -class CBNamedObject : public CBBase { +class BaseNamedObject : public BaseClass { public: - CBNamedObject(CBGame *inGame); - CBNamedObject(); - virtual ~CBNamedObject(void); - CBNamedObject(TDynamicConstructor, TDynamicConstructor); + BaseNamedObject(BaseGame *inGame); + BaseNamedObject(); + virtual ~BaseNamedObject(void); + BaseNamedObject(TDynamicConstructor, TDynamicConstructor); char *_name; void setName(const char *name); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 0a4a0638f0..4ab121ded9 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -40,10 +40,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBObject, false) +IMPLEMENT_PERSISTENT(BaseObject, false) ////////////////////////////////////////////////////////////////////// -CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { +BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { _posX = _posY = 0; _movable = true; _zoomable = true; @@ -65,7 +65,7 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { _iD = _gameRef->getSequence(); - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _rectSet = false; _cursor = NULL; @@ -101,17 +101,17 @@ CBObject::CBObject(CBGame *inGame): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// -CBObject::~CBObject() { +BaseObject::~BaseObject() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBObject::cleanup() { +bool BaseObject::cleanup() { if (_gameRef && _gameRef->_activeObject == this) _gameRef->_activeObject = NULL; - CBScriptHolder::cleanup(); + BaseScriptHolder::cleanup(); delete[] _soundEvent; _soundEvent = NULL; @@ -137,7 +137,7 @@ bool CBObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull +void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull if (caseVal == 0) caseVal = 1; if (caseVal < 1 || caseVal > 7) return; @@ -152,7 +152,7 @@ void CBObject::setCaption(const char *caption, int caseVal) { // TODO: rename Ca ////////////////////////////////////////////////////////////////////////// -const char *CBObject::getCaption(int caseVal) { +const char *BaseObject::getCaption(int caseVal) { if (caseVal == 0) caseVal = 1; if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) return ""; @@ -161,7 +161,7 @@ const char *CBObject::getCaption(int caseVal) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { +bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -169,7 +169,7 @@ bool CBObject::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SkipTo @@ -291,9 +291,9 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt bool looping; uint32 loopStart; - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); - CScValue *val3 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *val3 = stack->pop(); if (val1->_type == VAL_BOOL) { filename = NULL; @@ -321,8 +321,8 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt const char *filename; const char *eventName; - CScValue *val1 = stack->pop(); - CScValue *val2 = stack->pop(); + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); if (val2->isNULL()) { filename = NULL; @@ -473,12 +473,12 @@ bool CBObject::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); + else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBObject::scGetProperty(const char *name) { +ScValue *BaseObject::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -666,12 +666,12 @@ CScValue *CBObject::scGetProperty(const char *name) { return _scValue; } - else return CBScriptHolder::scGetProperty(name); + else return BaseScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBObject::scSetProperty(const char *name, CScValue *value) { +bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// @@ -845,32 +845,32 @@ bool CBObject::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptHolder::scSetProperty(name, value); + else return BaseScriptHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBObject::scToString() { +const char *BaseObject::scToString() { return "[object]"; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::showCursor() { +bool BaseObject::showCursor() { if (_cursor) return _gameRef->drawCursor(_cursor); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); +bool BaseObject::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); for (int i = 0; i < 7; i++) persistMgr->transfer(TMEMBER(_caption[i])); @@ -925,14 +925,14 @@ bool CBObject::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setCursor(const char *filename) { +bool BaseObject::setCursor(const char *filename) { if (!_sharedCursors) { delete _cursor; _cursor = NULL; } _sharedCursors = false; - _cursor = new CBSprite(_gameRef); + _cursor = new BaseSprite(_gameRef); if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { delete _cursor; _cursor = NULL; @@ -942,9 +942,9 @@ bool CBObject::setCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setActiveCursor(const char *filename) { +bool BaseObject::setActiveCursor(const char *filename) { delete _activeCursor; - _activeCursor = new CBSprite(_gameRef); + _activeCursor = new BaseSprite(_gameRef); if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { delete _activeCursor; _activeCursor = NULL; @@ -954,31 +954,31 @@ bool CBObject::setActiveCursor(const char *filename) { ////////////////////////////////////////////////////////////////////////// -int CBObject::getHeight() { +int BaseObject::getHeight() { return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouse(TMouseEvent event, TMouseButton button) { +bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleKeypress(Common::Event *event, bool printable) { +bool BaseObject::handleKeypress(Common::Event *event, bool printable) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::handleMouseWheel(int delta) { +bool BaseObject::handleMouseWheel(int delta) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { +bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { // just play loaded sound if (filename == NULL && _sFX) { if (_gameRef->_editorMode || _sFXStart) { @@ -998,7 +998,7 @@ bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const c // create new sound delete _sFX; - _sFX = new CBSound(_gameRef); + _sFX = new BaseSound(_gameRef); if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { _sFX->setVolumePercent(_sFXVolume); if (_sFXStart) { @@ -1020,7 +1020,7 @@ bool CBObject::playSFX(const char *filename, bool looping, bool playNow, const c ////////////////////////////////////////////////////////////////////////// -bool CBObject::stopSFX(bool deleteSound) { +bool BaseObject::stopSFX(bool deleteSound) { if (_sFX) { _sFX->stop(); if (deleteSound) { @@ -1033,21 +1033,21 @@ bool CBObject::stopSFX(bool deleteSound) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::pauseSFX() { +bool BaseObject::pauseSFX() { if (_sFX) return _sFX->pause(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::resumeSFX() { +bool BaseObject::resumeSFX() { if (_sFX) return _sFX->resume(); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXTime(uint32 time) { +bool BaseObject::setSFXTime(uint32 time) { _sFXStart = time; if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); else return STATUS_OK; @@ -1055,7 +1055,7 @@ bool CBObject::setSFXTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::setSFXVolume(int volume) { +bool BaseObject::setSFXVolume(int volume) { _sFXVolume = volume; if (_sFX) return _sFX->setVolumePercent(volume); else return STATUS_OK; @@ -1063,7 +1063,7 @@ bool CBObject::setSFXVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -bool CBObject::updateSounds() { +bool BaseObject::updateSounds() { if (_soundEvent) { if (_sFX && !_sFX->isPlaying()) { applyEvent(_soundEvent); @@ -1077,7 +1077,7 @@ bool CBObject::updateSounds() { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::updateOneSound(CBSound *sound) { +bool BaseObject::updateOneSound(BaseSound *sound) { bool Ret = STATUS_OK; if (sound) { @@ -1090,7 +1090,7 @@ bool CBObject::updateOneSound(CBSound *sound) { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::resetSoundPan() { +bool BaseObject::resetSoundPan() { if (!_sFX) return STATUS_OK; else { return _sFX->setPan(0.0f); @@ -1099,19 +1099,19 @@ bool CBObject::resetSoundPan() { ////////////////////////////////////////////////////////////////////////// -bool CBObject::getExtendedFlag(const char *flagName) { +bool BaseObject::getExtendedFlag(const char *flagName) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBObject::isReady() { +bool BaseObject::isReady() { return _ready; } ////////////////////////////////////////////////////////////////////////// -void CBObject::setSoundEvent(const char *eventName) { +void BaseObject::setSoundEvent(const char *eventName) { delete[] _soundEvent; _soundEvent = NULL; if (eventName) { @@ -1121,7 +1121,7 @@ void CBObject::setSoundEvent(const char *eventName) { } ////////////////////////////////////////////////////////////////////////// -bool CBObject::afterMove() { +bool BaseObject::afterMove() { return STATUS_OK; } diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 70dc69f53d..c05501b145 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -36,14 +36,14 @@ namespace WinterMute { -class CBSprite; -class CBSound; -class CBSurface; -class CBScriptHolder; -class CScValue; -class CScStack; -class CScScript; -class CBObject : public CBScriptHolder { +class BaseSprite; +class BaseSound; +class BaseSurface; +class BaseScriptHolder; +class ScValue; +class ScStack; +class ScScript; +class BaseObject : public BaseScriptHolder { public: TSpriteBlendMode _blendMode; virtual bool afterMove(); @@ -61,7 +61,7 @@ public: virtual bool getExtendedFlag(const char *flagName); virtual bool resetSoundPan(); virtual bool updateSounds(); - bool updateOneSound(CBSound *sound); + bool updateOneSound(BaseSound *sound); bool _autoSoundPanning; uint32 _sFXStart; int _sFXVolume; @@ -71,7 +71,7 @@ public: bool pauseSFX(); bool stopSFX(bool deleteSound = true); bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - CBSound *_sFX; + BaseSound *_sFX; TSFXType _sFXType; float _sFXParam1; @@ -92,13 +92,13 @@ public: bool _editorAlwaysRegister; bool _editorOnly; bool _is3D; - DECLARE_PERSISTENT(CBObject, CBScriptHolder) + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) virtual bool showCursor(); - CBSprite *_cursor; + BaseSprite *_cursor; bool _sharedCursors; - CBSprite *_activeCursor; - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); + BaseSprite *_activeCursor; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool _ready; bool _registrable; bool _zoomable; @@ -107,8 +107,8 @@ public: bool _rectSet; int _iD; bool _movable; - CBObject(CBGame *inGame); - virtual ~CBObject(); + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); char *_caption[7]; char *_soundEvent; int _posY; @@ -133,9 +133,9 @@ public: public: // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 0f185636aa..b07d98eca8 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -43,26 +43,26 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBParser::CBParser(CBGame *inGame): CBBase(inGame) { +BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } ////////////////////////////////////////////////////////////////////// -CBParser::~CBParser() { +BaseParser::~BaseParser() { if (_whiteSpace != NULL) delete [] _whiteSpace; } ////////////////////////////////////////////////////////////////////// -char *CBParser::getLastOffender() { +char *BaseParser::getLastOffender() { return _lastOffender; } ////////////////////////////////////////////////////////////////////// -int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -113,7 +113,7 @@ int32 CBParser::getObject(char **buf, TokenDesc *tokens, char **name, char **dat ////////////////////////////////////////////////////////////////////// -int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) return PARSERR_TOKENNOTFOUND; _gameRef->miniUpdate(); char *name; @@ -122,7 +122,7 @@ int32 CBParser::getCommand(char **buf, TokenDesc *tokens, char **params) { ////////////////////////////////////////////////////////////////////// -void CBParser::skipCharacters(char **buf, const char *toSkip) { +void BaseParser::skipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { if (ch == '\n') _parserLine++; @@ -135,7 +135,7 @@ void CBParser::skipCharacters(char **buf, const char *toSkip) { ////////////////////////////////////////////////////////////////////// -char *CBParser::getSubText(char **buf, char open, char close) { +char *BaseParser::getSubText(char **buf, char open, char close) { if (**buf == 0 || **buf != open) return 0; ++*buf; // skip opening delimiter @@ -164,7 +164,7 @@ char *CBParser::getSubText(char **buf, char open, char close) { ////////////////////////////////////////////////////////////////////// -char *CBParser::getAssignmentText(char **buf) { +char *BaseParser::getAssignmentText(char **buf) { ++*buf; // skip the '=' skipCharacters(buf, _whiteSpace); char *result = *buf; @@ -192,7 +192,7 @@ char *CBParser::getAssignmentText(char **buf) { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *CBParser::getToken(char **buf) { +char *BaseParser::getToken(char **buf) { static char token[100]; char *b = *buf, * t = token; while (true) { @@ -240,7 +240,7 @@ char *CBParser::getToken(char **buf) { ////////////////////////////////////////////////////////////////////// -float CBParser::getTokenFloat(char **buf) { +float BaseParser::getTokenFloat(char **buf) { char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. @@ -252,7 +252,7 @@ float CBParser::getTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// -int CBParser::getTokenInt(char **buf) { +int BaseParser::getTokenInt(char **buf) { char *t = getToken(buf); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. @@ -264,14 +264,14 @@ int CBParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// -void CBParser::skipToken(char **buf, char *tok, char * /*msg*/) { +void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { char *t = getToken(buf); if (strcmp(t, tok)) return; // Error } ////////////////////////////////////////////////////////////////////// -int CBParser::scanStr(const char *in, const char *format, ...) { +int BaseParser::scanStr(const char *in, const char *format, ...) { va_list arg; va_start(arg, format); diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 53a02c0f68..a5c55ceb41 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -40,7 +40,7 @@ TOKEN_TOTAL_COUNT \ }; #define TOKEN_TABLE_START(name) \ - static CBParser::TokenDesc name [] = \ + static BaseParser::TokenDesc name [] = \ { #define TOKEN_TABLE(name) \ { TOKEN_ ## name, #name }, @@ -57,7 +57,7 @@ namespace WinterMute { -class CBParser : public CBBase { +class BaseParser : public BaseClass { public: struct TokenDesc { int32 id; @@ -67,8 +67,8 @@ public: public: int scanStr(const char *in, const char *format, ...); int32 getCommand(char **buf, TokenDesc *tokens, char **params); - CBParser(CBGame *inGame = NULL); - virtual ~CBParser(); + BaseParser(BaseGame *inGame = NULL); + virtual ~BaseParser(); private: char *getLastOffender(); void skipToken(char **buf, char *tok, char *msg = NULL); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 743eaf355b..18dc8ed11c 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -51,7 +51,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGame) { +BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix): BaseClass(inGame) { _saving = false; // _buffer = NULL; // _bufferSize = 0; @@ -80,13 +80,13 @@ CBPersistMgr::CBPersistMgr(CBGame *inGame, const char *savePrefix): CBBase(inGam ////////////////////////////////////////////////////////////////////////// -CBPersistMgr::~CBPersistMgr() { +BasePersistenceManager::~BasePersistenceManager() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::cleanup() { +void BasePersistenceManager::cleanup() { /* if (_buffer) { if (_saving) free(_buffer); else delete [] _buffer; // allocated by file manager @@ -118,12 +118,12 @@ void CBPersistMgr::cleanup() { _saveStream = NULL; } -Common::String CBPersistMgr::getFilenameForSlot(int slot) const { +Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); } -void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { +void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { @@ -150,12 +150,12 @@ void CBPersistMgr::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { desc.setPlayTime(0); } -void CBPersistMgr::deleteSaveSlot(int slot) { +void BasePersistenceManager::deleteSaveSlot(int slot) { Common::String filename = getFilenameForSlot(slot); g_system->getSavefileManager()->removeSavefile(filename); } -uint32 CBPersistMgr::getMaxUsedSlot() { +uint32 BasePersistenceManager::getMaxUsedSlot() { Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); Common::StringArray::iterator it = saves.begin(); @@ -168,7 +168,7 @@ uint32 CBPersistMgr::getMaxUsedSlot() { return ret; } -bool CBPersistMgr::getSaveExists(int slot) { +bool BasePersistenceManager::getSaveExists(int slot) { Common::String filename = getFilenameForSlot(slot); warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { @@ -178,7 +178,7 @@ bool CBPersistMgr::getSaveExists(int slot) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initSave(const char *desc) { +bool BasePersistenceManager::initSave(const char *desc) { if (!desc) return STATUS_FAILED; cleanup(); @@ -189,7 +189,7 @@ bool CBPersistMgr::initSave(const char *desc) { if (_saveStream) { // get thumbnails if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new CBSaveThumbHelper(_gameRef); + _gameRef->_cachedThumbnail = new BaseSaveThumbHelper(_gameRef); if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { delete _gameRef->_cachedThumbnail; _gameRef->_cachedThumbnail = NULL; @@ -252,7 +252,7 @@ bool CBPersistMgr::initSave(const char *desc) { return STATUS_OK; } -bool CBPersistMgr::readHeader(const Common::String &filename) { +bool BasePersistenceManager::readHeader(const Common::String &filename) { cleanup(); _saving = false; @@ -307,7 +307,7 @@ bool CBPersistMgr::readHeader(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::initLoad(const char *filename) { +bool BasePersistenceManager::initLoad(const char *filename) { if (DID_FAIL(readHeader(filename))) { cleanup(); return STATUS_FAILED; @@ -356,13 +356,13 @@ bool CBPersistMgr::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::saveFile(const char *filename) { +bool BasePersistenceManager::saveFile(const char *filename) { return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { +bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); if (_saveStream->err()) return STATUS_FAILED; @@ -370,7 +370,7 @@ bool CBPersistMgr::putBytes(byte *buffer, uint32 size) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { +bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); if (_loadStream->err()) return STATUS_FAILED; @@ -378,20 +378,20 @@ bool CBPersistMgr::getBytes(byte *buffer, uint32 size) { } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putDWORD(uint32 val) { +void BasePersistenceManager::putDWORD(uint32 val) { _saveStream->writeUint32LE(val); } ////////////////////////////////////////////////////////////////////////// -uint32 CBPersistMgr::getDWORD() { +uint32 BasePersistenceManager::getDWORD() { uint32 ret = _loadStream->readUint32LE(); return ret; } ////////////////////////////////////////////////////////////////////////// -void CBPersistMgr::putString(const Common::String &val) { +void BasePersistenceManager::putString(const Common::String &val) { if (!val.size()) putString("(null)"); else { _saveStream->writeUint32LE(val.size()); @@ -399,7 +399,7 @@ void CBPersistMgr::putString(const Common::String &val) { } } -Common::String CBPersistMgr::getStringObj() { +Common::String BasePersistenceManager::getStringObj() { uint32 len = _loadStream->readUint32LE(); char *ret = new char[len + 1]; _loadStream->read(ret, len); @@ -416,7 +416,7 @@ Common::String CBPersistMgr::getStringObj() { } ////////////////////////////////////////////////////////////////////////// -char *CBPersistMgr::getString() { +char *BasePersistenceManager::getString() { uint32 len = _loadStream->readUint32LE(); char *ret = new char[len + 1]; _loadStream->read(ret, len); @@ -428,7 +428,7 @@ char *CBPersistMgr::getString() { } else return ret; } -bool CBPersistMgr::putTimeDate(const TimeDate &t) { +bool BasePersistenceManager::putTimeDate(const TimeDate &t) { _saveStream->writeSint32LE(t.tm_sec); _saveStream->writeSint32LE(t.tm_min); _saveStream->writeSint32LE(t.tm_hour); @@ -443,7 +443,7 @@ bool CBPersistMgr::putTimeDate(const TimeDate &t) { return STATUS_OK; } -TimeDate CBPersistMgr::getTimeDate() { +TimeDate BasePersistenceManager::getTimeDate() { TimeDate t; t.tm_sec = _loadStream->readSint32LE(); t.tm_min = _loadStream->readSint32LE(); @@ -455,13 +455,13 @@ TimeDate CBPersistMgr::getTimeDate() { return t; } -void CBPersistMgr::putFloat(float val) { +void BasePersistenceManager::putFloat(float val) { Common::String str = Common::String::format("F%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); } -float CBPersistMgr::getFloat() { +float BasePersistenceManager::getFloat() { char *str = getString(); float value = 0.0f; int ret = sscanf(str, "F%f", &value); @@ -472,14 +472,14 @@ float CBPersistMgr::getFloat() { return value; } -void CBPersistMgr::putDouble(double val) { +void BasePersistenceManager::putDouble(double val) { Common::String str = Common::String::format("F%f", val); str.format("D%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); } -double CBPersistMgr::getDouble() { +double BasePersistenceManager::getDouble() { char *str = getString(); double value = 0.0f; int ret = sscanf(str, "F%f", &value); @@ -492,7 +492,7 @@ double CBPersistMgr::getDouble() { ////////////////////////////////////////////////////////////////////////// // bool -bool CBPersistMgr::transfer(const char *name, bool *val) { +bool BasePersistenceManager::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -509,7 +509,7 @@ bool CBPersistMgr::transfer(const char *name, bool *val) { ////////////////////////////////////////////////////////////////////////// // int -bool CBPersistMgr::transfer(const char *name, int *val) { +bool BasePersistenceManager::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); if (_saveStream->err()) @@ -526,7 +526,7 @@ bool CBPersistMgr::transfer(const char *name, int *val) { ////////////////////////////////////////////////////////////////////////// // DWORD -bool CBPersistMgr::transfer(const char *name, uint32 *val) { +bool BasePersistenceManager::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); if (_saveStream->err()) @@ -543,7 +543,7 @@ bool CBPersistMgr::transfer(const char *name, uint32 *val) { ////////////////////////////////////////////////////////////////////////// // float -bool CBPersistMgr::transfer(const char *name, float *val) { +bool BasePersistenceManager::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); if (_saveStream->err()) @@ -560,7 +560,7 @@ bool CBPersistMgr::transfer(const char *name, float *val) { ////////////////////////////////////////////////////////////////////////// // double -bool CBPersistMgr::transfer(const char *name, double *val) { +bool BasePersistenceManager::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); if (_saveStream->err()) @@ -577,7 +577,7 @@ bool CBPersistMgr::transfer(const char *name, double *val) { ////////////////////////////////////////////////////////////////////////// // char* -bool CBPersistMgr::transfer(const char *name, char **val) { +bool BasePersistenceManager::transfer(const char *name, char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -594,7 +594,7 @@ bool CBPersistMgr::transfer(const char *name, char **val) { ////////////////////////////////////////////////////////////////////////// // const char* -bool CBPersistMgr::transfer(const char *name, const char **val) { +bool BasePersistenceManager::transfer(const char *name, const char **val) { if (_saving) { putString(*val); return STATUS_OK; @@ -611,7 +611,7 @@ bool CBPersistMgr::transfer(const char *name, const char **val) { ////////////////////////////////////////////////////////////////////////// // Common::String -bool CBPersistMgr::transfer(const char *name, Common::String *val) { +bool BasePersistenceManager::transfer(const char *name, Common::String *val) { if (_saving) { putString(*val); return STATUS_OK; @@ -632,7 +632,7 @@ bool CBPersistMgr::transfer(const char *name, Common::String *val) { } ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { +bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { size_t size; if (_saving) { @@ -662,7 +662,7 @@ bool CBPersistMgr::transfer(const char *name, AnsiStringArray &val) { ////////////////////////////////////////////////////////////////////////// // BYTE -bool CBPersistMgr::transfer(const char *name, byte *val) { +bool BasePersistenceManager::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); if (_saveStream->err()) @@ -679,7 +679,7 @@ bool CBPersistMgr::transfer(const char *name, byte *val) { ////////////////////////////////////////////////////////////////////////// // RECT -bool CBPersistMgr::transfer(const char *name, Rect32 *val) { +bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { if (_saving) { _saveStream->writeSint32LE(val->left); _saveStream->writeSint32LE(val->top); @@ -702,7 +702,7 @@ bool CBPersistMgr::transfer(const char *name, Rect32 *val) { ////////////////////////////////////////////////////////////////////////// // POINT -bool CBPersistMgr::transfer(const char *name, Point32 *val) { +bool BasePersistenceManager::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); @@ -721,7 +721,7 @@ bool CBPersistMgr::transfer(const char *name, Point32 *val) { ////////////////////////////////////////////////////////////////////////// // Vector2 -bool CBPersistMgr::transfer(const char *name, Vector2 *val) { +bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); @@ -740,11 +740,11 @@ bool CBPersistMgr::transfer(const char *name, Vector2 *val) { ////////////////////////////////////////////////////////////////////////// // generic pointer -bool CBPersistMgr::transfer(const char *name, void *val) { +bool BasePersistenceManager::transfer(const char *name, void *val) { int classID = -1, instanceID = -1; if (_saving) { - CSysClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { _gameRef->LOG(0, "Warning: invalid instance '%s'", name); } @@ -755,7 +755,7 @@ bool CBPersistMgr::transfer(const char *name, void *val) { classID = _loadStream->readUint32LE(); instanceID = _loadStream->readUint32LE(); - *(void **)val = CSysClassRegistry::getInstance()->idToPointer(classID, instanceID); + *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); } return STATUS_OK; @@ -763,7 +763,7 @@ bool CBPersistMgr::transfer(const char *name, void *val) { ////////////////////////////////////////////////////////////////////////// -bool CBPersistMgr::checkVersion(byte verMajor, byte verMinor, byte verBuild) { +bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { if (_saving) return true; // it's ok if we are same or newer than the saved game diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index f2fd42ceca..a400c612dc 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -42,7 +42,7 @@ namespace WinterMute { class Vector2; -class CBPersistMgr : public CBBase { +class BasePersistenceManager : public BaseClass { public: char *_savedDescription; TimeDate _savedTimestamp; @@ -94,8 +94,8 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - CBPersistMgr(CBGame *inGame = NULL, const char *savePrefix = NULL); - virtual ~CBPersistMgr(); + BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL); + virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); uint32 _thumbnailDataSize; diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index e878f34387..76d8d85c70 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -32,28 +32,28 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBPoint, false) +IMPLEMENT_PERSISTENT(BasePoint, false) ////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint() { +BasePoint::BasePoint() { x = y = 0; } ////////////////////////////////////////////////////////////////////////// -CBPoint::~CBPoint() { +BasePoint::~BasePoint() { } ////////////////////////////////////////////////////////////////////////// -CBPoint::CBPoint(int initX, int initY) { +BasePoint::BasePoint(int initX, int initY) { x = initX; y = initY; } ////////////////////////////////////////////////////////////////////////// -bool CBPoint::persist(CBPersistMgr *persistMgr) { +bool BasePoint::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(x)); persistMgr->transfer(TMEMBER(y)); diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 363ab1f919..35d310b8d9 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -34,14 +34,14 @@ namespace WinterMute { -class CBPoint: public CBBase { +class BasePoint: public BaseClass { public: - DECLARE_PERSISTENT(CBPoint, CBBase) - CBPoint(); - CBPoint(int initX, int initY); + DECLARE_PERSISTENT(BasePoint, BaseClass) + BasePoint(); + BasePoint(int initX, int initY); int y; int x; - virtual ~CBPoint(); + virtual ~BasePoint(); }; diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index ac1001a2fe..856a214f80 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { _text = new char [strlen(text) + 1]; if (_text) strcpy(_text, text); _startTime = _gameRef->_currentTime; @@ -41,13 +41,13 @@ CBQuickMsg::CBQuickMsg(CBGame *inGame, const char *text): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBQuickMsg::~CBQuickMsg() { +BaseQuickMsg::~BaseQuickMsg() { if (_text) delete [] _text; } ////////////////////////////////////////////////////////////////////////// -char *CBQuickMsg::getText() { +char *BaseQuickMsg::getText() { return _text; } diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index 9a68929932..f2f9144bc0 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -33,13 +33,13 @@ namespace WinterMute { -class CBQuickMsg : public CBBase { +class BaseQuickMsg : public BaseClass { public: char *getText(); uint32 _startTime; char *_text; - CBQuickMsg(CBGame *inGame, const char *Text); - virtual ~CBQuickMsg(); + BaseQuickMsg(BaseGame *inGame, const char *Text); + virtual ~BaseQuickMsg(); }; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 3e513f9fb8..e336b92789 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -40,43 +40,43 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBRegion, false) +IMPLEMENT_PERSISTENT(BaseRegion, false) ////////////////////////////////////////////////////////////////////////// -CBRegion::CBRegion(CBGame *inGame): CBObject(inGame) { +BaseRegion::BaseRegion(BaseGame *inGame): BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; _lastMimicX = _lastMimicY = INT_MIN; - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); } ////////////////////////////////////////////////////////////////////////// -CBRegion::~CBRegion() { +BaseRegion::~BaseRegion() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBRegion::cleanup() { +void BaseRegion::cleanup() { for (int i = 0; i < _points.getSize(); i++) delete _points[i]; _points.removeAll(); - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::createRegion() { +bool BaseRegion::createRegion() { return DID_SUCCEED(getBoundingRect(&_rect)); } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::pointInRegion(int x, int y) { +bool BaseRegion::pointInRegion(int x, int y) { if (_points.getSize() < 3) return false; Point32 pt; @@ -89,16 +89,16 @@ bool CBRegion::pointInRegion(int x, int y) { rect.top = y - 1; rect.bottom = y + 2; - if (CBPlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); + if (BasePlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); else return false; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadFile(const char *filename) { +bool BaseRegion::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBRegion::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -128,7 +128,7 @@ TOKEN_DEF(EDITOR_SELECTED_POINT) TOKEN_DEF(PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBRegion::loadBuffer(byte *buffer, bool complete) { +bool BaseRegion::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(REGION) TOKEN_TABLE(TEMPLATE) @@ -143,7 +143,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { @@ -179,7 +179,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { case TOKEN_POINT: { int x, y; parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); } break; @@ -210,7 +210,7 @@ bool CBRegion::loadBuffer(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // AddPoint @@ -220,7 +220,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - _points.add(new CBPoint(x, y)); + _points.add(new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -238,7 +238,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new CBPoint(x, y)); + _points.insertAt(Index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -295,7 +295,7 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt int index = stack->pop()->getInt(); if (index >= 0 && index < _points.getSize()) { - CScValue *val = stack->getPushValue(); + ScValue *val = stack->getPushValue(); if (val) { val->setProperty("X", _points[index]->x); val->setProperty("Y", _points[index]->y); @@ -305,12 +305,12 @@ bool CBRegion::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBRegion::scGetProperty(const char *name) { +ScValue *BaseRegion::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -345,12 +345,12 @@ CScValue *CBRegion::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::scSetProperty(const char *name, CScValue *value) { +bool BaseRegion::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// @@ -367,18 +367,18 @@ bool CBRegion::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBRegion::scToString() { +const char *BaseRegion::scToString() { return "[region]"; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride) { +bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); @@ -406,9 +406,9 @@ bool CBRegion::saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverr ////////////////////////////////////////////////////////////////////////// -bool CBRegion::persist(CBPersistMgr *persistMgr) { +bool BaseRegion::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_active)); persistMgr->transfer(TMEMBER(_editorSelectedPoint)); @@ -426,7 +426,7 @@ typedef struct { } dPoint; ////////////////////////////////////////////////////////////////////////// -bool CBRegion::ptInPolygon(int x, int y) { +bool BaseRegion::ptInPolygon(int x, int y) { if (_points.getSize() < 3) return false; int counter = 0; @@ -465,8 +465,8 @@ bool CBRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// -bool CBRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) CBPlatform::setRectEmpty(rect); +bool BaseRegion::getBoundingRect(Rect32 *rect) { + if (_points.getSize() == 0) BasePlatform::setRectEmpty(rect); else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; @@ -477,14 +477,14 @@ bool CBRegion::getBoundingRect(Rect32 *rect) { MaxX = MAX(MaxX, _points[i]->x); MaxY = MAX(MaxY, _points[i]->y); } - CBPlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + BasePlatform::setRect(rect, MinX, MinY, MaxX, MaxY); } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { +bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; cleanup(); @@ -495,7 +495,7 @@ bool CBRegion::mimic(CBRegion *region, float scale, int x, int y) { xVal = (int)((float)region->_points[i]->x * scale / 100.0f); yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - _points.add(new CBPoint(xVal + x, yVal + y)); + _points.add(new BasePoint(xVal + x, yVal + y)); } _lastMimicScale = scale; diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 0c35d99bd9..a15e0cca2a 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -34,32 +34,32 @@ namespace WinterMute { -class CBRegion : public CBObject { +class BaseRegion : public BaseObject { public: float _lastMimicScale; int _lastMimicX; int _lastMimicY; void cleanup(); - bool mimic(CBRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); bool getBoundingRect(Rect32 *rect); bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(CBRegion, CBObject) + DECLARE_PERSISTENT(BaseRegion, BaseObject) bool _active; int _editorSelectedPoint; - CBRegion(CBGame *inGame); - virtual ~CBRegion(); + BaseRegion(BaseGame *inGame); + virtual ~BaseRegion(); bool pointInRegion(int x, int y); bool createRegion(); bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; - CBArray _points; - virtual bool saveAsText(CBDynBuffer *buffer, int indent, const char *nameOverride = NULL); + BaseArray _points; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 350a34b61e..dfab1b5076 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { +BaseRegistry::BaseRegistry(BaseGame *inGame): BaseClass(inGame) { _iniName = NULL; setIniName("./wme.ini"); @@ -47,7 +47,7 @@ CBRegistry::CBRegistry(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBRegistry::~CBRegistry() { +BaseRegistry::~BaseRegistry() { saveValues(); delete[] _iniName; _iniName = NULL; @@ -56,7 +56,7 @@ CBRegistry::~CBRegistry() { ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { +AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { AnsiString ret = ""; bool found = false; @@ -69,14 +69,14 @@ AnsiString CBRegistry::readString(const AnsiString &subKey, const AnsiString &ke ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { +bool BaseRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { _values[subKey][key] = value; return true; } ////////////////////////////////////////////////////////////////////////// -int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { +int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { if (subKey == "Audio") { if (key == "MasterVolume") { if (ConfMan.hasKey("master_volume")) { @@ -111,7 +111,7 @@ int CBRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int ini ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { +bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { if (subKey == "Audio") { if (key == "MasterVolume") { ConfMan.setInt("master_volume", value); @@ -133,19 +133,19 @@ bool CBRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int v ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { +bool BaseRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { return (readInt(subKey, key, (int)init) != 0); } ////////////////////////////////////////////////////////////////////////// -bool CBRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { +bool BaseRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { return writeInt(subKey, key, (int)value); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::setIniName(const char *name) { +void BaseRegistry::setIniName(const char *name) { delete[] _iniName; _iniName = NULL; @@ -160,30 +160,30 @@ void CBRegistry::setIniName(const char *name) { ////////////////////////////////////////////////////////////////////////// -char *CBRegistry::getIniName() { +char *BaseRegistry::getIniName() { return _iniName; } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadValues(bool local) { +void BaseRegistry::loadValues(bool local) { if (local) loadXml("settings.xml", _localValues); else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveValues() { +void BaseRegistry::saveValues() { saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::setBasePath(const char *basePath) { +void BaseRegistry::setBasePath(const char *basePath) { _basePath = PathUtil::getFileNameWithoutExtension(basePath); loadValues(false); } ////////////////////////////////////////////////////////////////////////// -AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { +AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { found = false; PathValueMap::iterator it = values.find(path); if (it == values.end()) return ""; @@ -198,7 +198,7 @@ AnsiString CBRegistry::getValue(PathValueMap &values, const AnsiString path, con } ////////////////////////////////////////////////////////////////////////// -void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { +void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { TiXmlDocument doc(fileName.c_str()); if (!doc.LoadFile()) return; @@ -215,8 +215,8 @@ void CBRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { ////////////////////////////////////////////////////////////////////////// -void CBRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - CBUtils::createPath(fileName.c_str()); +void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { + BaseUtils::createPath(fileName.c_str()); TiXmlDocument doc; doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h index 06e052cd03..1d67c18e85 100644 --- a/engines/wintermute/base/base_registry.h +++ b/engines/wintermute/base/base_registry.h @@ -33,7 +33,7 @@ namespace WinterMute { -class CBRegistry : public CBBase { +class BaseRegistry : public BaseClass { public: void setIniName(const char *name); char *getIniName(); @@ -43,8 +43,8 @@ public: int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - CBRegistry(CBGame *inGame); - virtual ~CBRegistry(); + BaseRegistry(BaseGame *inGame); + virtual ~BaseRegistry(); void setBasePath(const char *basePath); AnsiString getBasePath() const { diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index bee63aa307..68cfb8a7ea 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -34,18 +34,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::CBSaveThumbHelper(CBGame *inGame): CBBase(inGame) { +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame): BaseClass(inGame) { _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// -CBSaveThumbHelper::~CBSaveThumbHelper(void) { +BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { delete _thumbnail; _thumbnail = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { +bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { delete _thumbnail; _thumbnail = NULL; @@ -60,12 +60,12 @@ bool CBSaveThumbHelper::storeThumbnail(bool doFlip) { _gameRef->_renderer->flip(); } - CBImage *screenshot = _gameRef->_renderer->takeScreenshot(); + BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); if (!screenshot) return STATUS_FAILED; // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new CBImage(_gameRef); + _thumbnail = new BaseImage(_gameRef); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index e8cdbdc00d..ef2615a668 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -33,16 +33,16 @@ namespace WinterMute { -class CBImage; +class BaseImage; -class CBSaveThumbHelper : public CBBase { +class BaseSaveThumbHelper : public BaseClass { public: - CBSaveThumbHelper(CBGame *inGame); - virtual ~CBSaveThumbHelper(void); + BaseSaveThumbHelper(BaseGame *inGame); + virtual ~BaseSaveThumbHelper(void); bool storeThumbnail(bool doFlip = false); - CBImage *_thumbnail; - CBImage *_richThumbnail; + BaseImage *_thumbnail; + BaseImage *_richThumbnail; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 5192f76f6e..f803a9191f 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -37,10 +37,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBScriptHolder, false) +IMPLEMENT_PERSISTENT(BaseScriptHolder, false) ////////////////////////////////////////////////////////////////////// -CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame): BaseScriptable(inGame) { setName(""); _freezable = true; @@ -49,13 +49,13 @@ CBScriptHolder::CBScriptHolder(CBGame *inGame): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////// -CBScriptHolder::~CBScriptHolder() { +BaseScriptHolder::~BaseScriptHolder() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::cleanup() { +bool BaseScriptHolder::cleanup() { delete[] _filename; _filename = NULL; @@ -71,7 +71,7 @@ bool CBScriptHolder::cleanup() { } ////////////////////////////////////////////////////////////////////// -void CBScriptHolder::setFilename(const char *filename) { +void BaseScriptHolder::setFilename(const char *filename) { if (_filename != NULL) delete [] _filename; _filename = new char [strlen(filename) + 1]; @@ -80,13 +80,13 @@ void CBScriptHolder::setFilename(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { +bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; bool ret = STATUS_FAILED; for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread) { - CScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { //_scripts.add(handler); numHandlers++; @@ -101,7 +101,7 @@ bool CBScriptHolder::applyEvent(const char *eventName, bool unbreakable) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { +bool BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { return STATUS_FAILED; } @@ -109,7 +109,7 @@ bool CBScriptHolder::listen(CBScriptHolder *param1, uint32 param2) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // DEBUG_CrashMe ////////////////////////////////////////////////////////////////////////// @@ -127,7 +127,7 @@ bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack * ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ApplyEvent") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); bool ret; ret = applyEvent(val->getString()); @@ -203,12 +203,12 @@ bool CBScriptHolder::scCallMethod(CScScript *script, CScStack *stack, CScStack * stack->pushBool(ret); return STATUS_OK; - } else return CBScriptable::scCallMethod(script, stack, thisStack, name); + } else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptHolder::scGetProperty(const char *name) { +ScValue *BaseScriptHolder::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -235,36 +235,36 @@ CScValue *CBScriptHolder::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::scSetProperty(const char *name, CScValue *value) { +bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Name") == 0) { setName(value->getString()); return STATUS_OK; - } else return CBScriptable::scSetProperty(name, value); + } else return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptHolder::scToString() { +const char *BaseScriptHolder::scToString() { return "[script_holder]"; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::saveAsText(CBDynBuffer *buffer, int indent) { - return CBBase::saveAsText(buffer, indent); +bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return BaseClass::saveAsText(buffer, indent); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); @@ -276,21 +276,21 @@ bool CBScriptHolder::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::addScript(const char *filename) { +bool BaseScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "CBScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); return STATUS_OK; } } } - CScScript *scr = _gameRef->_scEngine->runScript(filename, this); + ScScript *scr = _gameRef->_scEngine->runScript(filename, this); if (!scr) { if (_gameRef->_editorForceScripts) { // editor hack - scr = new CScScript(_gameRef, _gameRef->_scEngine); + scr = new ScScript(_gameRef, _gameRef->_scEngine); scr->_filename = new char[strlen(filename) + 1]; strcpy(scr->_filename, filename); scr->_state = SCRIPT_ERROR; @@ -311,7 +311,7 @@ bool CBScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::removeScript(CScScript *script) { +bool BaseScriptHolder::removeScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { _scripts.removeAt(i); @@ -322,7 +322,7 @@ bool CBScriptHolder::removeScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleEvent(const char *EventName) { +bool BaseScriptHolder::canHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; } @@ -331,7 +331,7 @@ bool CBScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::canHandleMethod(const char *MethodName) { +bool BaseScriptHolder::canHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; } @@ -345,7 +345,7 @@ TOKEN_DEF(NAME) TOKEN_DEF(VALUE) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { +bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { TOKEN_TABLE_START(commands) TOKEN_TABLE(PROPERTY) TOKEN_TABLE(NAME) @@ -354,7 +354,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { @@ -403,7 +403,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { } - CScValue *val = new CScValue(_gameRef); + ScValue *val = new ScValue(_gameRef); val->setString(propValue); scSetProperty(propName, val); @@ -418,7 +418,7 @@ bool CBScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::makeFreezable(bool freezable) { +void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->_freezable = freezable; @@ -427,11 +427,11 @@ void CBScriptHolder::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { +ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { for (int i = _scripts.getSize() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { - CScScript *thread = new CScScript(_gameRef, _scripts[i]->_engine); + ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); if (thread) { bool ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { @@ -450,7 +450,7 @@ CScScript *CBScriptHolder::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// -void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { +void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); if (_name && strcmp(_name, "") != 0) { strcat(buf, " Name: "); @@ -466,7 +466,7 @@ void CBScriptHolder::scDebuggerDesc(char *buf, int bufSize) { ////////////////////////////////////////////////////////////////////////// // IWmeObject ////////////////////////////////////////////////////////////////////////// -bool CBScriptHolder::sendEvent(const char *eventName) { +bool BaseScriptHolder::sendEvent(const char *eventName) { return DID_SUCCEED(applyEvent(eventName)); } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 0e5bc1b7ec..52711572c1 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -35,21 +35,21 @@ namespace WinterMute { -class CBScriptHolder : public CBScriptable { +class BaseScriptHolder : public BaseScriptable { public: - DECLARE_PERSISTENT(CBScriptHolder, CBScriptable) + DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) - CBScriptHolder(CBGame *inGame); - virtual ~CBScriptHolder(); - virtual CScScript *invokeMethodThread(const char *methodName); + BaseScriptHolder(BaseGame *inGame); + virtual ~BaseScriptHolder(); + virtual ScScript *invokeMethodThread(const char *methodName); virtual void makeFreezable(bool freezable); bool canHandleEvent(const char *eventName); virtual bool canHandleMethod(const char *eventMethod); bool cleanup(); - bool removeScript(CScScript *script); + bool removeScript(ScScript *script); bool addScript(const char *filename); - virtual bool saveAsText(CBDynBuffer *buffer, int indent); - virtual bool listen(CBScriptHolder *param1, uint32 param2); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); bool parseProperty(byte *buffer, bool complete = true); @@ -57,11 +57,11 @@ public: bool _freezable; bool _ready; - CBArray _scripts; + BaseArray _scripts; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index e9489fa407..6da67db3fb 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -33,14 +33,14 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBScriptable, false) +IMPLEMENT_PERSISTENT(BaseScriptable, false) ////////////////////////////////////////////////////////////////////////// -CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNamedObject(inGame) { +BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { _refCount = 0; if (noValue) _scValue = NULL; - else _scValue = new CScValue(_gameRef); + else _scValue = new ScValue(_gameRef); _persistable = persistable; @@ -49,7 +49,7 @@ CBScriptable::CBScriptable(CBGame *inGame, bool noValue, bool persistable): CBNa ////////////////////////////////////////////////////////////////////////// -CBScriptable::~CBScriptable() { +BaseScriptable::~BaseScriptable() { //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); delete _scValue; delete _scProp; @@ -61,7 +61,7 @@ CBScriptable::~CBScriptable() { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { /* stack->correctParams(0); stack->pushNULL(); @@ -74,72 +74,72 @@ bool CBScriptable::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// -CScValue *CBScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new CScValue(_gameRef); +ScValue *BaseScriptable::scGetProperty(const char *name) { + if (!_scProp) _scProp = new ScValue(_gameRef); if (_scProp) return _scProp->getProp(name); else return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scSetProperty(const char *name, CScValue *value) { - if (!_scProp) _scProp = new CScValue(_gameRef); +bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { + if (!_scProp) _scProp = new ScValue(_gameRef); if (_scProp) return _scProp->setProp(name, value); else return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::scToString() { +const char *BaseScriptable::scToString() { return "[native object]"; } ////////////////////////////////////////////////////////////////////////// -void *CBScriptable::scToMemBuffer() { +void *BaseScriptable::scToMemBuffer() { return (void *)NULL; } ////////////////////////////////////////////////////////////////////////// -int CBScriptable::scToInt() { +int BaseScriptable::scToInt() { return 0; } ////////////////////////////////////////////////////////////////////////// -double CBScriptable::scToFloat() { +double BaseScriptable::scToFloat() { return 0.0f; } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::scToBool() { +bool BaseScriptable::scToBool() { return false; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetString(const char *val) { +void BaseScriptable::scSetString(const char *val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetInt(int val) { +void BaseScriptable::scSetInt(int val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetFloat(double val) { +void BaseScriptable::scSetFloat(double val) { } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scSetBool(bool val) { +void BaseScriptable::scSetBool(bool val) { } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::persist(CBPersistMgr *persistMgr) { +bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_refCount)); persistMgr->transfer(TMEMBER(_scProp)); @@ -150,25 +150,25 @@ bool CBScriptable::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBScriptable::scCompare(CBScriptable *val) { +int BaseScriptable::scCompare(BaseScriptable *val) { if (this < val) return -1; else if (this > val) return 1; else return 0; } ////////////////////////////////////////////////////////////////////////// -void CBScriptable::scDebuggerDesc(char *buf, int bufSize) { +void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); } ////////////////////////////////////////////////////////////////////////// -bool CBScriptable::canHandleMethod(const char *eventMethod) { +bool BaseScriptable::canHandleMethod(const char *eventMethod) { return false; } ////////////////////////////////////////////////////////////////////////// -CScScript *CBScriptable::invokeMethodThread(const char *methodName) { +ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } @@ -176,12 +176,12 @@ CScScript *CBScriptable::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugObject ////////////////////////////////////////////////////////////////////////// -const char *CBScriptable::dbgGetNativeClass() { +const char *BaseScriptable::dbgGetNativeClass() { return getClassName(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *CBScriptable::dbgGetProperty(const char *name) { +IWmeDebugProp *BaseScriptable::dbgGetProperty(const char *name) { return scGetProperty(name); } diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 166f3c0bd1..b9283ed349 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -36,23 +36,23 @@ namespace WinterMute { -class CScValue; -class CScStack; -class CScScript; +class ScValue; +class ScStack; +class ScScript; -class CBScriptable : public CBNamedObject, public IWmeDebugObject { +class BaseScriptable : public BaseNamedObject, public IWmeDebugObject { public: - virtual CScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(CBScriptable, CBNamedObject) + virtual ScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) - CBScriptable(CBGame *inGame, bool noValue = false, bool persistable = true); - virtual ~CBScriptable(); + BaseScriptable(BaseGame *inGame, bool noValue = false, bool persistable = true); + virtual ~BaseScriptable(); // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); virtual int scToInt(); @@ -62,11 +62,11 @@ public: virtual void scSetInt(int val); virtual void scSetFloat(double val); virtual void scSetBool(bool val); - virtual int scCompare(CBScriptable *val); + virtual int scCompare(BaseScriptable *val); virtual void scDebuggerDesc(char *buf, int bufSize); int _refCount; - CScValue *_scValue; - CScValue *_scProp; + ScValue *_scValue; + ScValue *_scProp; public: // IWmeDebugObject @@ -76,14 +76,14 @@ public: }; // Implemented in their respective .cpp-files -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXMath(CBGame *inGame); -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack); -CBScriptable *makeSXStore(CBGame *inGame); -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack); +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXMath(BaseGame *inGame); +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXStore(BaseGame *inGame); +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index ba55d1b88b..046a40bacf 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -45,10 +45,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSprite, false) +IMPLEMENT_PERSISTENT(BaseSprite, false) ////////////////////////////////////////////////////////////////////// -CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner): BaseScriptHolder(inGame) { _editorAllFrames = false; _owner = Owner; setDefaults(); @@ -56,13 +56,13 @@ CBSprite::CBSprite(CBGame *inGame, CBObject *Owner): CBScriptHolder(inGame) { ////////////////////////////////////////////////////////////////////// -CBSprite::~CBSprite() { +BaseSprite::~BaseSprite() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CBSprite::setDefaults() { +void BaseSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; @@ -87,8 +87,8 @@ void CBSprite::setDefaults() { ////////////////////////////////////////////////////////////////////////// -void CBSprite::cleanup() { - CBScriptHolder::cleanup(); +void BaseSprite::cleanup() { + BaseScriptHolder::cleanup(); for (int i = 0; i < _frames.getSize(); i++) delete _frames[i]; @@ -102,7 +102,7 @@ void CBSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// -bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { +bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; @@ -122,10 +122,10 @@ bool CBSprite::draw(int x, int y, CBObject *registerOwner, float zoomX, float zo ////////////////////////////////////////////////////////////////////// -bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { - _gameRef->LOG(0, "CBSprite::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); else return loadFile("invalid.bmp", lifeTime, cacheType); } else { @@ -137,8 +137,8 @@ bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cac AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { - CBFrame *frame = new CBFrame(_gameRef); - CBSubFrame *subframe = new CBSubFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); @@ -146,7 +146,7 @@ bool CBSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cac delete frame; delete subframe; } else { - CBPlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + BasePlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); frame->_subframes.add(subframe); _frames.add(frame); _currentFrame = 0; @@ -187,7 +187,7 @@ TOKEN_DEF(EDITOR_BG_ALPHA) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { TOKEN_TABLE_START(commands) TOKEN_TABLE(CONTINUOUS) TOKEN_TABLE(SPRITE) @@ -208,7 +208,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach byte *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); cleanup(); @@ -222,7 +222,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach } int frameCount = 1; - CBFrame *frame; + BaseFrame *frame; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_CONTINUOUS: @@ -287,7 +287,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach int FrameLifeTime = lifeTime; if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; - frame = new CBFrame(_gameRef); + frame = new BaseFrame(_gameRef); if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { delete frame; @@ -318,7 +318,7 @@ bool CBSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCach ////////////////////////////////////////////////////////////////////// -void CBSprite::reset() { +void BaseSprite::reset() { if (_frames.getSize() > 0) _currentFrame = 0; else _currentFrame = -1; @@ -331,7 +331,7 @@ void CBSprite::reset() { ////////////////////////////////////////////////////////////////////// -bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { +bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; @@ -383,7 +383,7 @@ bool CBSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; // on change... @@ -401,34 +401,34 @@ bool CBSprite::display(int X, int Y, CBObject *Register, float ZoomX, float Zoom ////////////////////////////////////////////////////////////////////////// -CBSurface *CBSprite::getSurface() { +BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - CBFrame *Frame = _frames[_currentFrame]; + BaseFrame *Frame = _frames[_currentFrame]; if (Frame && Frame->_subframes.getSize() > 0) { - CBSubFrame *Subframe = Frame->_subframes[0]; + BaseSubFrame *Subframe = Frame->_subframes[0]; if (Subframe) return Subframe->_surface; else return NULL; } else return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; - CBPlatform::setRectEmpty(rect); + BasePlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { Rect32 frame; Rect32 temp; - CBPlatform::copyRect(&temp, rect); + BasePlatform::copyRect(&temp, rect); _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - CBPlatform::unionRect(rect, &temp, &frame); + BasePlatform::unionRect(rect, &temp, &frame); } return true; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { +bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); @@ -451,7 +451,7 @@ bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); } - CBScriptHolder::saveAsText(buffer, indent + 2); + BaseScriptHolder::saveAsText(buffer, indent + 2); int i; @@ -472,8 +472,8 @@ bool CBSprite::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// -bool CBSprite::persist(CBPersistMgr *persistMgr) { - CBScriptHolder::persist(persistMgr); +bool BaseSprite::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); persistMgr->transfer(TMEMBER(_canBreak)); persistMgr->transfer(TMEMBER(_changed)); @@ -507,7 +507,7 @@ bool CBSprite::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetFrame ////////////////////////////////////////////////////////////////////////// @@ -526,14 +526,14 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteFrame") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (Val->isInt()) { int Index = Val->getInt(-1); if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); } } else { - CBFrame *Frame = (CBFrame *)Val->getNative(); + BaseFrame *Frame = (BaseFrame *)Val->getNative(); for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i] == Frame) { if (i == _currentFrame) _lastFrameTime = 0; @@ -562,13 +562,13 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AddFrame") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.add(sub); @@ -589,14 +589,14 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt if (index < 0) index = 0; - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); const char *filename = NULL; if (!val->isNULL()) filename = val->getString(); - CBFrame *frame = new CBFrame(_gameRef); + BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { - CBSubFrame *sub = new CBSubFrame(_gameRef); + BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); else delete sub; } @@ -629,12 +629,12 @@ bool CBSprite::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt return STATUS_OK; } - else return CBScriptHolder::scCallMethod(script, stack, thisStack, name); + else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSprite::scGetProperty(const char *name) { +ScValue *BaseSprite::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -702,12 +702,12 @@ CScValue *CBSprite::scGetProperty(const char *name) { return _scValue; } - else return CBScriptHolder::scGetProperty(name); + else return BaseScriptHolder::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::scSetProperty(const char *name, CScValue *value) { +bool BaseSprite::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// @@ -736,18 +736,18 @@ bool CBSprite::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptHolder::scSetProperty(name, value); + else return BaseScriptHolder::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSprite::scToString() { +const char *BaseSprite::scToString() { return "[sprite]"; } ////////////////////////////////////////////////////////////////////////// -bool CBSprite::killAllSounds() { +bool BaseSprite::killAllSounds() { for (int i = 0; i < _frames.getSize(); i++) { if (_frames[i]->_sound) _frames[i]->_sound->stop(); diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 8f3ce84eb4..6ddec287d6 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -34,13 +34,13 @@ #include "engines/wintermute/base/base_script_holder.h" namespace WinterMute { -class CBFrame; -class CBSurface; -class CBObject; -class CBSprite: public CBScriptHolder { +class BaseFrame; +class BaseSurface; +class BaseObject; +class BaseSprite: public BaseScriptHolder { public: bool killAllSounds(); - CBSurface *getSurface(); + BaseSurface *getSurface(); char *_editorBgFile; int _editorBgOffsetX; int _editorBgOffsetY; @@ -50,38 +50,38 @@ public: void cleanup(); void setDefaults(); bool _precise; - DECLARE_PERSISTENT(CBSprite, CBScriptHolder) + DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) bool _editorAllFrames; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; - bool display(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; bool _continuous; void reset(); - CBObject *_owner; + BaseObject *_owner; bool _changed; bool _paused; bool _finished; bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; - bool draw(int x, int y, CBObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - CBSprite(CBGame *inGame, CBObject *owner = NULL); - virtual ~CBSprite(); - CBArray _frames; - bool saveAsText(CBDynBuffer *buffer, int indent); + BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); + virtual ~BaseSprite(); + BaseArray _frames; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index c7789add9d..7ac79d4745 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -36,13 +36,13 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBStringTable::CBStringTable(CBGame *inGame): CBBase(inGame) { +BaseStringTable::BaseStringTable(BaseGame *inGame): BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBStringTable::~CBStringTable() { +BaseStringTable::~BaseStringTable() { // delete strings _strings.clear(); @@ -50,7 +50,7 @@ CBStringTable::~CBStringTable() { ////////////////////////////////////////////////////////////////////////// -bool CBStringTable::addString(const char *key, const char *val, bool reportDuplicities) { +bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { if (key == NULL || val == NULL) return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { @@ -70,7 +70,7 @@ bool CBStringTable::addString(const char *key, const char *val, bool reportDupli } ////////////////////////////////////////////////////////////////////////// -char *CBStringTable::getKey(const char *str) { +char *BaseStringTable::getKey(const char *str) { if (str == NULL || str[0] != '/') return NULL; const char *value = strchr(str + 1, '/'); @@ -79,7 +79,7 @@ char *CBStringTable::getKey(const char *str) { char *key = new char[value - str]; strncpy(key, str + 1, value - str - 1); key[value - str - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); char *new_str; @@ -102,7 +102,7 @@ char *CBStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void CBStringTable::expand(char **str, bool forceExpand) { +void BaseStringTable::expand(char **str, bool forceExpand) { if (_gameRef->_doNotExpandStrings && !forceExpand) return; if (str == NULL || *str == NULL || *str[0] != '/') return; @@ -113,7 +113,7 @@ void CBStringTable::expand(char **str, bool forceExpand) { char *key = new char[value - *str]; strncpy(key, *str + 1, value - *str - 1); key[value - *str - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); value++; @@ -137,7 +137,7 @@ void CBStringTable::expand(char **str, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { +const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) { if (_gameRef->_doNotExpandStrings && !forceExpand) return string; if (string == NULL || string[0] == '\0' || string[0] != '/') return string; @@ -148,7 +148,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { char *key = new char[value - string]; strncpy(key, string + 1, value - string - 1); key[value - string - 1] = '\0'; - CBPlatform::strlwr(key); + BasePlatform::strlwr(key); value++; @@ -169,7 +169,7 @@ const char *CBStringTable::expandStatic(const char *string, bool forceExpand) { ////////////////////////////////////////////////////////////////////////// -bool CBStringTable::loadFile(const char *filename, bool clearOld) { +bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); if (clearOld) _strings.clear(); @@ -177,7 +177,7 @@ bool CBStringTable::loadFile(const char *filename, bool clearOld) { uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (buffer == NULL) { - _gameRef->LOG(0, "CBStringTable::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index c612c33a41..ac46aaee43 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -35,14 +35,14 @@ namespace WinterMute { -class CBStringTable : public CBBase { +class BaseStringTable : public BaseClass { public: const char *expandStatic(const char *string, bool forceExpand = false); bool loadFile(const char *filename, bool deleteAll = true); void expand(char **str, bool forceExpand = false); bool addString(const char *key, const char *val, bool reportDuplicities = true); - CBStringTable(CBGame *inGame); - virtual ~CBStringTable(); + BaseStringTable(BaseGame *inGame); + virtual ~BaseStringTable(); Common::HashMap _strings; char *getKey(const char *str); private: diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index adce6c6b75..d6a8c2490f 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -40,16 +40,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSubFrame, false) +IMPLEMENT_PERSISTENT(BaseSubFrame, false) ////////////////////////////////////////////////////////////////////////// -CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { +BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { _surface = NULL; _hotspotX = _hotspotY = 0; _alpha = 0xFFFFFFFF; _transparent = 0xFFFF00FF; - CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRectEmpty(&_rect); _editorSelected = false; @@ -67,7 +67,7 @@ CBSubFrame::CBSubFrame(CBGame *inGame): CBScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// -CBSubFrame::~CBSubFrame() { +BaseSubFrame::~BaseSubFrame() { if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); delete[] _surfaceFilename; _surfaceFilename = NULL; @@ -90,7 +90,7 @@ TOKEN_DEF(EDITOR_SELECTED) TOKEN_DEF(EDITOR_PROPERTY) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { TOKEN_TABLE_START(commands) TOKEN_TABLE(IMAGE) TOKEN_TABLE(TRANSPARENT) @@ -109,12 +109,12 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; bool custoTrans = false; - CBPlatform::setRectEmpty(&rect); + BasePlatform::setRectEmpty(&rect); char *surfaceFile = NULL; delete _surface; @@ -196,7 +196,7 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } */ - if (CBPlatform::isRectEmpty(&rect)) setDefaultRect(); + if (BasePlatform::isRectEmpty(&rect)) setDefaultRect(); else _rect = rect; return STATUS_OK; @@ -204,14 +204,14 @@ bool CBSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////// -bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { +bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (!_surface) return STATUS_OK; if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->_rectList.add(new CBActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) return STATUS_OK; @@ -233,13 +233,13 @@ bool CBSubFrame::draw(int x, int y, CBObject *registerOwner, float zoomX, float ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { +bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { if (!rect) return false; float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; - CBPlatform::setRect(rect, + BasePlatform::setRect(rect, (int)(x - _hotspotX * ratioX), (int)(y - _hotspotY * ratioY), (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), @@ -249,7 +249,7 @@ bool CBSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { +bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { if (complete) buffer->putTextIndent(indent, "SUBFRAME {\n"); @@ -260,9 +260,9 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); Rect32 rect; - CBPlatform::setRectEmpty(&rect); - if (_surface) CBPlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!CBPlatform::equalRect(&rect, &_rect)) + BasePlatform::setRectEmpty(&rect); + if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + if (!BasePlatform::equalRect(&rect, &_rect)) buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) @@ -291,7 +291,7 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { if (_editorSelected) buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - CBBase::saveAsText(buffer, indent + 2); + BaseClass::saveAsText(buffer, indent + 2); if (complete) @@ -302,17 +302,17 @@ bool CBSubFrame::saveAsText(CBDynBuffer *buffer, int indent, bool complete) { ////////////////////////////////////////////////////////////////////////// -void CBSubFrame::setDefaultRect() { +void BaseSubFrame::setDefaultRect() { if (_surface) { - CBPlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else CBPlatform::setRectEmpty(&_rect); + BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } else BasePlatform::setRectEmpty(&_rect); } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::persist(CBPersistMgr *persistMgr) { +bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); @@ -342,7 +342,7 @@ bool CBSubFrame::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetImage @@ -360,7 +360,7 @@ bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); if (Val->isNULL()) { if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); @@ -378,13 +378,13 @@ bool CBSubFrame::scCallMethod(CScScript *script, CScStack *stack, CScStack *this return STATUS_OK; } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CBSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new CScValue(_gameRef); +ScValue *BaseSubFrame::scGetProperty(const char *name) { + if (!_scValue) _scValue = new ScValue(_gameRef); _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -468,12 +468,12 @@ CScValue *CBSubFrame::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { +bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// @@ -538,18 +538,18 @@ bool CBSubFrame::scSetProperty(const char *name, CScValue *value) { return STATUS_OK; } - else return CBScriptable::scSetProperty(name, value); + else return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CBSubFrame::scToString() { +const char *BaseSubFrame::scToString() { return "[subframe]"; } ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -576,7 +576,7 @@ bool CBSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, by ////////////////////////////////////////////////////////////////////////// -bool CBSubFrame::setSurfaceSimple() { +bool BaseSubFrame::setSurfaceSimple() { if (!_surfaceFilename) { _surface = NULL; return STATUS_OK; diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 6fb24c0e4f..52b1d76c01 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -34,25 +34,25 @@ #include "engines/wintermute/base/base_scriptable.h" namespace WinterMute { -class CBObject; -class CBSurface; -class CBSubFrame : public CBScriptable { +class BaseObject; +class BaseSurface; +class BaseSubFrame : public BaseScriptable { public: bool _mirrorX; bool _mirrorY; bool _decoration; bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool setSurfaceSimple(); - DECLARE_PERSISTENT(CBSubFrame, CBScriptable) + DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) void setDefaultRect(); uint32 _transparent; - bool saveAsText(CBDynBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(CBDynBuffer *buffer, int indent, bool complete); + bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); bool _editorSelected; - CBSubFrame(CBGame *inGame); - virtual ~CBSubFrame(); + BaseSubFrame(BaseGame *inGame); + virtual ~BaseSubFrame(); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, CBObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _hotspotX; @@ -71,12 +71,12 @@ public: bool _2DOnly; bool _3DOnly; - CBSurface *_surface; + BaseSurface *_surface; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); }; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 06c2f1b0cc..7067c2a607 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -36,24 +36,24 @@ namespace WinterMute { -//IMPLEMENT_PERSISTENT(CBSurfaceStorage, true); +//IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); ////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::CBSurfaceStorage(CBGame *inGame): CBBase(inGame) { +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame): BaseClass(inGame) { _lastCleanupTime = 0; } ////////////////////////////////////////////////////////////////////// -CBSurfaceStorage::~CBSurfaceStorage() { +BaseSurfaceStorage::~BaseSurfaceStorage() { cleanup(true); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::cleanup(bool warn) { +bool BaseSurfaceStorage::cleanup(bool warn) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "CBSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + if (warn) _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); delete _surfaces[i]; } _surfaces.clear(); @@ -63,7 +63,7 @@ bool CBSurfaceStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::initLoop() { +bool BaseSurfaceStorage::initLoop() { if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); @@ -81,7 +81,7 @@ bool CBSurfaceStorage::initLoop() { ////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::removeSurface(CBSurface *surface) { +bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { for (uint32 i = 0; i < _surfaces.size(); i++) { if (_surfaces[i] == surface) { _surfaces[i]->_referenceCount--; @@ -97,7 +97,7 @@ bool CBSurfaceStorage::removeSurface(CBSurface *surface) { ////////////////////////////////////////////////////////////////////// -CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (uint32 i = 0; i < _surfaces.size(); i++) { if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { _surfaces[i]->_referenceCount++; @@ -113,7 +113,7 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); } - CBSurface *surface; + BaseSurface *surface; surface = _gameRef->_renderer->createSurface(); if (!surface) return NULL; @@ -130,12 +130,12 @@ CBSurface *CBSurfaceStorage::addSurface(const char *filename, bool defaultCK, by ////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::restoreAll() { +bool BaseSurfaceStorage::restoreAll() { bool ret; for (uint32 i = 0; i < _surfaces.size(); i++) { ret = _surfaces[i]->restore(); if (ret != STATUS_OK) { - _gameRef->LOG(0, "CBSurfaceStorage::RestoreAll failed"); + _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); return ret; } } @@ -145,7 +145,7 @@ bool CBSurfaceStorage::restoreAll() { /* ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) +bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { if(!persistMgr->_saving) cleanup(false); @@ -160,16 +160,16 @@ bool CBSurfaceStorage::persist(CBPersistMgr *persistMgr) ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(CBSurface *), surfaceSortCB); +bool BaseSurfaceStorage::sortSurfaces() { + qsort(&_surfaces[0], _surfaces.size(), sizeof(BaseSurface *), surfaceSortCB); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CBSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - CBSurface *s1 = *((CBSurface **)arg1); - CBSurface *s2 = *((CBSurface **)arg2); +int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + BaseSurface *s1 = *((BaseSurface **)arg1); + BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 58f25e6875..350210b95e 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -33,23 +33,23 @@ #include "common/array.h" namespace WinterMute { -class CBSurface; -class CBSurfaceStorage : public CBBase { +class BaseSurface; +class BaseSurfaceStorage : public BaseClass { public: uint32 _lastCleanupTime; bool initLoop(); bool sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); bool cleanup(bool Warn = false); - //DECLARE_PERSISTENT(CBSurfaceStorage, CBBase); + //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); - CBSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(CBSurface *surface); - CBSurfaceStorage(CBGame *inGame); - virtual ~CBSurfaceStorage(); + BaseSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(BaseSurface *surface); + BaseSurfaceStorage(BaseGame *inGame); + virtual ~BaseSurfaceStorage(); - Common::Array _surfaces; + Common::Array _surfaces; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 30a1a32e6a..b524636af7 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame): BaseClass(inGame) { _state = TRANS_MGR_READY; _type = TRANSITION_NONE; _origInteractive = false; @@ -46,19 +46,19 @@ CBTransitionMgr::CBTransitionMgr(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBTransitionMgr::~CBTransitionMgr() { +BaseTransitionMgr::~BaseTransitionMgr() { } ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::isReady() { +bool BaseTransitionMgr::isReady() { return (_state == TRANS_MGR_READY); } ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { +bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { if (_state != TRANS_MGR_READY) return STATUS_OK; if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { @@ -83,12 +83,12 @@ bool CBTransitionMgr::start(TTransitionType type, bool nonInteractive) { #define FADE_DURATION 200 ////////////////////////////////////////////////////////////////////////// -bool CBTransitionMgr::update() { +bool BaseTransitionMgr::update() { if (isReady()) return STATUS_OK; if (!_started) { _started = true; - _lastTime = CBPlatform::getTime(); + _lastTime = BasePlatform::getTime(); } switch (_type) { @@ -97,7 +97,7 @@ bool CBTransitionMgr::update() { break; case TRANSITION_FADE_OUT: { - uint32 time = CBPlatform::getTime() - _lastTime; + uint32 time = BasePlatform::getTime() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -108,7 +108,7 @@ bool CBTransitionMgr::update() { break; case TRANSITION_FADE_IN: { - uint32 time = CBPlatform::getTime() - _lastTime; + uint32 time = BasePlatform::getTime() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -118,7 +118,7 @@ bool CBTransitionMgr::update() { } break; default: - error("CBTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + error("BaseTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); } if (isReady()) { diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 9b84c653e9..104f327fb8 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -33,7 +33,7 @@ namespace WinterMute { -class CBTransitionMgr : public CBBase { +class BaseTransitionMgr : public BaseClass { public: bool _started; uint32 _lastTime; @@ -43,8 +43,8 @@ public: bool start(TTransitionType type, bool nonInteractive = false); bool isReady(); TTransMgrState _state; - CBTransitionMgr(CBGame *inGame); - virtual ~CBTransitionMgr(); + BaseTransitionMgr(BaseGame *inGame); + virtual ~BaseTransitionMgr(); TTransitionType _type; }; diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index 83cbc5b0f0..ad875ec00d 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -32,24 +32,24 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBViewport, false) +IMPLEMENT_PERSISTENT(BaseViewport, false) ////////////////////////////////////////////////////////////////////////// -CBViewport::CBViewport(CBGame *inGame): CBBase(inGame) { - CBPlatform::setRectEmpty(&_rect); +BaseViewport::BaseViewport(BaseGame *inGame): BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); _mainObject = NULL; _offsetX = _offsetY = 0; } ////////////////////////////////////////////////////////////////////////// -CBViewport::~CBViewport() { +BaseViewport::~BaseViewport() { } ////////////////////////////////////////////////////////////////////////// -bool CBViewport::persist(CBPersistMgr *persistMgr) { +bool BaseViewport::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -63,7 +63,7 @@ bool CBViewport::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { +bool BaseViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { if (!noCheck) { left = MAX(left, 0); top = MAX(top, 0); @@ -71,7 +71,7 @@ bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) bottom = MIN(bottom, _gameRef->_renderer->_height); } - CBPlatform::setRect(&_rect, left, top, right, bottom); + BasePlatform::setRect(&_rect, left, top, right, bottom); _offsetX = left; _offsetY = top; return STATUS_OK; @@ -79,19 +79,19 @@ bool CBViewport::setRect(int left, int top, int right, int bottom, bool noCheck) ////////////////////////////////////////////////////////////////////////// -Rect32 *CBViewport::getRect() { +Rect32 *BaseViewport::getRect() { return &_rect; } ////////////////////////////////////////////////////////////////////////// -int CBViewport::getWidth() { +int BaseViewport::getWidth() { return _rect.right - _rect.left; } ////////////////////////////////////////////////////////////////////////// -int CBViewport::getHeight() { +int BaseViewport::getHeight() { return _rect.bottom - _rect.top; } diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 795e6f404f..33e9448082 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -33,19 +33,19 @@ #include "engines/wintermute/base/base.h" namespace WinterMute { -class CBObject; -class CBViewport : public CBBase { +class BaseObject; +class BaseViewport : public BaseClass { public: int getHeight(); int getWidth(); Rect32 *getRect(); bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(CBViewport, CBBase) + DECLARE_PERSISTENT(BaseViewport, BaseClass) int _offsetY; int _offsetX; - CBObject *_mainObject; - CBViewport(CBGame *inGame = NULL); - virtual ~CBViewport(); + BaseObject *_mainObject; + BaseViewport(BaseGame *inGame = NULL); + virtual ~BaseViewport(); private: Rect32 _rect; }; diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 3acde9c1ff..5e1ebc5922 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -39,6 +39,9 @@ namespace WinterMute { +// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size +// as such it is not renamed to follow the convention of the rest of the files. + // HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. class CBPkgFile : public Common::SeekableReadStream { uint32 _size; @@ -65,8 +68,8 @@ public: } }; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager) { - CBFileEntry *fileEntry; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager) { + BaseFileEntry *fileEntry; Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH_LENGTH]; strcpy(fileName, filename.c_str()); diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h index 4356ae5519..ca1b1f837d 100644 --- a/engines/wintermute/base/file/BPkgFile.h +++ b/engines/wintermute/base/file/BPkgFile.h @@ -41,8 +41,8 @@ class File; namespace WinterMute { -class CBFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, CBFileManager *fileManager); +class BaseFileManager; +Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 99bf9cff3f..6c89fc22f1 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -45,7 +45,7 @@ void correctSlashes(char *fileName) { } } -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager) { +Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 23e1a0a315..e688a12b50 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -35,7 +35,7 @@ class SeekableReadStream; namespace WinterMute { -Common::SeekableReadStream *openDiskFile(const Common::String &filename, CBFileManager *fileManager); +Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 88a64cb147..d4109bb259 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -38,24 +38,24 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBFile::CBFile(CBGame *inGame): CBBase(inGame) { +BaseFile::BaseFile(BaseGame *inGame): BaseClass(inGame) { _pos = 0; _size = 0; } ////////////////////////////////////////////////////////////////////////// -CBFile::~CBFile() { +BaseFile::~BaseFile() { } ////////////////////////////////////////////////////////////////////////// -bool CBFile::isEOF() { +bool BaseFile::isEOF() { return _pos == _size; } -Common::SeekableReadStream *CBFile::getMemStream() { +Common::SeekableReadStream *BaseFile::getMemStream() { uint32 oldPos = getPos(); seek(0); byte *data = new byte[getSize()]; diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index b29fc41299..1a144414fc 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -40,7 +40,7 @@ class SeekableReadStream; namespace WinterMute { -class CBFile : public CBBase { +class BaseFile : public BaseClass { protected: uint32 _pos; uint32 _size; @@ -56,8 +56,8 @@ public: virtual bool close() = 0; virtual bool open(const Common::String &filename) = 0; virtual bool isEOF(); - CBFile(CBGame *inGame); - virtual ~CBFile(); + BaseFile(BaseGame *inGame); + virtual ~BaseFile(); // Temporary solution to allow usage in ScummVM-code: virtual Common::SeekableReadStream *getMemStream(); }; diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 3b6f4c7c16..d3e0fee7b0 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -31,7 +31,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { +BaseFileEntry::BaseFileEntry(BaseGame *inGame): BaseClass(inGame) { _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; @@ -43,7 +43,7 @@ CBFileEntry::CBFileEntry(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBFileEntry::~CBFileEntry() { +BaseFileEntry::~BaseFileEntry() { _package = NULL; // ref only } diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index ed80821004..0e0375e42d 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -34,9 +34,9 @@ namespace WinterMute { -class CBPackage; +class BasePackage; -class CBFileEntry : public CBBase { +class BaseFileEntry : public BaseClass { public: uint32 _timeDate2; uint32 _timeDate1; @@ -46,9 +46,9 @@ public: uint32 _compressedLength; uint32 _length; uint32 _offset; - CBPackage *_package; - CBFileEntry(CBGame *inGame); - virtual ~CBFileEntry(); + BasePackage *_package; + BaseFileEntry(BaseGame *inGame); + virtual ~BaseFileEntry(); }; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index fab6409c00..03a80f3d8d 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { +BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { _file = NULL; _name = NULL; _cD = 0; @@ -50,14 +50,14 @@ CBPackage::CBPackage(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBPackage::~CBPackage() { +BasePackage::~BasePackage() { if (_name) delete [] _name; closeFilePointer(_file); } ////////////////////////////////////////////////////////////////////////// -bool CBPackage::open() { +bool BasePackage::open() { if (_file) return STATUS_OK; else { _file = getFilePointer(); @@ -67,7 +67,7 @@ bool CBPackage::open() { ////////////////////////////////////////////////////////////////////////// -bool CBPackage::close() { +bool BasePackage::close() { delete _file; _file = NULL; return STATUS_OK; @@ -75,7 +75,7 @@ bool CBPackage::close() { ////////////////////////////////////////////////////////////////////////// -bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { +bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { bool ret; if (DID_FAIL(ret = open())) return ret; else { @@ -86,7 +86,7 @@ bool CBPackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buff } ////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *CBPackage::getFilePointer() { +Common::SeekableReadStream *BasePackage::getFilePointer() { Common::File *file = _gameRef->_fileManager->openPackage(_name); if (!file) { _gameRef->_fileManager->requestCD(_cD, _name, ""); @@ -96,7 +96,7 @@ Common::SeekableReadStream *CBPackage::getFilePointer() { } ////////////////////////////////////////////////////////////////////////// -void CBPackage::closeFilePointer(Common::SeekableReadStream *&file) { +void BasePackage::closeFilePointer(Common::SeekableReadStream *&file) { delete file; file = NULL; } diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 52fc4f9677..bf45087f91 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -38,7 +38,7 @@ class SeekableReadStream; namespace WinterMute { -class CBPackage : public CBBase { +class BasePackage : public BaseClass { public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); @@ -51,8 +51,8 @@ public: char *_name; int _cD; Common::SeekableReadStream *_file; - CBPackage(CBGame *inGame); - virtual ~CBPackage(); + BasePackage(BaseGame *inGame); + virtual ~BasePackage(); }; diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 09cbae88fe..9b1c9fee04 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2806,7 +2806,7 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; -Common::SeekableReadStream *CBResources::getFile(const Common::String &fileName) { +Common::SeekableReadStream *BaseResources::getFile(const Common::String &fileName) { if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 6ec0541b5c..6316cecd15 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -34,7 +34,7 @@ namespace WinterMute { -class CBResources { +class BaseResources { public: static Common::SeekableReadStream *getFile(const Common::String &fileName); }; diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 68200d3fc6..a2295b70a5 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -39,19 +39,19 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::CBSaveThumbFile(CBGame *inGame): CBFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame): BaseFile(inGame) { _data = NULL; } ////////////////////////////////////////////////////////////////////////// -CBSaveThumbFile::~CBSaveThumbFile() { +BaseSaveThumbFile::~BaseSaveThumbFile() { close(); } ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::open(const Common::String &filename) { +bool BaseSaveThumbFile::open(const Common::String &filename) { close(); if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; @@ -71,7 +71,7 @@ bool CBSaveThumbFile::open(const Common::String &filename) { char slotFilename[MAX_PATH_LENGTH + 1]; _gameRef->getSaveSlotFilename(slot, slotFilename); - CBPersistMgr *pm = new CBPersistMgr(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; _gameRef->_debugAbsolutePathWarning = false; @@ -97,7 +97,7 @@ bool CBSaveThumbFile::open(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::close() { +bool BaseSaveThumbFile::close() { delete[] _data; _data = NULL; @@ -109,7 +109,7 @@ bool CBSaveThumbFile::close() { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::read(void *buffer, uint32 size) { +bool BaseSaveThumbFile::read(void *buffer, uint32 size) { if (!_data || _pos + size > _size) return STATUS_FAILED; memcpy(buffer, (byte *)_data + _pos, size); @@ -120,7 +120,7 @@ bool CBSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// -bool CBSaveThumbFile::seek(uint32 pos, int whence) { +bool BaseSaveThumbFile::seek(uint32 pos, int whence) { if (!_data) return STATUS_FAILED; uint32 newPos = 0; diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 42566581e2..6065f10f81 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -35,10 +35,10 @@ namespace WinterMute { //TODO: Get rid of this -class CBSaveThumbFile : public CBFile { +class BaseSaveThumbFile : public BaseFile { public: - CBSaveThumbFile(CBGame *Game); - virtual ~CBSaveThumbFile(); + BaseSaveThumbFile(BaseGame *Game); + virtual ~BaseSaveThumbFile(); virtual bool seek(uint32 pos, int whence = SEEK_SET); virtual bool read(void *buffer, uint32 size); virtual bool close(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 8976cfdabd..0c86517fc7 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -40,42 +40,42 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFont, false) +IMPLEMENT_PERSISTENT(BaseFont, false) ////////////////////////////////////////////////////////////////////// -CBFont::CBFont(CBGame *inGame): CBObject(inGame) { +BaseFont::BaseFont(BaseGame *inGame): BaseObject(inGame) { } ////////////////////////////////////////////////////////////////////// -CBFont::~CBFont() { +BaseFont::~BaseFont() { } ////////////////////////////////////////////////////////////////////// -void CBFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextHeight(byte *text, int width) { +int BaseFont::getTextHeight(byte *text, int width) { return 0; } ////////////////////////////////////////////////////////////////////// -int CBFont::getTextWidth(byte *text, int maxLength) { +int BaseFont::getTextWidth(byte *text, int maxLength) { return 0; } /* ////////////////////////////////////////////////////////////////////// -bool CBFont::loadFile(const char * Filename) +bool BaseFont::loadFile(const char * Filename) { BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); if(Buffer==NULL){ - _gameRef->LOG(0, "CBFont::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -96,7 +96,7 @@ TOKEN_DEF_START TOKEN_DEF (FONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFont::loadBuffer(byte * Buffer) +bool BaseFont::loadBuffer(byte * Buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE (FONT) @@ -104,7 +104,7 @@ bool CBFont::loadBuffer(byte * Buffer) char* params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); @@ -138,23 +138,23 @@ bool CBFont::loadBuffer(byte * Buffer) */ ////////////////////////////////////////////////////////////////////////// -int CBFont::getLetterHeight() { +int BaseFont::getLetterHeight() { return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBFont::persist(CBPersistMgr *persistMgr) { +bool BaseFont::persist(BasePersistenceManager *persistMgr) { - CBObject::persist(persistMgr); + BaseObject::persist(persistMgr); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const char *filename) { if (isTrueType(gameRef, filename)) { - CBFontTT *font = new CBFontTT(gameRef); + BaseFontTT *font = new BaseFontTT(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -163,7 +163,7 @@ CBFont *CBFont::createFromFile(CBGame *gameRef, const char *filename) { } return font; } else { - CBFontBitmap *font = new CBFontBitmap(gameRef); + BaseFontBitmap *font = new BaseFontBitmap(gameRef); if (font) { if (DID_FAIL(font->loadFile(filename))) { delete font; @@ -180,7 +180,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { +bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) @@ -193,7 +193,7 @@ bool CBFont::isTrueType(CBGame *gameRef, const char *filename) { byte *WorkBuffer = buffer; char *params; - CBParser parser(gameRef); + BaseParser parser(gameRef); bool ret = false; if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 3df3090bb9..695bce2af3 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -35,9 +35,9 @@ namespace WinterMute { -class CBFont: public CBObject { +class BaseFont: public BaseObject { public: - DECLARE_PERSISTENT(CBFont, CBObject) + DECLARE_PERSISTENT(BaseFont, BaseObject) virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); @@ -45,15 +45,15 @@ public: virtual void initLoop() {}; virtual void afterLoad() {}; - CBFont(CBGame *inGame); - virtual ~CBFont(); + BaseFont(BaseGame *inGame); + virtual ~BaseFont(); - static CBFont *createFromFile(CBGame *game, const char *filename); + static BaseFont *createFromFile(BaseGame *game, const char *filename); private: //bool loadBuffer(byte * Buffer); //bool loadFile(const char* Filename); - static bool isTrueType(CBGame *game, const char *filename); + static bool isTrueType(BaseGame *game, const char *filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ef730afb0a..a913cc52ba 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -45,10 +45,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFontBitmap, false) +IMPLEMENT_PERSISTENT(BaseFontBitmap, false) ////////////////////////////////////////////////////////////////////// -CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame): BaseFont(inGame) { _subframe = NULL; _sprite = NULL; _widthsFrame = 0; @@ -61,7 +61,7 @@ CBFontBitmap::CBFontBitmap(CBGame *inGame): CBFont(inGame) { ////////////////////////////////////////////////////////////////////// -CBFontBitmap::~CBFontBitmap() { +BaseFontBitmap::~BaseFontBitmap() { delete _subframe; delete _sprite; _subframe = NULL; @@ -70,19 +70,19 @@ CBFontBitmap::~CBFontBitmap() { ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { textHeightDraw(text, x, y, width, align, true, max_height, maxLength); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextHeight(byte *text, int width) { +int BaseFontBitmap::getTextHeight(byte *text, int width) { return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); } ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getTextWidth(byte *text, int maxLength) { +int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { AnsiString str; if (_gameRef->_textEncoding == TEXT_UTF8) { @@ -106,7 +106,7 @@ int CBFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// -int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { +int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { if (maxLength == 0) return 0; if (text == NULL || text[0] == '\0') return _tileHeight; @@ -187,7 +187,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign StartX = x; break; default: - error("CBFontBitmap::TextHeightDraw - Unhandled enum"); + error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); break; } for (i = start; i < end + 1; i++) { @@ -213,7 +213,7 @@ int CBFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign ////////////////////////////////////////////////////////////////////// -void CBFontBitmap::drawChar(byte c, int x, int y) { +void BaseFontBitmap::drawChar(byte c, int x, int y) { if (_fontextFix) c--; int row, col; @@ -227,7 +227,7 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { if (_wholeCell) tileWidth = _tileWidth; else tileWidth = _widths[c]; - CBPlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; if (_sprite) { _sprite->GetCurrentFrame(); @@ -243,10 +243,10 @@ void CBFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadFile(const char *filename) { +bool BaseFontBitmap::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBFontBitmap::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -282,7 +282,7 @@ TOKEN_DEF(WIDTHS_FRAME) TOKEN_DEF(PAINT_WHOLE_CELL) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::loadBuffer(byte *buffer) { +bool BaseFontBitmap::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONTEXT_FIX) TOKEN_TABLE(FONT) @@ -304,7 +304,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { _gameRef->LOG(0, "'FONT' keyword expected."); @@ -401,7 +401,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { if (spriteFile != NULL) { delete _sprite; - _sprite = new CBSprite(_gameRef, this); + _sprite = new BaseSprite(_gameRef, this); if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { delete _sprite; _sprite = NULL; @@ -409,7 +409,7 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { } if (surfaceFile != NULL && !_sprite) { - _subframe = new CBSubFrame(_gameRef); + _subframe = new BaseSubFrame(_gameRef); if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); else _subframe->setSurface(surfaceFile); } @@ -454,9 +454,9 @@ bool CBFontBitmap::loadBuffer(byte *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { +bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { - CBFont::persist(persistMgr); + BaseFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_numColumns)); persistMgr->transfer(TMEMBER(_subframe)); @@ -480,15 +480,15 @@ bool CBFontBitmap::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getCharWidth(byte index) { +int BaseFontBitmap::getCharWidth(byte index) { if (_fontextFix) index--; return _widths[index]; } ////////////////////////////////////////////////////////////////////////// -bool CBFontBitmap::getWidths() { - CBSurface *surf = NULL; +bool BaseFontBitmap::getWidths() { + BaseSurface *surf = NULL; if (_sprite) { if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { @@ -533,7 +533,7 @@ bool CBFontBitmap::getWidths() { } ////////////////////////////////////////////////////////////////////////// -int CBFontBitmap::getLetterHeight() { +int BaseFontBitmap::getLetterHeight() { return _tileHeight; } diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 8af530cbc9..8a4f5af570 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -33,10 +33,10 @@ #include "engines/wintermute/base/font/base_font.h" namespace WinterMute { -class CBSubFrame; -class CBFontBitmap : public CBFont { +class BaseSubFrame; +class BaseFontBitmap : public BaseFont { public: - DECLARE_PERSISTENT(CBFontBitmap, CBFont) + DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) bool loadBuffer(byte *Buffer); bool loadFile(const char *filename); virtual int getTextWidth(byte *text, int maxLength = -1); @@ -44,19 +44,19 @@ public: virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - CBFontBitmap(CBGame *inGame); - virtual ~CBFontBitmap(); + BaseFontBitmap(BaseGame *inGame); + virtual ~BaseFontBitmap(); bool getWidths(); - CBSprite *_sprite; + BaseSprite *_sprite; int _widthsFrame; bool _fontextFix; int _numColumns; int _tileHeight; int _tileWidth; byte _widths[NUM_CHARACTERS]; - CBSubFrame *_subframe; + BaseSubFrame *_subframe; bool _wholeCell; private: diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 13f779f2cb..220a16e14f 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -39,19 +39,19 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CBFontStorage, true) +IMPLEMENT_PERSISTENT(BaseFontStorage, true) ////////////////////////////////////////////////////////////////////////// -CBFontStorage::CBFontStorage(CBGame *inGame): CBBase(inGame) { +BaseFontStorage::BaseFontStorage(BaseGame *inGame): BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBFontStorage::~CBFontStorage() { +BaseFontStorage::~BaseFontStorage() { cleanup(true); } ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::cleanup(bool warn) { +bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); delete _fonts[i]; @@ -62,7 +62,7 @@ bool CBFontStorage::cleanup(bool warn) { } ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::initLoop() { +bool BaseFontStorage::initLoop() { for (int i = 0; i < _fonts.getSize(); i++) { _fonts[i]->initLoop(); } @@ -70,7 +70,7 @@ bool CBFontStorage::initLoop() { } ////////////////////////////////////////////////////////////////////////// -CBFont *CBFontStorage::addFont(const char *filename) { +BaseFont *BaseFontStorage::addFont(const char *filename) { if (!filename) return NULL; for (int i = 0; i < _fonts.getSize(); i++) { @@ -81,7 +81,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { } /* - CBFont* font = new CBFont(_gameRef); + BaseFont* font = new BaseFont(_gameRef); if (!font) return NULL; if (DID_FAIL(font->loadFile(filename))) { @@ -94,7 +94,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { return font; } */ - CBFont *font = CBFont::createFromFile(_gameRef, filename); + BaseFont *font = BaseFont::createFromFile(_gameRef, filename); if (font) { font->_refCount = 1; _fonts.add(font); @@ -104,7 +104,7 @@ CBFont *CBFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::removeFont(CBFont *font) { +bool BaseFontStorage::removeFont(BaseFont *font) { if (!font) return STATUS_FAILED; for (int i = 0; i < _fonts.getSize(); i++) { @@ -122,7 +122,7 @@ bool CBFontStorage::removeFont(CBFont *font) { ////////////////////////////////////////////////////////////////////////// -bool CBFontStorage::persist(CBPersistMgr *persistMgr) { +bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(false); diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 7c88e9a2f4..2c9c6817c3 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -36,17 +36,17 @@ namespace WinterMute { -class CBFont; +class BaseFont; -class CBFontStorage : public CBBase { +class BaseFontStorage : public BaseClass { public: - DECLARE_PERSISTENT(CBFontStorage, CBBase) + DECLARE_PERSISTENT(BaseFontStorage, BaseClass) bool cleanup(bool warn = false); - bool removeFont(CBFont *font); - CBFont *addFont(const char *filename); - CBFontStorage(CBGame *inGame); - virtual ~CBFontStorage(); - CBArray _fonts; + bool removeFont(BaseFont *font); + BaseFont *addFont(const char *filename); + BaseFontStorage(BaseGame *inGame); + virtual ~BaseFontStorage(); + BaseArray _fonts; bool initLoop(); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index a52922fb76..bcf8621a40 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -46,10 +46,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBFontTT, false) +IMPLEMENT_PERSISTENT(BaseFontTT, false) ////////////////////////////////////////////////////////////////////////// -CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { +BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _fontHeight = 12; _isBold = _isItalic = _isUnderline = _isStriked = false; @@ -71,7 +71,7 @@ CBFontTT::CBFontTT(CBGame *inGame): CBFont(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBFontTT::~CBFontTT(void) { +BaseFontTT::~BaseFontTT(void) { clearCache(); for (int i = 0; i < _layers.getSize(); i++) { @@ -97,7 +97,7 @@ CBFontTT::~CBFontTT(void) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::clearCache() { +void BaseFontTT::clearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { if (_cachedTexts[i]) delete _cachedTexts[i]; _cachedTexts[i] = NULL; @@ -105,7 +105,7 @@ void CBFontTT::clearCache() { } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::initLoop() { +void BaseFontTT::initLoop() { // we need more aggressive cache management on iOS not to waste too much memory on fonts if (_gameRef->_constrainedMemory) { // purge all cached images not used in the last frame @@ -121,7 +121,7 @@ void CBFontTT::initLoop() { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextWidth(byte *text, int maxLength) { +int BaseFontTT::getTextWidth(byte *text, int maxLength) { WideString textStr; if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); @@ -138,7 +138,7 @@ int CBFontTT::getTextWidth(byte *text, int maxLength) { } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getTextHeight(byte *text, int width) { +int BaseFontTT::getTextHeight(byte *text, int width) { WideString textStr; if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); @@ -153,7 +153,7 @@ int CBFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { if (text == NULL || strcmp((char *)text, "") == 0) return; WideString textStr = (char *)text; @@ -166,12 +166,12 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i textStr = Common::String(textStr.c_str(), (uint32)maxLength); //text = text.substr(0, MaxLength); // TODO: Remove - CBRenderer *renderer = _gameRef->_renderer; + BaseRenderer *renderer = _gameRef->_renderer; // find cached surface, if exists int minPriority = INT_MAX; int minIndex = -1; - CBSurface *surface = NULL; + BaseSurface *surface = NULL; int textOffset = 0; for (int i = 0; i < NUM_CACHED_TEXTS; i++) { @@ -201,7 +201,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i if (surface) { // write surface to cache if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; - _cachedTexts[minIndex] = new CBCachedTTFontText; + _cachedTexts[minIndex] = new BaseCachedTTFontText; _cachedTexts[minIndex]->_surface = surface; _cachedTexts[minIndex]->_align = align; @@ -219,7 +219,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i // and paint it if (surface) { Rect32 rc; - CBPlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); for (int i = 0; i < _layers.getSize(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = renderer->_forceAlphaColor; @@ -237,7 +237,7 @@ void CBFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, i } ////////////////////////////////////////////////////////////////////////// -CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { +BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { //TextLineList lines; // TODO //WrapText(text, width, maxHeight, lines); @@ -256,7 +256,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex static bool hasWarned = false; if (!hasWarned) { hasWarned = true; - warning("CBFontTT::RenderTextToTexture - Not fully ported yet"); + warning("BaseFontTT::RenderTextToTexture - Not fully ported yet"); } debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); @@ -274,7 +274,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex heightOffset += (int)_lineHeight; } - CBSurface *retSurface = _gameRef->_renderer->createSurface(); + BaseSurface *retSurface = _gameRef->_renderer->createSurface(); Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); @@ -363,7 +363,7 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex posY += GetLineHeight(); } - CBSurfaceOSystem *wmeSurface = new CBSurfaceOSystem(_gameRef); + BaseSurfaceOSystem *wmeSurface = new BaseSurfaceOSystem(_gameRef); if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { SDL_FreeSurface(surface); return wmeSurface; @@ -377,9 +377,9 @@ CBSurface *CBFontTT::renderTextToTexture(const WideString &text, int width, TTex } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { +void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { //SDL_BlitSurface(src, NULL, target, targetRect); - warning("CBFontTT::BlitSurface - not ported yet"); + warning("BaseFontTT::BlitSurface - not ported yet"); #if 0 for (int y = 0; y < src->h; y++) { if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; @@ -401,16 +401,16 @@ void CBFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Co } ////////////////////////////////////////////////////////////////////////// -int CBFontTT::getLetterHeight() { +int BaseFontTT::getLetterHeight() { return (int)getLineHeight(); } ////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadFile(const char *filename) { +bool BaseFontTT::loadFile(const char *filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "CBFontTT::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -444,7 +444,7 @@ TOKEN_DEF(OFFSET_X) TOKEN_DEF(OFFSET_Y) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////// -bool CBFontTT::loadBuffer(byte *buffer) { +bool BaseFontTT::loadBuffer(byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(TTFONT) TOKEN_TABLE(SIZE) @@ -462,7 +462,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { _gameRef->LOG(0, "'TTFONT' keyword expected."); @@ -483,7 +483,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { break; case TOKEN_FILENAME: - CBUtils::setString(&_fontFile, params); + BaseUtils::setString(&_fontFile, params); break; case TOKEN_BOLD: @@ -521,7 +521,7 @@ bool CBFontTT::loadBuffer(byte *buffer) { break; case TOKEN_LAYER: { - CBTTFontLayer *Layer = new CBTTFontLayer; + BaseTTFontLayer *Layer = new BaseTTFontLayer; if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); else { delete Layer; @@ -540,19 +540,19 @@ bool CBFontTT::loadBuffer(byte *buffer) { // create at least one layer if (_layers.getSize() == 0) { - CBTTFontLayer *Layer = new CBTTFontLayer; + BaseTTFontLayer *Layer = new BaseTTFontLayer; Layer->_color = BaseColor; _layers.add(Layer); } - if (!_fontFile) CBUtils::setString(&_fontFile, "arial.ttf"); + if (!_fontFile) BaseUtils::setString(&_fontFile, "arial.ttf"); return initFont(); } ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { +bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { TOKEN_TABLE_START(commands) TOKEN_TABLE(OFFSET_X) TOKEN_TABLE(OFFSET_Y) @@ -562,7 +562,7 @@ bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { char *params; int cmd; - CBParser parser(_gameRef); + BaseParser parser(_gameRef); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -595,8 +595,8 @@ bool CBFontTT::parseLayer(CBTTFontLayer *layer, byte *buffer) { ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::persist(CBPersistMgr *persistMgr) { - CBFont::persist(persistMgr); +bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { + BaseFont::persist(persistMgr); persistMgr->transfer(TMEMBER(_isBold)); persistMgr->transfer(TMEMBER(_isItalic)); @@ -616,7 +616,7 @@ bool CBFontTT::persist(CBPersistMgr *persistMgr) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { - CBTTFontLayer *layer = new CBTTFontLayer; + BaseTTFontLayer *layer = new BaseTTFontLayer; layer->persist(persistMgr); _layers.add(layer); } @@ -632,18 +632,18 @@ bool CBFontTT::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CBFontTT::afterLoad() { +void BaseFontTT::afterLoad() { initFont(); } ////////////////////////////////////////////////////////////////////////// -bool CBFontTT::initFont() { +bool BaseFontTT::initFont() { if (!_fontFile) return STATUS_FAILED; Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(CBPlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); @@ -659,7 +659,7 @@ bool CBFontTT::initFont() { } if (!_font) { _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BFontTT::InitFont - Couldn't load %s", _fontFile); + warning("BaseFontTT::InitFont - Couldn't load %s", _fontFile); } _lineHeight = _font->getFontHeight(); return STATUS_OK; @@ -673,8 +673,8 @@ bool CBFontTT::initFont() { _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; memset(_fTStream, 0, sizeof(*_fTStream)); - _fTStream->read = CBFontTT::FTReadSeekProc; - _fTStream->close = CBFontTT::FTCloseProc; + _fTStream->read = BaseFontTT::FTReadSeekProc; + _fTStream->close = BaseFontTT::FTCloseProc; _fTStream->descriptor.pointer = file; _fTStream->size = file->GetSize(); @@ -725,7 +725,7 @@ bool CBFontTT::initFont() { } ////////////////////////////////////////////////////////////////////////// -void CBFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { +void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; // TODO: This function gets called a lot, so warnings like these drown out the usefull information static bool hasWarned = false; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 4d8e71a3ff..8a8459b070 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -40,22 +40,22 @@ namespace WinterMute { -class CBFontTT : public CBFont { +class BaseFontTT : public BaseFont { private: ////////////////////////////////////////////////////////////////////////// - class CBCachedTTFontText { + class BaseCachedTTFontText { public: WideString _text; int _width; TTextAlign _align; int _maxHeight; int _maxLength; - CBSurface *_surface; + BaseSurface *_surface; int _priority; int _textOffset; bool _marked; - CBCachedTTFontText() { + BaseCachedTTFontText() { //_text = L""; _text = ""; _width = _maxHeight = _maxLength = -1; @@ -66,21 +66,21 @@ private: _marked = false; } - virtual ~CBCachedTTFontText() { + virtual ~BaseCachedTTFontText() { if (_surface) delete _surface; } }; public: ////////////////////////////////////////////////////////////////////////// - class CBTTFontLayer { + class BaseTTFontLayer { public: - CBTTFontLayer() { + BaseTTFontLayer() { _offsetX = _offsetY = 0; _color = 0x00000000; } - bool persist(CBPersistMgr *persistMgr) { + bool persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_offsetX)); persistMgr->transfer(TMEMBER(_offsetY)); persistMgr->transfer(TMEMBER(_color)); @@ -114,9 +114,9 @@ public: public: - DECLARE_PERSISTENT(CBFontTT, CBFont) - CBFontTT(CBGame *inGame); - virtual ~CBFontTT(void); + DECLARE_PERSISTENT(BaseFontTT, BaseFont) + BaseFontTT(BaseGame *inGame); + virtual ~BaseFontTT(void); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); @@ -134,16 +134,16 @@ public: void initLoop(); private: - bool parseLayer(CBTTFontLayer *layer, byte *buffer); + bool parseLayer(BaseTTFontLayer *layer, byte *buffer); void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - CBSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - CBCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; bool initFont(); @@ -170,7 +170,7 @@ public: int _fontHeight; char *_fontFile; - CBArray _layers; + BaseArray _layers; void clearCache(); }; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index fb6b23db2b..533c3a866e 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -44,7 +44,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { +BaseImage::BaseImage(BaseGame *inGame, FIBITMAP *bitmap): BaseClass(inGame) { #if 0 _bitmap = bitmap; #endif @@ -57,7 +57,7 @@ CBImage::CBImage(CBGame *inGame, FIBITMAP *bitmap): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBImage::~CBImage() { +BaseImage::~BaseImage() { /* delete _bitmap; */ delete _decoder; if (_deletableSurface) { @@ -69,7 +69,7 @@ CBImage::~CBImage() { #endif } -bool CBImage::loadFile(const Common::String &filename) { +bool BaseImage::loadFile(const Common::String &filename) { _filename = filename; _filename.toLowercase(); if (StringUtil::startsWith(filename, "savegame:", true)) { @@ -83,7 +83,7 @@ bool CBImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { - error("CBImage::loadFile : Unsupported fileformat %s", filename.c_str()); + error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); } _filename = filename; Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); @@ -97,7 +97,7 @@ bool CBImage::loadFile(const Common::String &filename) { return STATUS_OK; } -byte CBImage::getAlphaAt(int x, int y) { +byte BaseImage::getAlphaAt(int x, int y) { if (!_surface) return 0xFF; uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; @@ -105,13 +105,13 @@ byte CBImage::getAlphaAt(int x, int y) { return a; } -void CBImage::copyFrom(Graphics::Surface *surface) { +void BaseImage::copyFrom(Graphics::Surface *surface) { _surface = _deletableSurface = new Graphics::Surface(); _deletableSurface->copyFrom(*surface); } ////////////////////////////////////////////////////////////////////////// -bool CBImage::saveBMPFile(const char *filename) { +bool BaseImage::saveBMPFile(const char *filename) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -123,7 +123,7 @@ bool CBImage::saveBMPFile(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::resize(int newWidth, int newHeight) { +bool BaseImage::resize(int newWidth, int newHeight) { #if 0 if (!_bitmap) return STATUS_FAILED; @@ -143,7 +143,7 @@ bool CBImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::writeBMPToStream(Common::WriteStream *stream) { +bool BaseImage::writeBMPToStream(Common::WriteStream *stream) { if (!_surface) return false; /* The following is just copied over and inverted to write-ops from the BMP-decoder */ @@ -247,7 +247,7 @@ bool CBImage::writeBMPToStream(Common::WriteStream *stream) { ////////////////////////////////////////////////////////////////////////// -bool CBImage::copyFrom(CBImage *origImage, int newWidth, int newHeight) { +bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { #if 0 if (_bitmap) FreeImage_Unload(_bitmap); diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 6cda3e6b46..4b43e36a6d 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -40,12 +40,12 @@ struct FIBITMAP; namespace WinterMute { -class CBSurface; -class CBImage: CBBase { +class BaseSurface; +class BaseImage: BaseClass { public: - CBImage(CBGame *inGame, FIBITMAP *bitmap = NULL); - ~CBImage(); + BaseImage(BaseGame *inGame, FIBITMAP *bitmap = NULL); + ~BaseImage(); bool loadFile(const Common::String &filename); const Graphics::Surface *getSurface() const { @@ -58,7 +58,7 @@ public: bool writeBMPToStream(Common::WriteStream *stream); bool resize(int newWidth, int newHeight); bool saveBMPFile(const char *filename); - bool copyFrom(CBImage *origImage, int newWidth = 0, int newHeight = 0); + bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); void copyFrom(Graphics::Surface *surface); private: Common::String _filename; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index a8c19362f6..c46115d70a 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { +BaseRenderer::BaseRenderer(BaseGame *inGame): BaseClass(inGame) { _window = 0; _clipperWindow = 0; _active = false; @@ -46,7 +46,7 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { _forceAlphaColor = 0x00; _width = _height = _bPP = 0; - CBPlatform::setRectEmpty(&_monitorRect); + BasePlatform::setRectEmpty(&_monitorRect); _realWidth = _realHeight = 0; _drawOffsetX = _drawOffsetY = 0; @@ -54,26 +54,26 @@ CBRenderer::CBRenderer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBRenderer::~CBRenderer() { +BaseRenderer::~BaseRenderer() { deleteRectList(); unclipCursor(); } ////////////////////////////////////////////////////////////////////// -void CBRenderer::initLoop() { +void BaseRenderer::initLoop() { deleteRectList(); } ////////////////////////////////////////////////////////////////////// -CBObject *CBRenderer::getObjectAt(int x, int y) { +BaseObject *BaseRenderer::getObjectAt(int x, int y) { Point32 point; point.x = x; point.y = y; for (int i = _rectList.getSize() - 1; i >= 0; i--) { - if (CBPlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { @@ -100,12 +100,12 @@ CBObject *CBRenderer::getObjectAt(int x, int y) { } } - return (CBObject *)NULL; + return (BaseObject *)NULL; } ////////////////////////////////////////////////////////////////////////// -void CBRenderer::deleteRectList() { +void BaseRenderer::deleteRectList() { for (int i = 0; i < _rectList.getSize(); i++) { delete _rectList[i]; } @@ -115,58 +115,58 @@ void CBRenderer::deleteRectList() { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -bool CBRenderer::switchFullscreen() { +bool BaseRenderer::switchFullscreen() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::flip() { +bool BaseRenderer::flip() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::initRenderer(int width, int height, bool windowed) { +bool BaseRenderer::initRenderer(int width, int height, bool windowed) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -void CBRenderer::onWindowChange() { +void BaseRenderer::onWindowChange() { } ////////////////////////////////////////////////////////////////////// -bool CBRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool BaseRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::windowedBlt() { +bool BaseRenderer::windowedBlt() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setup2D(bool Force) { +bool BaseRenderer::setup2D(bool Force) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setupLines() { +bool BaseRenderer::setupLines() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { +bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { for (int i = 0; i < width; i++) { drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down @@ -179,31 +179,31 @@ bool CBRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int widt ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fade(uint16 alpha) { +bool BaseRenderer::fade(uint16 alpha) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::fadeToColor(uint32 color, Common::Rect *rect) { +bool BaseRenderer::fadeToColor(uint32 color, Common::Rect *rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(int left, int top, int right, int bottom) { +bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setScreenViewport() { +bool BaseRenderer::setScreenViewport() { return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::setViewport(Rect32 *rect) { +bool BaseRenderer::setViewport(Rect32 *rect) { return setViewport(rect->left + _drawOffsetX, rect->top + _drawOffsetY, rect->right + _drawOffsetX, @@ -212,13 +212,13 @@ bool CBRenderer::setViewport(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderer::takeScreenshot() { +BaseImage *BaseRenderer::takeScreenshot() { return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::clipCursor() { +bool BaseRenderer::clipCursor() { /* if (!_windowed) { Rect32 rc; @@ -237,7 +237,7 @@ bool CBRenderer::clipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::unclipCursor() { +bool BaseRenderer::unclipCursor() { /* if (!_windowed) ::ClipCursor(NULL); */ @@ -245,7 +245,7 @@ bool CBRenderer::unclipCursor() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderer::pointInViewport(Point32 *p) { +bool BaseRenderer::pointInViewport(Point32 *p) { if (p->x < _drawOffsetX) return false; if (p->y < _drawOffsetY) return false; if (p->x > _drawOffsetX + _width) return false; diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index d743f19791..118cda0ec6 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -36,11 +36,11 @@ namespace WinterMute { -class CBImage; -class CBActiveRect; -class CBObject; -class CBSurface; -class CBRenderer: public CBBase { +class BaseImage; +class BaseActiveRect; +class BaseObject; +class BaseSurface; +class BaseRenderer: public BaseClass { public: int _realWidth; int _realHeight; @@ -48,7 +48,7 @@ public: int _drawOffsetY; virtual void dumpData(const char *filename) {}; - virtual CBImage *takeScreenshot(); + virtual BaseImage *takeScreenshot(); virtual bool setViewport(int left, int top, int right, int bottom); virtual bool setViewport(Rect32 *Rect); virtual bool setScreenViewport(); @@ -56,8 +56,8 @@ public: virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); - CBRenderer(CBGame *inGame = NULL); - virtual ~CBRenderer(); + BaseRenderer(BaseGame *inGame = NULL); + virtual ~BaseRenderer(); virtual bool setProjection() { return STATUS_OK; }; @@ -89,12 +89,12 @@ public: return 1.0f; } - virtual CBSurface *createSurface() = 0; + virtual BaseSurface *createSurface() = 0; bool clipCursor(); bool unclipCursor(); - CBObject *getObjectAt(int x, int y); + BaseObject *getObjectAt(int x, int y); void deleteRectList(); virtual bool startSpriteBatch() { @@ -118,10 +118,10 @@ public: int _height; int _width; - CBArray _rectList; + BaseArray _rectList; }; -CBRenderer *makeOSystemRenderer(CBGame *inGame); // Implemented in BRenderSDL.cpp +BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 73b385d180..684236ac7f 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { +BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { _referenceCount = 0; _width = _height = 0; @@ -53,87 +53,87 @@ CBSurface::CBSurface(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////// -CBSurface::~CBSurface() { +BaseSurface::~BaseSurface() { if (_pixelOpReady) endPixelOp(); } ////////////////////////////////////////////////////////////////////// -bool CBSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::restore() { +bool BaseSurface::restore() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAt(int x, int y) { +bool BaseSurface::isTransparentAt(int x, int y) { return false; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::displayHalfTrans(int x, int y, Rect32 rect) { +bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::create(int Width, int Height) { +bool BaseSurface::create(int Width, int Height) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::startPixelOp() { +bool BaseSurface::startPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::endPixelOp() { +bool BaseSurface::endPixelOp() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { +bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { +bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { +bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { return false; } ////////////////////////////////////////////////////////////////////// -bool CBSurface::isTransparentAtLite(int x, int y) { +bool BaseSurface::isTransparentAtLite(int x, int y) { return false; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::invalidate() { +bool BaseSurface::invalidate() { return STATUS_FAILED; } ////////////////////////////////////////////////////////////////////////// -bool CBSurface::prepareToDraw() { +bool BaseSurface::prepareToDraw() { _lastUsedTime = _gameRef->_liveTimer; if (!_valid) { @@ -144,7 +144,7 @@ bool CBSurface::prepareToDraw() { ////////////////////////////////////////////////////////////////////////// -void CBSurface::setSize(int width, int height) { +void BaseSurface::setSize(int width, int height) { _width = width; _height = height; } diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 22c1fb83b8..9a72cbb236 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -35,7 +35,7 @@ namespace WinterMute { -class CBSurface: public CBBase { +class BaseSurface: public BaseClass { public: virtual bool invalidate(); virtual bool prepareToDraw(); @@ -50,8 +50,8 @@ public: bool _keepLoaded; bool _pixelOpReady; - CBSurface(CBGame *inGame); - virtual ~CBSurface(); + BaseSurface(BaseGame *inGame); + virtual ~BaseSurface(); virtual bool displayHalfTrans(int x, int y, Rect32 rect); virtual bool isTransparentAt(int x, int y); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index dbd2511928..ec69a80095 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -41,7 +41,7 @@ namespace WinterMute { -RenderTicket::RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; @@ -89,14 +89,14 @@ bool RenderTicket::operator==(RenderTicket &t) { return true; } -CBRenderer *makeOSystemRenderer(CBGame *inGame) { - return new CBRenderOSystem(inGame); +BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { + return new BaseRenderOSystem(inGame); } // TODO: Redo everything here. ////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { +BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); _drawNum = 1; _needsFlip = true; @@ -110,7 +110,7 @@ CBRenderOSystem::CBRenderOSystem(CBGame *inGame) : CBRenderer(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBRenderOSystem::~CBRenderOSystem() { +BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; #if 0 @@ -121,7 +121,7 @@ CBRenderOSystem::~CBRenderOSystem() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { +bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; #if 0 @@ -237,20 +237,20 @@ bool CBRenderOSystem::initRenderer(int width, int height, bool windowed) { return STATUS_OK; } -void CBRenderOSystem::setAlphaMod(byte alpha) { +void BaseRenderOSystem::setAlphaMod(byte alpha) { byte r = RGBCOLGetR(_colorMod); byte g = RGBCOLGetB(_colorMod); byte b = RGBCOLGetB(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } -void CBRenderOSystem::setColorMod(byte r, byte g, byte b) { +void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { byte alpha = RGBCOLGetA(_colorMod); _colorMod = BS_ARGB(alpha, r, g, b); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::flip() { +bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); } @@ -270,7 +270,7 @@ bool CBRenderOSystem::flip() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { +bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); @@ -285,20 +285,20 @@ bool CBRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fade(uint16 Alpha) { +bool BaseRenderOSystem::fade(uint16 Alpha) { uint32 dwAlpha = 255 - Alpha; return fadeToColor(dwAlpha << 24); } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { +bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBRenderOSystem::FadeToColor - Breaks when using dirty rects"); - warning("Implement CBRenderOSystem::FadeToColor"); // TODO. + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + warning("Implement BaseRenderOSystem::FadeToColor"); // TODO. hasWarned = true; } @@ -347,7 +347,7 @@ bool CBRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { return STATUS_OK; } -void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { if (_disableDirtyRects) { RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. @@ -375,13 +375,13 @@ void CBRenderOSystem::drawSurface(CBSurfaceOSystem *owner, const Graphics::Surfa drawFromTicket(ticket); } -void CBRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { +void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); renderTicket->_isValid = false; // renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. } -void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { +void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { if ((*it)->_owner == surf) { @@ -390,7 +390,7 @@ void CBRenderOSystem::invalidateTicketsFromSurface(CBSurfaceOSystem *surf) { } } -void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { +void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { renderTicket->_wantsDraw = true; // A new item always has _drawNum == 0 if (renderTicket->_drawNum == 0) { @@ -445,7 +445,7 @@ void CBRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { } } -void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { +void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { if (!_dirtyRect) { _dirtyRect = new Common::Rect(rect); } else { @@ -455,7 +455,7 @@ void CBRenderOSystem::addDirtyRect(const Common::Rect &rect) { // warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); } -void CBRenderOSystem::drawTickets() { +void BaseRenderOSystem::drawTickets() { RenderQueueIterator it = _renderQueue.begin(); // Clean out the old tickets int decrement = 0; @@ -511,7 +511,7 @@ void CBRenderOSystem::drawTickets() { } // Replacement for SDL2's SDL_RenderCopy -void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { +void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { TransparentSurface src(*surf, false); bool doDelete = false; if (!clipRect) { @@ -527,10 +527,10 @@ void CBRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rec } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { +bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { - warning("CBRenderOSystem::DrawLine - not fully ported yet"); + warning("BaseRenderOSystem::DrawLine - not fully ported yet"); hasWarned = true; } byte r = RGBCOLGetR(color); @@ -558,10 +558,10 @@ bool CBRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { } ////////////////////////////////////////////////////////////////////////// -CBImage *CBRenderOSystem::takeScreenshot() { +BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Fix this - warning("CBRenderOSystem::TakeScreenshot() - not ported yet"); - CBImage *screenshot = new CBImage(_gameRef); + warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); + BaseImage *screenshot = new BaseImage(_gameRef); screenshot->copyFrom(_renderSurface); return screenshot; #if 0 @@ -584,13 +584,13 @@ CBImage *CBRenderOSystem::takeScreenshot() { memcpy(bits, src, bytespp * viewport.w); } - return new CBImage(_gameRef, dib); + return new BaseImage(_gameRef, dib); #endif return NULL; } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::switchFullscreen() { +bool BaseRenderOSystem::switchFullscreen() { /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); else SDL_SetWindowFullscreen(_win, SDL_FALSE); @@ -602,7 +602,7 @@ bool CBRenderOSystem::switchFullscreen() { } ////////////////////////////////////////////////////////////////////////// -const char *CBRenderOSystem::getName() { +const char *BaseRenderOSystem::getName() { if (_name.empty()) { #if 0 if (_renderer) { @@ -616,7 +616,7 @@ const char *CBRenderOSystem::getName() { } ////////////////////////////////////////////////////////////////////////// -bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { +bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { Common::Rect rect; // TODO: Hopefully this is the same logic that ScummVM uses. rect.left = (int16)(left + _borderLeft); @@ -632,7 +632,7 @@ bool CBRenderOSystem::setViewport(int left, int top, int right, int bottom) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::modTargetRect(Common::Rect *rect) { +void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -645,7 +645,7 @@ void CBRenderOSystem::modTargetRect(Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointFromScreen(Point32 *point) { +void BaseRenderOSystem::pointFromScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -657,7 +657,7 @@ void CBRenderOSystem::pointFromScreen(Point32 *point) { ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::pointToScreen(Point32 *point) { +void BaseRenderOSystem::pointToScreen(Point32 *point) { #if 0 SDL_Rect viewportRect; SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); @@ -668,19 +668,19 @@ void CBRenderOSystem::pointToScreen(Point32 *point) { } ////////////////////////////////////////////////////////////////////////// -void CBRenderOSystem::dumpData(const char *filename) { - warning("CBRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO +void BaseRenderOSystem::dumpData(const char *filename) { + warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO #if 0 FILE *f = fopen(filename, "wt"); if (!f) return; - CBSurfaceStorage *Mgr = _gameRef->_surfaceStorage; + BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; int TotalKB = 0; int TotalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - CBSurfaceOSystem *Surf = (CBSurfaceOSystem *)Mgr->_surfaces[i]; + BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; if (!Surf->_filename) continue; if (!Surf->_valid) continue; @@ -702,8 +702,8 @@ void CBRenderOSystem::dumpData(const char *filename) { #endif } -CBSurface *CBRenderOSystem::createSurface() { - return new CBSurfaceOSystem(_gameRef); +BaseSurface *BaseRenderOSystem::createSurface() { + return new BaseSurfaceOSystem(_gameRef); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 8a8eb88ede..75c745ecf7 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -35,11 +35,11 @@ #include "common/list.h" namespace WinterMute { -class CBSurfaceOSystem; +class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; public: - RenderTicket(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); const Graphics::Surface *getSurface() { return _surface; } @@ -53,14 +53,14 @@ public: uint32 _drawNum; uint32 _colorMod; - CBSurfaceOSystem *_owner; + BaseSurfaceOSystem *_owner; bool operator==(RenderTicket &a); }; -class CBRenderOSystem : public CBRenderer { +class BaseRenderOSystem : public BaseRenderer { public: - CBRenderOSystem(CBGame *inGame); - ~CBRenderOSystem(); + BaseRenderOSystem(BaseGame *inGame); + ~BaseRenderOSystem(); const char *getName(); @@ -75,12 +75,12 @@ public: bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - CBImage *takeScreenshot(); + BaseImage *takeScreenshot(); void setAlphaMod(byte alpha); void setColorMod(byte r, byte g, byte b); void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(CBSurfaceOSystem *surf); + void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); @@ -98,8 +98,8 @@ public: return _ratioY; } - void drawSurface(CBSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); - CBSurface *createSurface(); + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + BaseSurface *createSurface(); private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 87c5731b49..0de31349fd 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -46,7 +46,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { +BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { _surface = new Graphics::Surface(); _alphaMask = NULL; _hasAlpha = true; @@ -56,7 +56,7 @@ CBSurfaceOSystem::CBSurfaceOSystem(CBGame *inGame) : CBSurface(inGame) { } ////////////////////////////////////////////////////////////////////////// -CBSurfaceOSystem::~CBSurfaceOSystem() { +BaseSurfaceOSystem::~BaseSurfaceOSystem() { //TODO if (_surface) { _surface->free(); @@ -68,7 +68,7 @@ CBSurfaceOSystem::~CBSurfaceOSystem() { _alphaMask = NULL; _gameRef->addMem(-_width * _height * 4); - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); } @@ -91,8 +91,8 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ +bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); @@ -116,8 +116,8 @@ bool CBSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, return STATUS_OK; } -void CBSurfaceOSystem::finishLoad() { - CBImage *image = new CBImage(_gameRef); +void BaseSurfaceOSystem::finishLoad() { + BaseImage *image = new BaseImage(_gameRef); image->loadFile(_filename); _width = image->getSurface()->w; @@ -191,8 +191,8 @@ void CBSurfaceOSystem::finishLoad() { } ////////////////////////////////////////////////////////////////////////// -void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::GenAlphaMask - Not ported yet"); +void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); return; delete[] _alphaMask; @@ -237,8 +237,8 @@ void CBSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { - warning("CBSurfaceOSystem::GetPixel - Not ported yet"); +uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { + warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; @@ -273,10 +273,10 @@ uint32 CBSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::create(int width, int height) { - warning("CBSurfaceOSystem::Create not ported yet"); //TODO +bool BaseSurfaceOSystem::create(int width, int height) { + warning("BaseSurfaceOSystem::Create not ported yet"); //TODO #if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); #endif _width = width; @@ -290,10 +290,10 @@ bool CBSurfaceOSystem::create(int width, int height) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { - warning("CBSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO +bool BaseSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO #if 0 - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); #endif if (_surface) { @@ -314,12 +314,12 @@ bool CBSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAt(int x, int y) { +bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAt not ported yet"); + warning("BaseSurfaceOSystem::IsTransparentAt not ported yet"); hasWarned = true; } #if 0 @@ -340,14 +340,14 @@ bool CBSurfaceOSystem::isTransparentAt(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { +bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { //if (!_lockPixels) return false; // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::IsTransparentAtLite not ported yet"); + warning("BaseSurfaceOSystem::IsTransparentAtLite not ported yet"); hasWarned = true; } if (_surface->format.bytesPerPixel == 4) { @@ -387,57 +387,57 @@ bool CBSurfaceOSystem::isTransparentAtLite(int x, int y) { } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::startPixelOp() { +bool BaseSurfaceOSystem::startPixelOp() { //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); // Any pixel-op makes the caching useless: - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::endPixelOp() { +bool BaseSurfaceOSystem::endPixelOp() { //SDL_UnlockTexture(_texture); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { +bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { +bool BaseSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); } ////////////////////////////////////////////////////////////////////////// -bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); +bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); if (!_loaded) { finishLoad(); @@ -450,7 +450,7 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("CBSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. + warning("BaseSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. hasWarned = true; } @@ -508,7 +508,7 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float hasAlpha = false; } if (alphaDisable) { - warning("CBSurfaceOSystem::drawSprite - AlphaDisable ignored"); + warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); @@ -519,11 +519,11 @@ bool CBSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float return STATUS_OK; } -bool CBSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { +bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; _surface->copyFrom(surface); _hasAlpha = hasAlpha; - CBRenderOSystem *renderer = static_cast(_gameRef->_renderer); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); return STATUS_OK; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 091e8ccba8..bece031fe7 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -35,11 +35,11 @@ namespace WinterMute { struct TransparentSurface; -class CBImage; -class CBSurfaceOSystem : public CBSurface { +class BaseImage; +class BaseSurfaceOSystem : public BaseSurface { public: - CBSurfaceOSystem(CBGame *inGame); - ~CBSurfaceOSystem(); + BaseSurfaceOSystem(BaseGame *inGame); + ~BaseSurfaceOSystem(); bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index b3b05b6e65..212f11d2f6 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -43,13 +43,13 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CPartEmitter, false) +IMPLEMENT_PERSISTENT(PartEmitter, false) ////////////////////////////////////////////////////////////////////////// -CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inGame) { +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject(inGame) { _width = _height = 0; - CBPlatform::setRectEmpty(&_border); + BasePlatform::setRectEmpty(&_border); _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; _angle1 = _angle2 = 0; @@ -94,7 +94,7 @@ CPartEmitter::CPartEmitter(CBGame *inGame, CBScriptHolder *Owner) : CBObject(inG ////////////////////////////////////////////////////////////////////////// -CPartEmitter::~CPartEmitter(void) { +PartEmitter::~PartEmitter(void) { for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } @@ -116,7 +116,7 @@ CPartEmitter::~CPartEmitter(void) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addSprite(const char *filename) { +bool PartEmitter::addSprite(const char *filename) { if (!filename) return STATUS_FAILED; // do we already have the file? @@ -139,7 +139,7 @@ bool CPartEmitter::addSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeSprite(const char *filename) { +bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete [] _sprites[i]; @@ -151,34 +151,34 @@ bool CPartEmitter::removeSprite(const char *filename) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta) { +bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { if (!particle) return STATUS_FAILED; if (_sprites.getSize() == 0) return STATUS_FAILED; - int posX = CBUtils::randomInt(_posX, _posX + _width); - int posY = CBUtils::randomInt(_posY, _posY + _height); - float posZ = CBUtils::randomFloat(0.0f, 100.0f); + int posX = BaseUtils::randomInt(_posX, _posX + _width); + int posY = BaseUtils::randomInt(_posY, _posY + _height); + float posZ = BaseUtils::randomFloat(0.0f, 100.0f); float velocity; if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = CBUtils::randomFloat(_velocity1, _velocity2); + else velocity = BaseUtils::randomFloat(_velocity1, _velocity2); float scale; if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = CBUtils::randomFloat(_scale1, _scale2); + else scale = BaseUtils::randomFloat(_scale1, _scale2); int lifeTime; if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; - else lifeTime = CBUtils::randomInt(_lifeTime1, _lifeTime2); + else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); - float angle = CBUtils::randomAngle(_angle1, _angle2); - int spriteIndex = CBUtils::randomInt(0, _sprites.getSize() - 1); + float angle = BaseUtils::randomAngle(_angle1, _angle2); + int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); - float rotation = CBUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = CBUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = CBUtils::randomFloat(_growthRate1, _growthRate2); + float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); - if (!CBPlatform::isRectEmpty(&_border)) { + if (!BasePlatform::isRectEmpty(&_border)) { int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); @@ -195,14 +195,14 @@ bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uin Vector2 vecVel(0, velocity); Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); matRot.transformVector2(vecVel); if (_alphaTimeBased) { particle->_alpha1 = _alpha1; particle->_alpha2 = _alpha2; } else { - int alpha = CBUtils::randomInt(_alpha1, _alpha2); + int alpha = BaseUtils::randomInt(_alpha1, _alpha2); particle->_alpha1 = alpha; particle->_alpha2 = alpha; } @@ -226,13 +226,13 @@ bool CPartEmitter::initParticle(CPartParticle *particle, uint32 currentTime, uin } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::update() { +bool PartEmitter::update() { if (!_running) return STATUS_OK; else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { +bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; for (int i = 0; i < _particles.getSize(); i++) { @@ -263,10 +263,10 @@ bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } } - CPartParticle *particle; + PartParticle *particle; if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; else { - particle = new CPartParticle(_gameRef); + particle = new PartParticle(_gameRef); _particles.add(particle); } initParticle(particle, currentTime, timerDelta); @@ -288,7 +288,7 @@ bool CPartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::display(CBRegion *region) { +bool PartEmitter::display(BaseRegion *region) { if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); for (int i = 0; i < _particles.getSize(); i++) { @@ -305,7 +305,7 @@ bool CPartEmitter::display(CBRegion *region) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::start() { +bool PartEmitter::start() { for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->_isDead = true; } @@ -329,16 +329,16 @@ bool CPartEmitter::start() { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::sortParticlesByZ() { +bool PartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(CPartParticle *), CPartEmitter::compareZ); + qsort(_particles.getData(), _particles.getSize(), sizeof(PartParticle *), PartEmitter::compareZ); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -int CPartEmitter::compareZ(const void *obj1, const void *obj2) { - CPartParticle *p1 = *(CPartParticle **)obj1; - CPartParticle *p2 = *(CPartParticle **)obj2; +int PartEmitter::compareZ(const void *obj1, const void *obj2) { + PartParticle *p1 = *(PartParticle **)obj1; + PartParticle *p2 = *(PartParticle **)obj2; if (p1->_posZ < p2->_posZ) return -1; else if (p1->_posZ > p2->_posZ) return 1; @@ -346,14 +346,14 @@ int CPartEmitter::compareZ(const void *obj1, const void *obj2) { } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorder(int x, int y, int width, int height) { - CBPlatform::setRect(&_border, x, y, x + width, y + height); +bool PartEmitter::setBorder(int x, int y, int width, int height) { + BasePlatform::setRect(&_border, x, y, x + width, y + height); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { +bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { _borderThicknessLeft = thicknessLeft; _borderThicknessRight = thicknessRight; _borderThicknessTop = thicknessTop; @@ -363,8 +363,8 @@ bool CPartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int } ////////////////////////////////////////////////////////////////////////// -CPartForce *CPartEmitter::addForceByName(const char *name) { - CPartForce *force = NULL; +PartForce *PartEmitter::addForceByName(const char *name) { + PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { @@ -373,7 +373,7 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { } } if (!force) { - force = new CPartForce(_gameRef); + force = new PartForce(_gameRef); if (force) { force->setName(name); _forces.add(force); @@ -384,8 +384,8 @@ CPartForce *CPartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength) { - CPartForce *force = addForceByName(name); +bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { + PartForce *force = addForceByName(name); if (!force) return STATUS_FAILED; force->_type = type; @@ -393,14 +393,14 @@ bool CPartEmitter::addForce(const char *name, CPartForce::TForceType type, int p force->_direction = Vector2(0, strength); Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(CBUtils::normalizeAngle(angle - 180))); + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); matRot.transformVector2(force->_direction); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::removeForce(const char *name) { +bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->_name) == 0) { delete _forces[i]; @@ -415,7 +415,7 @@ bool CPartEmitter::removeForce(const char *name) { ////////////////////////////////////////////////////////////////////////// // high level scripting interface ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetBorder ////////////////////////////////////////////////////////////////////////// @@ -524,7 +524,7 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, 0, 0, angle, strength))); return STATUS_OK; } @@ -540,7 +540,7 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th float angle = stack->pop()->getFloat(); float strength = stack->pop()->getFloat(); - stack->pushBool(DID_SUCCEED(addForce(forceName, CPartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, posX, posY, angle, strength))); return STATUS_OK; } @@ -557,11 +557,11 @@ bool CPartEmitter::scCallMethod(CScScript *script, CScStack *stack, CScStack *th return STATUS_OK; } - else return CBObject::scCallMethod(script, stack, thisStack, name); + else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CPartEmitter::scGetProperty(const char *name) { +ScValue *PartEmitter::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -828,12 +828,12 @@ CScValue *CPartEmitter::scGetProperty(const char *name) { return _scValue; } - else return CBObject::scGetProperty(name); + else return BaseObject::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { +bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// @@ -1081,16 +1081,16 @@ bool CPartEmitter::scSetProperty(const char *name, CScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->isNULL()) CBUtils::setString(&_emitEvent, value->getString()); + if (!value->isNULL()) BaseUtils::setString(&_emitEvent, value->getString()); return STATUS_OK; } - else return CBObject::scSetProperty(name, value); + else return BaseObject::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -const char *CPartEmitter::scToString() { +const char *PartEmitter::scToString() { return "[particle emitter]"; } @@ -1098,8 +1098,8 @@ const char *CPartEmitter::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CPartEmitter::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool PartEmitter::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); persistMgr->transfer(TMEMBER(_width)); persistMgr->transfer(TMEMBER(_height)); @@ -1171,7 +1171,7 @@ bool CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < numForces; i++) { - CPartForce *force = new CPartForce(_gameRef); + PartForce *force = new PartForce(_gameRef); force->persist(persistMgr); _forces.add(force); } @@ -1187,7 +1187,7 @@ bool CPartEmitter::persist(CBPersistMgr *persistMgr) { } else { persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < numParticles; i++) { - CPartParticle *particle = new CPartParticle(_gameRef); + PartParticle *particle = new PartParticle(_gameRef); particle->persist(persistMgr); _particles.add(particle); } diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index cff0a1ec83..6575544db0 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -34,14 +34,14 @@ #include "engines/wintermute/base/particles/part_force.h" namespace WinterMute { -class CBRegion; -class CPartParticle; -class CPartEmitter : public CBObject { +class BaseRegion; +class PartParticle; +class PartEmitter : public BaseObject { public: - DECLARE_PERSISTENT(CPartEmitter, CBObject) + DECLARE_PERSISTENT(PartEmitter, BaseObject) - CPartEmitter(CBGame *inGame, CBScriptHolder *Owner); - virtual ~CPartEmitter(void); + PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); + virtual ~PartEmitter(void); int _width; int _height; @@ -98,13 +98,13 @@ public: bool _useRegion; char *_emitEvent; - CBScriptHolder *_owner; + BaseScriptHolder *_owner; bool start(); bool update(); bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(CBRegion *region); + bool display(BaseRegion *region); bool sortParticlesByZ(); bool addSprite(const char *filename); @@ -112,26 +112,26 @@ public: bool setBorder(int x, int y, int width, int height); bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - bool addForce(const char *name, CPartForce::TForceType type, int posX, int posY, float angle, float strength); + bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); bool removeForce(const char *name); - CBArray _forces; + BaseArray _forces; // scripting interface - virtual CScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, CScValue *value); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); private: - CPartForce *addForceByName(const char *name); + PartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); - bool initParticle(CPartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; - CBArray _particles; - CBArray _sprites; + BaseArray _particles; + BaseArray _sprites; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 2f330c21b0..ba60e8b41c 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { +PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { _pos = Vector2(0.0f, 0.0f); _direction = Vector2(0.0f, 0.0f); _type = FORCE_POINT; @@ -42,12 +42,12 @@ CPartForce::CPartForce(CBGame *inGame) : CBNamedObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CPartForce::~CPartForce(void) { +PartForce::~PartForce(void) { } ////////////////////////////////////////////////////////////////////////// -bool CPartForce::persist(CBPersistMgr *persistMgr) { +bool PartForce::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_name)); persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h index f0a6d66c43..ec79ab7238 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -36,20 +36,20 @@ namespace WinterMute { -class CPartForce : public CBNamedObject { +class PartForce : public BaseNamedObject { public: enum TForceType { FORCE_POINT, FORCE_GLOBAL }; - CPartForce(CBGame *inGame); - virtual ~CPartForce(void); + PartForce(BaseGame *inGame); + virtual ~PartForce(void); Vector2 _pos; Vector2 _direction; TForceType _type; - bool persist(CBPersistMgr *PersistMgr); + bool persist(BasePersistenceManager *PersistMgr); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 931f7558c7..93b9f3659d 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -39,7 +39,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { +PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { _pos = Vector2(0.0f, 0.0f); _posZ = 0.0f; _velocity = Vector2(0.0f, 0.0f); @@ -48,7 +48,7 @@ CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { _creationTime = 0; _lifeTime = 0; _isDead = true; - CBPlatform::setRectEmpty(&_border); + BasePlatform::setRectEmpty(&_border); _state = PARTICLE_NORMAL; _fadeStart = 0; @@ -66,13 +66,13 @@ CPartParticle::CPartParticle(CBGame *inGame) : CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CPartParticle::~CPartParticle(void) { +PartParticle::~PartParticle(void) { delete _sprite; _sprite = NULL; } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::setSprite(const char *filename) { +bool PartParticle::setSprite(const char *filename) { if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { _sprite->reset(); return STATUS_OK; @@ -81,22 +81,22 @@ bool CPartParticle::setSprite(const char *filename) { delete _sprite; _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = true; - _sprite = new CBSprite(_gameRef, _gameRef); + SystemClassRegistry::getInstance()->_disabled = true; + _sprite = new BaseSprite(_gameRef, _gameRef); if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; return STATUS_OK; } else { delete _sprite; _sprite = NULL; - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; return STATUS_FAILED; } } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { +bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { if (_state == PARTICLE_FADEIN) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; @@ -123,11 +123,11 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim } // particle hit the border - if (!_isDead && !CBPlatform::isRectEmpty(&_border)) { + if (!_isDead && !BasePlatform::isRectEmpty(&_border)) { Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!CBPlatform::ptInRect(&_border, p)) + if (!BasePlatform::ptInRect(&_border, p)) fadeOut(currentTime, emitter->_fadeOutTime); } if (_state != PARTICLE_NORMAL) return STATUS_OK; @@ -144,13 +144,13 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim float elapsedTime = (float)timerDelta / 1000.f; for (int i = 0; i < emitter->_forces.getSize(); i++) { - CPartForce *force = emitter->_forces[i]; + PartForce *force = emitter->_forces[i]; switch (force->_type) { - case CPartForce::FORCE_GLOBAL: + case PartForce::FORCE_GLOBAL: _velocity += force->_direction * elapsedTime; break; - case CPartForce::FORCE_POINT: { + case PartForce::FORCE_POINT: { Vector2 vecDist = force->_pos - _pos; float dist = fabs(vecDist.length()); @@ -165,7 +165,7 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim // update rotation _rotation += _angVelocity * elapsedTime; - _rotation = CBUtils::normalizeAngle(_rotation); + _rotation = BaseUtils::normalizeAngle(_rotation); // update scale if (_exponentialGrowth) @@ -182,7 +182,7 @@ bool CPartParticle::update(CPartEmitter *emitter, uint32 currentTime, uint32 tim } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::display(CPartEmitter *emitter) { +bool PartParticle::display(PartEmitter *emitter) { if (!_sprite) return STATUS_FAILED; if (_isDead) return STATUS_OK; @@ -197,7 +197,7 @@ bool CPartParticle::display(CPartEmitter *emitter) { ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { +bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { _currentAlpha = 0; _fadeStart = currentTime; _fadeTime = fadeTime; @@ -207,7 +207,7 @@ bool CPartParticle::fadeIn(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { +bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { //_currentAlpha = 255; _fadeStartAlpha = _currentAlpha; _fadeStart = currentTime; @@ -218,7 +218,7 @@ bool CPartParticle::fadeOut(uint32 currentTime, int fadeTime) { } ////////////////////////////////////////////////////////////////////////// -bool CPartParticle::persist(CBPersistMgr *persistMgr) { +bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_alpha1)); persistMgr->transfer(TMEMBER(_alpha2)); persistMgr->transfer(TMEMBER(_border)); @@ -244,9 +244,9 @@ bool CPartParticle::persist(CBPersistMgr *persistMgr) { } else { char *filename; persistMgr->transfer(TMEMBER(filename)); - CSysClassRegistry::getInstance()->_disabled = true; + SystemClassRegistry::getInstance()->_disabled = true; setSprite(filename); - CSysClassRegistry::getInstance()->_disabled = false; + SystemClassRegistry::getInstance()->_disabled = false; delete[] filename; filename = NULL; } diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 0b256d44ec..8b0c6eea36 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -36,18 +36,18 @@ namespace WinterMute { -class CPartEmitter; -class CBSprite; -class CBPersistMgr; +class PartEmitter; +class BaseSprite; +class BasePersistenceManager; -class CPartParticle : public CBBase { +class PartParticle : public BaseClass { public: enum TParticleState { PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT }; - CPartParticle(CBGame *inGame); - virtual ~CPartParticle(void); + PartParticle(BaseGame *inGame); + virtual ~PartParticle(void); float _growthRate; bool _exponentialGrowth; @@ -63,21 +63,21 @@ public: float _posZ; Vector2 _velocity; float _scale; - CBSprite *_sprite; + BaseSprite *_sprite; uint32 _creationTime; int _lifeTime; bool _isDead; TParticleState _state; - bool update(CPartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(CPartEmitter *emitter); + bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(PartEmitter *emitter); bool setSprite(const char *filename); bool fadeIn(uint32 currentTime, int fadeTime); bool fadeOut(uint32 currentTime, int fadeTime); - bool persist(CBPersistMgr *PersistMgr); + bool persist(BasePersistenceManager *PersistMgr); private: uint32 _fadeStart; int _fadeTime; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index a9646e0045..45544831e3 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -36,10 +36,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScScript, false) +IMPLEMENT_PERSISTENT(ScScript, false) ////////////////////////////////////////////////////////////////////////// -CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { +ScScript::ScScript(BaseGame *inGame, ScEngine *Engine): BaseClass(inGame) { _buffer = NULL; _bufferSize = _iP = 0; _scriptStream = NULL; @@ -98,11 +98,11 @@ CScScript::CScScript(CBGame *inGame, CScEngine *Engine): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScScript::~CScScript() { +ScScript::~ScScript() { cleanup(); } -void CScScript::readHeader() { +void ScScript::readHeader() { uint32 oldPos = _scriptStream->pos(); _scriptStream->seek(0); _header.magic = _scriptStream->readUint32LE(); @@ -118,7 +118,7 @@ void CScScript::readHeader() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::initScript() { +bool ScScript::initScript() { if (!_scriptStream) { _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); } @@ -139,13 +139,13 @@ bool CScScript::initScript() { initTables(); // init stacks - _scopeStack = new CScStack(_gameRef); - _callStack = new CScStack(_gameRef); - _thisStack = new CScStack(_gameRef); - _stack = new CScStack(_gameRef); + _scopeStack = new ScStack(_gameRef); + _callStack = new ScStack(_gameRef); + _thisStack = new ScStack(_gameRef); + _stack = new ScStack(_gameRef); - _operand = new CScValue(_gameRef); - _reg1 = new CScValue(_gameRef); + _operand = new ScValue(_gameRef); + _reg1 = new ScValue(_gameRef); // skip to the beginning @@ -165,7 +165,7 @@ bool CScScript::initScript() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::initTables() { +bool ScScript::initTables() { uint32 OrigIP = _iP; readHeader(); @@ -240,7 +240,7 @@ bool CScScript::initTables() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner) { +bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner) { cleanup(); _thread = false; @@ -263,7 +263,7 @@ bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScript if (DID_FAIL(res)) return res; // establish global variables table - _globals = new CScValue(_gameRef); + _globals = new ScValue(_gameRef); _owner = owner; @@ -272,7 +272,7 @@ bool CScScript::create(const char *filename, byte *buffer, uint32 size, CBScript ////////////////////////////////////////////////////////////////////////// -bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eventName) { +bool ScScript::createThread(ScScript *original, uint32 initIP, const char *eventName) { cleanup(); _thread = true; @@ -316,7 +316,7 @@ bool CScScript::createThread(CScScript *original, uint32 initIP, const char *eve ////////////////////////////////////////////////////////////////////////// -bool CScScript::createMethodThread(CScScript *original, const char *methodName) { +bool ScScript::createMethodThread(ScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); if (ip == 0) return STATUS_FAILED; @@ -360,7 +360,7 @@ bool CScScript::createMethodThread(CScScript *original, const char *methodName) ////////////////////////////////////////////////////////////////////////// -void CScScript::cleanup() { +void ScScript::cleanup() { if (_buffer) delete [] _buffer; _buffer = NULL; @@ -430,7 +430,7 @@ void CScScript::cleanup() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getDWORD() { +uint32 ScScript::getDWORD() { _scriptStream->seek((int32)_iP); uint32 ret = _scriptStream->readUint32LE(); _iP += sizeof(uint32); @@ -439,7 +439,7 @@ uint32 CScScript::getDWORD() { } ////////////////////////////////////////////////////////////////////////// -double CScScript::getFloat() { +double ScScript::getFloat() { _scriptStream->seek((int32)_iP); byte buffer[8]; _scriptStream->read(buffer, 8); @@ -459,7 +459,7 @@ double CScScript::getFloat() { ////////////////////////////////////////////////////////////////////////// -char *CScScript::getString() { +char *ScScript::getString() { char *ret = (char *)(_buffer + _iP); while (*(char *)(_buffer + _iP) != '\0') _iP++; _iP++; // string terminator @@ -470,17 +470,17 @@ char *CScScript::getString() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::executeInstruction() { +bool ScScript::executeInstruction() { bool ret = STATUS_OK; uint32 dw; const char *str = NULL; - //CScValue* op = new CScValue(_gameRef); + //ScValue* op = new ScValue(_gameRef); _operand->cleanup(); - CScValue *op1; - CScValue *op2; + ScValue *op1; + ScValue *op2; uint32 inst = getDWORD(); switch (inst) { @@ -557,7 +557,7 @@ bool CScScript::executeInstruction() { char *MethodName = new char[strlen(str) + 1]; strcpy(MethodName, str); - CScValue *var = _stack->pop(); + ScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; bool res = STATUS_FAILED; @@ -591,7 +591,7 @@ bool CScScript::executeInstruction() { break; } /* - CScValue* val = var->getProp(MethodName); + ScValue* val = var->getProp(MethodName); if(val){ dw = GetFuncPos(val->getString()); if(dw==0){ @@ -660,7 +660,7 @@ bool CScScript::executeInstruction() { break; case II_PUSH_VAR: { - CScValue *var = getVar(_symbols[getDWORD()]); + ScValue *var = getVar(_symbols[getDWORD()]); if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->setReference(var); _stack->push(_operand); @@ -669,7 +669,7 @@ bool CScScript::executeInstruction() { } case II_PUSH_VAR_REF: { - CScValue *var = getVar(_symbols[getDWORD()]); + ScValue *var = getVar(_symbols[getDWORD()]); _operand->setReference(var); _stack->push(_operand); break; @@ -677,9 +677,9 @@ bool CScScript::executeInstruction() { case II_POP_VAR: { char *VarName = _symbols[getDWORD()]; - CScValue *var = getVar(VarName); + ScValue *var = getVar(VarName); if (var) { - CScValue *val = _stack->pop(); + ScValue *val = _stack->pop(); if (!val) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); @@ -740,7 +740,7 @@ bool CScScript::executeInstruction() { case II_PUSH_BY_EXP: { str = _stack->pop()->getString(); - CScValue *val = _stack->pop()->getProp(str); + ScValue *val = _stack->pop()->getProp(str); if (val) _stack->push(val); else _stack->pushNULL(); @@ -749,8 +749,8 @@ bool CScScript::executeInstruction() { case II_POP_BY_EXP: { str = _stack->pop()->getString(); - CScValue *var = _stack->pop(); - CScValue *val = _stack->pop(); + ScValue *var = _stack->pop(); + ScValue *val = _stack->pop(); if (val == NULL) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); @@ -778,7 +778,7 @@ bool CScScript::executeInstruction() { case II_JMP_FALSE: { dw = getDWORD(); //if(!_stack->pop()->getBool()) _iP = dw; - CScValue *val = _stack->pop(); + ScValue *val = _stack->pop(); if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { @@ -916,7 +916,7 @@ bool CScScript::executeInstruction() { } */ - _operand->setBool(CScValue::compare(op1, op2) == 0); + _operand->setBool(ScValue::compare(op1, op2) == 0); _stack->push(_operand); break; @@ -940,7 +940,7 @@ bool CScScript::executeInstruction() { } */ - _operand->setBool(CScValue::compare(op1, op2) != 0); + _operand->setBool(ScValue::compare(op1, op2) != 0); _stack->push(_operand); break; @@ -955,7 +955,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() < op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) < 0); + _operand->setBool(ScValue::compare(op1, op2) < 0); _stack->push(_operand); break; @@ -970,7 +970,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() > op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) > 0); + _operand->setBool(ScValue::compare(op1, op2) > 0); _stack->push(_operand); break; @@ -985,7 +985,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() <= op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) <= 0); + _operand->setBool(ScValue::compare(op1, op2) <= 0); _stack->push(_operand); break; @@ -1000,7 +1000,7 @@ bool CScScript::executeInstruction() { else _operand->setBool(op1->getInt() >= op2->getInt()); */ - _operand->setBool(CScValue::compare(op1, op2) >= 0); + _operand->setBool(ScValue::compare(op1, op2) >= 0); _stack->push(_operand); break; @@ -1009,7 +1009,7 @@ bool CScScript::executeInstruction() { op1 = _stack->pop(); //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) == 0); + _operand->setBool(ScValue::compareStrict(op1, op2) == 0); _stack->push(_operand); break; @@ -1019,7 +1019,7 @@ bool CScScript::executeInstruction() { op1 = _stack->pop(); //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(CScValue::compareStrict(op1, op2) != 0); + _operand->setBool(ScValue::compareStrict(op1, op2) != 0); _stack->push(_operand); break; @@ -1059,7 +1059,7 @@ bool CScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getFuncPos(const char *name) { +uint32 ScScript::getFuncPos(const char *name) { for (uint32 i = 0; i < _numFunctions; i++) { if (strcmp(name, _functions[i].name) == 0) return _functions[i].pos; @@ -1069,7 +1069,7 @@ uint32 CScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getMethodPos(const char *name) { +uint32 ScScript::getMethodPos(const char *name) { for (uint32 i = 0; i < _numMethods; i++) { if (strcmp(name, _methods[i].name) == 0) return _methods[i].pos; @@ -1079,8 +1079,8 @@ uint32 CScScript::getMethodPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScScript::getVar(char *name) { - CScValue *ret = NULL; +ScValue *ScScript::getVar(char *name) { + ScValue *ret = NULL; // scope locals if (_scopeStack->_sP >= 0) { @@ -1103,8 +1103,8 @@ CScValue *CScScript::getVar(char *name) { if (ret == NULL) { //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - CScValue *val = new CScValue(_gameRef); - CScValue *scope = _scopeStack->getTop(); + ScValue *val = new ScValue(_gameRef); + ScValue *scope = _scopeStack->getTop(); if (scope) { scope->setProp(name, val); ret = _scopeStack->getTop()->getProp(name); @@ -1120,7 +1120,7 @@ CScValue *CScScript::getVar(char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::waitFor(CBObject *object) { +bool ScScript::waitFor(BaseObject *object) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1133,14 +1133,14 @@ bool CScScript::waitFor(CBObject *object) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::waitForExclusive(CBObject *object) { +bool ScScript::waitForExclusive(BaseObject *object) { _engine->resetObject(object); return waitFor(object); } ////////////////////////////////////////////////////////////////////////// -bool CScScript::sleep(uint32 duration) { +bool ScScript::sleep(uint32 duration) { if (_unbreakable) { runtimeError("Script cannot be interrupted."); return STATUS_OK; @@ -1148,7 +1148,7 @@ bool CScScript::sleep(uint32 duration) { _state = SCRIPT_SLEEPING; if (_gameRef->_state == GAME_FROZEN) { - _waitTime = CBPlatform::getTime() + duration; + _waitTime = BasePlatform::getTime() + duration; _waitFrozen = true; } else { _waitTime = _gameRef->_timer + duration; @@ -1159,7 +1159,7 @@ bool CScScript::sleep(uint32 duration) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::finish(bool includingThreads) { +bool ScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); @@ -1171,14 +1171,14 @@ bool CScScript::finish(bool includingThreads) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::run() { +bool ScScript::run() { _state = SCRIPT_RUNNING; return STATUS_OK; } ////////////////////////////////////////////////////////////////////// -void CScScript::runtimeError(const char *fmt, ...) { +void ScScript::runtimeError(const char *fmt, ...) { char buff[256]; va_list va; @@ -1195,7 +1195,7 @@ void CScScript::runtimeError(const char *fmt, ...) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::persist(CBPersistMgr *persistMgr) { +bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); @@ -1257,13 +1257,13 @@ bool CScScript::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable) { +ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { //if(_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); if (!pos) return NULL; - CScScript *thread = new CScScript(_gameRef, _engine); + ScScript *thread = new ScScript(_gameRef, _engine); if (thread) { bool ret = thread->createThread(this, pos, eventName); if (DID_SUCCEED(ret)) { @@ -1281,7 +1281,7 @@ CScScript *CScScript::invokeEventHandler(const char *eventName, bool unbreakable ////////////////////////////////////////////////////////////////////////// -uint32 CScScript::getEventPos(const char *name) { +uint32 ScScript::getEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; } @@ -1290,19 +1290,19 @@ uint32 CScScript::getEventPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleEvent(const char *eventName) { +bool ScScript::canHandleEvent(const char *eventName) { return getEventPos(eventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::canHandleMethod(const char *methodName) { +bool ScScript::canHandleMethod(const char *methodName) { return getMethodPos(methodName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::pause() { +bool ScScript::pause() { if (_state == SCRIPT_PAUSED) { _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); return STATUS_FAILED; @@ -1318,7 +1318,7 @@ bool CScScript::pause() { ////////////////////////////////////////////////////////////////////////// -bool CScScript::resume() { +bool ScScript::resume() { if (_state != SCRIPT_PAUSED) return STATUS_OK; _state = _origState; @@ -1327,7 +1327,7 @@ bool CScScript::resume() { ////////////////////////////////////////////////////////////////////////// -CScScript::TExternalFunction *CScScript::getExternal(char *name) { +ScScript::TExternalFunction *ScScript::getExternal(char *name) { for (uint32 i = 0; i < _numExternals; i++) { if (strcmp(name, _externals[i].name) == 0) return &_externals[i]; @@ -1337,7 +1337,7 @@ CScScript::TExternalFunction *CScScript::getExternal(char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function) { +bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { _gameRef->LOG(0, "External functions are not supported on this platform."); stack->correctParams(0); @@ -1347,7 +1347,7 @@ bool CScScript::externalCall(CScStack *stack, CScStack *thisStack, CScScript::TE ////////////////////////////////////////////////////////////////////////// -bool CScScript::copyParameters(CScStack *stack) { +bool ScScript::copyParameters(ScStack *stack) { int i; int NumParams = stack->pop()->getInt(); for (i = NumParams - 1; i >= 0; i--) { @@ -1362,9 +1362,9 @@ bool CScScript::copyParameters(CScStack *stack) { ////////////////////////////////////////////////////////////////////////// -bool CScScript::finishThreads() { +bool ScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.getSize(); i++) { - CScScript *scr = _engine->_scripts[i]; + ScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) scr->finish(true); } @@ -1374,18 +1374,18 @@ bool CScScript::finishThreads() { ////////////////////////////////////////////////////////////////////////// // IWmeDebugScript interface implementation -int CScScript::dbgGetLine() { +int ScScript::dbgGetLine() { return _currentLine; } ////////////////////////////////////////////////////////////////////////// -const char *CScScript::dbgGetFilename() { +const char *ScScript::dbgGetFilename() { return _filename; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendScript(IWmeDebugClient *client) { +bool ScScript::dbgSendScript(IWmeDebugClient *client) { if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); else client->onScriptInit(this); @@ -1395,14 +1395,14 @@ bool CScScript::dbgSendScript(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSendVariables(IWmeDebugClient *client) { +bool ScScript::dbgSendVariables(IWmeDebugClient *client) { // send script globals _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); // send scope variables if (_scopeStack->_sP >= 0) { for (int i = 0; i <= _scopeStack->_sP; i++) { - // CScValue *Scope = _scopeStack->GetAt(i); + // ScValue *Scope = _scopeStack->GetAt(i); //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); } } @@ -1411,35 +1411,35 @@ bool CScScript::dbgSendVariables(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// -TScriptState CScScript::dbgGetState() { +TScriptState ScScript::dbgGetState() { return _state; } ////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetNumBreakpoints() { +int ScScript::dbgGetNumBreakpoints() { return _breakpoints.getSize(); } ////////////////////////////////////////////////////////////////////////// -int CScScript::dbgGetBreakpoint(int index) { +int ScScript::dbgGetBreakpoint(int index) { if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; else return -1; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgSetTracingMode(bool isTracing) { +bool ScScript::dbgSetTracingMode(bool isTracing) { _tracingMode = isTracing; return true; } ////////////////////////////////////////////////////////////////////////// -bool CScScript::dbgGetTracingMode() { +bool ScScript::dbgGetTracingMode() { return _tracingMode; } ////////////////////////////////////////////////////////////////////////// -void CScScript::afterLoad() { +void ScScript::afterLoad() { if (_buffer == NULL) { byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); if (!buffer) { diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 899e1f3098..3bb4bc48a7 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -37,50 +37,50 @@ #include "engines/wintermute/wme_debugger.h" namespace WinterMute { -class CBScriptHolder; -class CBObject; -class CScEngine; -class CScStack; -class CScScript : public CBBase, public IWmeDebugScript { +class BaseScriptHolder; +class BaseObject; +class ScEngine; +class ScStack; +class ScScript : public BaseClass, public IWmeDebugScript { public: bool dbgSendScript(IWmeDebugClient *client); bool dbgSendVariables(IWmeDebugClient *client); - CBArray _breakpoints; + BaseArray _breakpoints; bool _tracingMode; - CScScript *_parentScript; + ScScript *_parentScript; bool _unbreakable; bool finishThreads(); - bool copyParameters(CScStack *stack); + bool copyParameters(ScStack *stack); void afterLoad(); - CScValue *_operand; - CScValue *_reg1; + ScValue *_operand; + ScValue *_reg1; bool _freezable; bool resume(); bool pause(); bool canHandleEvent(const char *eventName); bool canHandleMethod(const char *methodName); - bool createThread(CScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(CScScript *original, const char *methodName); - CScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + bool createThread(ScScript *original, uint32 initIP, const char *eventName); + bool createMethodThread(ScScript *original, const char *methodName); + ScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); uint32 _timeSlice; - DECLARE_PERSISTENT(CScScript, CBBase) + DECLARE_PERSISTENT(ScScript, BaseClass) void runtimeError(const char *fmt, ...); bool run(); bool finish(bool includingThreads = false); bool sleep(uint32 duration); - bool waitForExclusive(CBObject *object); - bool waitFor(CBObject *object); + bool waitForExclusive(BaseObject *object); + bool waitFor(BaseObject *object); uint32 _waitTime; bool _waitFrozen; - CBObject *_waitObject; - CScScript *_waitScript; + BaseObject *_waitObject; + ScScript *_waitScript; TScriptState _state; TScriptState _origState; - CScValue *getVar(char *name); + ScValue *getVar(char *name); uint32 getFuncPos(const char *name); uint32 getEventPos(const char *name); uint32 getMethodPos(const char *name); @@ -122,19 +122,19 @@ public: } TExternalFunction; - CScStack *_callStack; - CScStack *_thisStack; - CScStack *_scopeStack; - CScStack *_stack; - CScValue *_globals; - CScEngine *_engine; + ScStack *_callStack; + ScStack *_thisStack; + ScStack *_scopeStack; + ScStack *_stack; + ScValue *_globals; + ScEngine *_engine; int _currentLine; bool executeInstruction(); char *getString(); uint32 getDWORD(); double getFloat(); void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, CBScriptHolder *owner); + bool create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner); uint32 _iP; private: void readHeader(); @@ -142,8 +142,8 @@ private: byte *_buffer; public: Common::SeekableReadStream *_scriptStream; - CScScript(CBGame *inGame, CScEngine *Engine); - virtual ~CScScript(); + ScScript(BaseGame *inGame, ScEngine *Engine); + virtual ~ScScript(); char *_filename; char **_symbols; uint32 _numSymbols; @@ -158,9 +158,9 @@ public: bool _thread; bool _methodThread; char *_threadEvent; - CBScriptHolder *_owner; - CScScript::TExternalFunction *getExternal(char *name); - bool externalCall(CScStack *stack, CScStack *thisStack, CScScript::TExternalFunction *function); + BaseScriptHolder *_owner; + ScScript::TExternalFunction *getExternal(char *name); + bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); private: bool initScript(); bool initTables(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 387093ac4a..44add054c5 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -41,29 +41,29 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScEngine, true) +IMPLEMENT_PERSISTENT(ScEngine, true) #define COMPILER_DLL "dcscomp.dll" ////////////////////////////////////////////////////////////////////////// -CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { +ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); else _gameRef->LOG(0, " Script compiler is NOT available"); - _globals = new CScValue(_gameRef); + _globals = new ScValue(_gameRef); // register 'Game' as global variable if (!_globals->propExists("Game")) { - CScValue val(_gameRef); + ScValue val(_gameRef); val.setNative(_gameRef, true); _globals->setProp("Game", &val); } // register 'Math' as global variable if (!_globals->propExists("Math")) { - CScValue val(_gameRef); + ScValue val(_gameRef); val.setNative(_gameRef->_mathClass, true); _globals->setProp("Math", &val); } @@ -81,7 +81,7 @@ CScEngine::CScEngine(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScEngine::~CScEngine() { +ScEngine::~ScEngine() { _gameRef->LOG(0, "Shutting down scripting engine"); saveBreakpoints(); @@ -98,7 +98,7 @@ CScEngine::~CScEngine() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::cleanup() { +bool ScEngine::cleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); delete _scripts[i]; @@ -120,25 +120,25 @@ bool CScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::loadFile(void *data, char *filename, uint32 *size) { - CBGame *gameRef = (CBGame *)data; +byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { + BaseGame *gameRef = (BaseGame *)data; return gameRef->_fileManager->readWholeFile(filename, size); } ////////////////////////////////////////////////////////////////////////// -void CScEngine::closeFile(void *data, byte *buffer) { +void ScEngine::closeFile(void *data, byte *buffer) { delete [] buffer; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::parseElement(void *data, int line, int type, void *elementData) { +void ScEngine::parseElement(void *data, int line, int type, void *elementData) { } ////////////////////////////////////////////////////////////////////////// -CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { +ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { byte *compBuffer; uint32 compSize; @@ -147,7 +147,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { if (!compBuffer) return NULL; // add new script - CScScript *script = new CScScript(_gameRef, this); + ScScript *script = new ScScript(_gameRef, this); bool ret = script->create(filename, compBuffer, compSize, owner); if (DID_FAIL(ret)) { _gameRef->LOG(ret, "Error running script '%s'...", filename); @@ -155,7 +155,7 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { return NULL; } else { // publish the "self" pseudo-variable - CScValue val(_gameRef); + ScValue val(_gameRef); if (owner)val.setNative(owner, true); else val.setNULL(); @@ -171,12 +171,12 @@ CScScript *CScEngine::runScript(const char *filename, CBScriptHolder *owner) { ////////////////////////////////////////////////////////////////////////// -byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { +byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { // is script in cache? if (!ignoreCache) { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = CBPlatform::getTime(); + _cachedScripts[i]->_timestamp = BasePlatform::getTime(); *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } @@ -191,7 +191,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); if (!buffer) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - error opening script '%s'", filename); + _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; } @@ -201,7 +201,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i compSize = size; } else { if (!_compilerAvailable) { - _gameRef->LOG(0, "CScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); delete [] buffer; return NULL; } @@ -216,7 +216,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = CBPlatform::getTime(); + uint32 MinTime = BasePlatform::getTime(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; @@ -244,7 +244,7 @@ byte *CScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool i ////////////////////////////////////////////////////////////////////////// -bool CScEngine::tick() { +bool ScEngine::tick() { if (_scripts.getSize() == 0) return STATUS_OK; @@ -275,7 +275,7 @@ bool CScEngine::tick() { case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= CBPlatform::getTime()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= BasePlatform::getTime()) _scripts[i]->run(); } else { if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); } @@ -300,7 +300,7 @@ bool CScEngine::tick() { break; } default: - //warning("CScEngine::Tick - Unhandled enum"); + //warning("ScEngine::Tick - Unhandled enum"); break; } // switch } // for each script @@ -314,25 +314,25 @@ bool CScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = CBPlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && CBPlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + uint32 StartTime = BasePlatform::getTime(); + while (_scripts[i]->_state == SCRIPT_RUNNING && BasePlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - StartTime); } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = CBPlatform::getTime(); + if (isProfiling) startTime = BasePlatform::getTime(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, CBPlatform::getTime() - startTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - startTime); } _currentScript = NULL; } @@ -344,7 +344,7 @@ bool CScEngine::tick() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::tickUnbreakable() { +bool ScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.getSize(); i++) { if (!_scripts[i]->_unbreakable) continue; @@ -363,7 +363,7 @@ bool CScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeFinishedScripts() { +bool ScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { @@ -379,7 +379,7 @@ bool CScEngine::removeFinishedScripts() { ////////////////////////////////////////////////////////////////////////// -int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { +int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; for (int i = 0; i < _scripts.getSize(); i++) { @@ -397,7 +397,7 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { numPersistent++; break; default: - warning("CScEngine::GetNumScripts - unhandled enum"); + warning("ScEngine::GetNumScripts - unhandled enum"); break; } numTotal++; @@ -411,7 +411,7 @@ int CScEngine::getNumScripts(int *running, int *waiting, int *persistent) { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::emptyScriptCache() { +bool ScEngine::emptyScriptCache() { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i]) { delete _cachedScripts[i]; @@ -423,7 +423,7 @@ bool CScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetObject(CBObject *Object) { +bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { @@ -437,7 +437,7 @@ bool CScEngine::resetObject(CBObject *Object) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resetScript(CScScript *script) { +bool ScEngine::resetScript(ScScript *script) { // terminate all scripts waiting for this script for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { @@ -448,7 +448,7 @@ bool CScEngine::resetScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::persist(CBPersistMgr *persistMgr) { +bool ScEngine::persist(BasePersistenceManager *persistMgr) { if (!persistMgr->_saving) cleanup(); persistMgr->transfer(TMEMBER(_gameRef)); @@ -461,7 +461,7 @@ bool CScEngine::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::editorCleanup() { +void ScEngine::editorCleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; @@ -473,7 +473,7 @@ void CScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::pauseAll() { +bool ScEngine::pauseAll() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] != _currentScript) _scripts[i]->pause(); } @@ -483,7 +483,7 @@ bool CScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::resumeAll() { +bool ScEngine::resumeAll() { for (int i = 0; i < _scripts.getSize(); i++) _scripts[i]->resume(); @@ -492,7 +492,7 @@ bool CScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// -bool CScEngine::isValidScript(CScScript *script) { +bool ScEngine::isValidScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) return true; } @@ -500,13 +500,13 @@ bool CScEngine::isValidScript(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::clearGlobals(bool includingNatives) { +bool ScEngine::clearGlobals(bool includingNatives) { _globals->CleanProps(includingNatives); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { +bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { // send global variables _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); @@ -526,7 +526,7 @@ bool CScEngine::dbgSendScripts(IWmeDebugClient *client) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { +bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; CScBreakpoint *bp = NULL; @@ -553,7 +553,7 @@ bool CScEngine::addBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { +bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -578,7 +578,7 @@ bool CScEngine::removeBreakpoint(const char *scriptFilename, int line) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints() { +bool ScEngine::refreshScriptBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; for (int i = 0; i < _scripts.getSize(); i++) { @@ -588,7 +588,7 @@ bool CScEngine::refreshScriptBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::refreshScriptBreakpoints(CScScript *script) { +bool ScEngine::refreshScriptBreakpoints(ScScript *script) { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; if (!script || !script->_filename) return STATUS_FAILED; @@ -605,7 +605,7 @@ bool CScEngine::refreshScriptBreakpoints(CScScript *script) { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::saveBreakpoints() { +bool ScEngine::saveBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; @@ -628,7 +628,7 @@ bool CScEngine::saveBreakpoints() { } ////////////////////////////////////////////////////////////////////////// -bool CScEngine::loadBreakpoints() { +bool ScEngine::loadBreakpoints() { if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; char key[100]; @@ -639,8 +639,8 @@ bool CScEngine::loadBreakpoints() { sprintf(key, "Breakpoint%d", i); AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); - char *path = CBUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = CBUtils::strEntry(1, breakpoint.c_str(), ':'); + char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); + char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); delete[] path; @@ -654,7 +654,7 @@ bool CScEngine::loadBreakpoints() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::addScriptTime(const char *filename, uint32 time) { +void ScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) return; AnsiString fileName = filename; @@ -664,19 +664,19 @@ void CScEngine::addScriptTime(const char *filename, uint32 time) { ////////////////////////////////////////////////////////////////////////// -void CScEngine::enableProfiling() { +void ScEngine::enableProfiling() { if (_isProfiling) return; // destroy old data, if any _scriptTimes.clear(); - _profilingStartTime = CBPlatform::getTime(); + _profilingStartTime = BasePlatform::getTime(); _isProfiling = true; } ////////////////////////////////////////////////////////////////////////// -void CScEngine::disableProfiling() { +void ScEngine::disableProfiling() { if (!_isProfiling) return; dumpStats(); @@ -685,9 +685,9 @@ void CScEngine::disableProfiling() { ////////////////////////////////////////////////////////////////////////// -void CScEngine::dumpStats() { +void ScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = CBPlatform::getTime() - _profilingStartTime; + /* uint32 totalTime = BasePlatform::getTime() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 81dc13a73c..06d61b4156 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -39,16 +39,16 @@ namespace WinterMute { #define MAX_CACHED_SCRIPTS 20 -class CScScript; -class CScValue; -class CBObject; -class CBScriptHolder; -class CScEngine : public CBBase { +class ScScript; +class ScValue; +class BaseObject; +class BaseScriptHolder; +class ScEngine : public BaseClass { public: class CScCachedScript { public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = CBPlatform::getTime(); + _timestamp = BasePlatform::getTime(); _buffer = new byte[size]; if (_buffer) memcpy(_buffer, buffer, size); _size = size; @@ -76,7 +76,7 @@ public: } Common::String _filename; - CBArray _lines; + BaseArray _lines; }; @@ -85,42 +85,42 @@ public: public: bool dbgSendScripts(IWmeDebugClient *client); - CBArray _breakpoints; + BaseArray _breakpoints; bool addBreakpoint(const char *scriptFilename, int line); bool removeBreakpoint(const char *scriptFilename, int line); bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(CScScript *script); + bool refreshScriptBreakpoints(ScScript *script); bool saveBreakpoints(); bool loadBreakpoints(); bool clearGlobals(bool includingNatives = false); bool tickUnbreakable(); bool removeFinishedScripts(); - bool isValidScript(CScScript *script); + bool isValidScript(ScScript *script); - CScScript *_currentScript; + ScScript *_currentScript; bool resumeAll(); bool pauseAll(); void editorCleanup(); - bool resetObject(CBObject *Object); - bool resetScript(CScScript *script); + bool resetObject(BaseObject *Object); + bool resetScript(ScScript *script); bool emptyScriptCache(); byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(CScEngine, CBBase) + DECLARE_PERSISTENT(ScEngine, BaseClass) bool cleanup(); int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); bool tick(); - CScValue *_globals; - CScScript *runScript(const char *filename, CBScriptHolder *owner = NULL); + ScValue *_globals; + ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); static const bool _compilerAvailable = false; - CScEngine(CBGame *inGame); - virtual ~CScEngine(); + ScEngine(BaseGame *inGame); + virtual ~ScEngine(); static byte *loadFile(void *data, char *filename, uint32 *size); static void closeFile(void *data, byte *buffer); static void parseElement(void *data, int line, int type, void *elementData); - CBArray _scripts; + BaseArray _scripts; void enableProfiling(); void disableProfiling(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index a1b8249cb1..41059b2d80 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -34,16 +34,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXArray, false) +IMPLEMENT_PERSISTENT(SXArray, false) -CBScriptable *makeSXArray(CBGame *inGame, CScStack *stack) { - return new CSXArray(inGame, stack); +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { + return new SXArray(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { _length = 0; - _values = new CScValue(_gameRef); + _values = new ScValue(_gameRef); int numParams = stack->pop()->getInt(0); @@ -59,27 +59,27 @@ CSXArray::CSXArray(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CSXArray::CSXArray(CBGame *inGame): CBScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame): BaseScriptable(inGame) { _length = 0; - _values = new CScValue(_gameRef); + _values = new ScValue(_gameRef); } ////////////////////////////////////////////////////////////////////////// -CSXArray::~CSXArray() { +SXArray::~SXArray() { delete _values; _values = NULL; } ////////////////////////////////////////////////////////////////////////// -const char *CSXArray::scToString() { +const char *SXArray::scToString() { static char dummy[32768]; // TODO: Get rid of static. strcpy(dummy, ""); char propName[20]; for (int i = 0; i < _length; i++) { sprintf(propName, "%d", i); - CScValue *val = _values->getProp(propName); + ScValue *val = _values->getProp(propName); if (val) { if (strlen(dummy) + strlen(val->getString()) < 32768) { strcat(dummy, val->getString()); @@ -93,7 +93,7 @@ const char *CSXArray::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Push ////////////////////////////////////////////////////////////////////////// @@ -134,7 +134,7 @@ bool CSXArray::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSt ////////////////////////////////////////////////////////////////////////// -CScValue *CSXArray::scGetProperty(const char *name) { +ScValue *SXArray::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -166,7 +166,7 @@ CScValue *CSXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::scSetProperty(const char *name, CScValue *value) { +bool SXArray::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// @@ -199,8 +199,8 @@ bool CSXArray::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::persist(CBPersistMgr *persistMgr) { - CBScriptable::persist(persistMgr); +bool SXArray::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_length)); persistMgr->transfer(TMEMBER(_values)); @@ -210,7 +210,7 @@ bool CSXArray::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CSXArray::validNumber(const char *origStr, char *outStr) { +bool SXArray::validNumber(const char *origStr, char *outStr) { bool isNumber = true; for (uint32 i = 0; i < strlen(origStr); i++) { if (!(origStr[i] >= '0' && origStr[i] <= '9')) { @@ -227,7 +227,7 @@ bool CSXArray::validNumber(const char *origStr, char *outStr) { } ////////////////////////////////////////////////////////////////////////// -bool CSXArray::push(CScValue *val) { +bool SXArray::push(ScValue *val) { char paramName[20]; _length++; sprintf(paramName, "%d", _length - 1); diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index b873416572..3f8d703f85 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -33,20 +33,20 @@ namespace WinterMute { -class CSXArray : public CBScriptable { +class SXArray : public BaseScriptable { public: - bool push(CScValue *Val); + bool push(ScValue *Val); bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(CSXArray, CBScriptable) - CSXArray(CBGame *inGame, CScStack *stack); - CSXArray(CBGame *inGame); - virtual ~CSXArray(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXArray, BaseScriptable) + SXArray(BaseGame *inGame, ScStack *stack); + SXArray(BaseGame *inGame); + virtual ~SXArray(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); int _length; - CScValue *_values; + ScValue *_values; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 211c0d34f0..322fb9bc5b 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -32,19 +32,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXDate, false) +IMPLEMENT_PERSISTENT(SXDate, false) -CBScriptable *makeSXDate(CBGame *inGame, CScStack *stack) { - return new CSXDate(inGame, stack); +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { + return new SXDate(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXDate::SXDate(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); - CScValue *valYear = stack->pop(); + ScValue *valYear = stack->pop(); _tm.tm_year = valYear->getInt() - 1900; _tm.tm_mon = stack->pop()->getInt() - 1; _tm.tm_mday = stack->pop()->getInt(); @@ -59,12 +59,12 @@ CSXDate::CSXDate(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXDate::~CSXDate() { +SXDate::~SXDate() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXDate::scToString() { +const char *SXDate::scToString() { // TODO: Make this more stringy, and less ISO 8601-like _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); return _strRep.c_str(); @@ -75,7 +75,7 @@ const char *CSXDate::scToString() { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // GetYear ////////////////////////////////////////////////////////////////////////// @@ -207,7 +207,7 @@ bool CSXDate::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// -CScValue *CSXDate::scGetProperty(const char *name) { +ScValue *SXDate::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -223,7 +223,7 @@ CScValue *CSXDate::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::scSetProperty(const char *name, CScValue *value) { +bool SXDate::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Name @@ -238,9 +238,9 @@ bool CSXDate::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXDate::persist(CBPersistMgr *persistMgr) { +bool SXDate::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_tm.tm_year)); persistMgr->transfer(TMEMBER(_tm.tm_mon)); persistMgr->transfer(TMEMBER(_tm.tm_mday)); @@ -251,9 +251,9 @@ bool CSXDate::persist(CBPersistMgr *persistMgr) { } ////////////////////////////////////////////////////////////////////////// -int CSXDate::scCompare(CBScriptable *Value) { +int SXDate::scCompare(BaseScriptable *Value) { TimeDate time1 = _tm; - TimeDate time2 = ((CSXDate *)Value)->_tm; + TimeDate time2 = ((SXDate *)Value)->_tm; if (time1.tm_year < time2.tm_year) { return -1; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 82f6af1f1d..b2df4abe94 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -34,15 +34,15 @@ namespace WinterMute { -class CSXDate : public CBScriptable { +class SXDate : public BaseScriptable { public: - int scCompare(CBScriptable *Value); - DECLARE_PERSISTENT(CSXDate, CBScriptable) - CSXDate(CBGame *inGame, CScStack *Stack); - virtual ~CSXDate(); - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + int scCompare(BaseScriptable *Value); + DECLARE_PERSISTENT(SXDate, BaseScriptable) + SXDate(BaseGame *inGame, ScStack *Stack); + virtual ~SXDate(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); char *_string; TimeDate _tm; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 58c0416b43..ffa362a938 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -42,19 +42,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXFile, false) +IMPLEMENT_PERSISTENT(SXFile, false) -CBScriptable *makeSXFile(CBGame *inGame, CScStack *stack) { - return new CSXFile(inGame, stack); +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { + return new SXFile(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); - CScValue *Val = stack->pop(); + ScValue *Val = stack->pop(); _filename = NULL; - if (!Val->isNULL()) CBUtils::setString(&_filename, Val->getString()); + if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString()); _readFile = NULL; _writeFile = NULL; @@ -65,12 +65,12 @@ CSXFile::CSXFile(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXFile::~CSXFile() { +SXFile::~SXFile() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void CSXFile::cleanup() { +void SXFile::cleanup() { delete[] _filename; _filename = NULL; close(); @@ -78,7 +78,7 @@ void CSXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// -void CSXFile::close() { +void SXFile::close() { if (_readFile) { _gameRef->_fileManager->closeFile(_readFile); _readFile = NULL; @@ -93,14 +93,14 @@ void CSXFile::close() { } ////////////////////////////////////////////////////////////////////////// -const char *CSXFile::scToString() { +const char *SXFile::scToString() { if (_filename) return _filename; else return "[file object]"; } #define FILE_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// -bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetFilename ////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta stack->correctParams(1); const char *filename = stack->pop()->getString(); cleanup(); - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); stack->pushNULL(); return STATUS_OK; } @@ -182,7 +182,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); close(); - stack->pushBool(CBPlatform::deleteFile(_filename) != false); + stack->pushBool(BasePlatform::deleteFile(_filename) != false); return STATUS_OK; } @@ -195,7 +195,7 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta bool Overwrite = stack->pop()->getBool(true); close(); - stack->pushBool(CBPlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); return STATUS_OK; } @@ -593,12 +593,12 @@ bool CSXFile::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta } - else return CBScriptable::scCallMethod(script, stack, thisStack, name); + else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// -CScValue *CSXFile::scGetProperty(const char *name) { +ScValue *SXFile::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -649,12 +649,12 @@ CScValue *CSXFile::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::scSetProperty(const char *name, CScValue *value) { +bool SXFile::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -672,11 +672,11 @@ bool CSXFile::scSetProperty(const char *name, CScValue *value) { } return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getPos() { +uint32 SXFile::getPos() { if (_mode == 1 && _readFile) return _readFile->pos(); else if ((_mode == 2 || _mode == 3) && _writeFile) { @@ -689,11 +689,11 @@ uint32 CSXFile::getPos() { } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::setPos(uint32 pos, int whence) { +bool SXFile::setPos(uint32 pos, int whence) { if (_mode == 1 && _readFile) return _readFile->seek(pos, whence); else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - seeking in WriteFile not supported"); + error("SXFile - seeking in WriteFile not supported"); return false; // return fseek((FILE *)_writeFile, pos, (int)origin) == 0; } @@ -701,11 +701,11 @@ bool CSXFile::setPos(uint32 pos, int whence) { } ////////////////////////////////////////////////////////////////////////// -uint32 CSXFile::getLength() { +uint32 SXFile::getLength() { if (_mode == 1 && _readFile) return _readFile->size(); else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("CSXFile - reading length for WriteFile not supported"); + error("SXFile - reading length for WriteFile not supported"); return 0; /* uint32 currentPos = ftell((FILE *)_writeFile); @@ -717,9 +717,9 @@ uint32 CSXFile::getLength() { } ////////////////////////////////////////////////////////////////////////// -bool CSXFile::persist(CBPersistMgr *persistMgr) { +bool SXFile::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_mode)); @@ -767,12 +767,12 @@ bool CSXFile::persist(CBPersistMgr *persistMgr) { } // Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *CSXFile::openForWrite(const Common::String &filename, bool binary) { +Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool binary) { error("SXFile::openForWrite - WriteFiles not supported"); } // Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *CSXFile::openForAppend(const Common::String &filename, bool binary) { +Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { error("SXFile::openForAppend - WriteFiles not supported"); } diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index 5a6811fe57..4d78feb044 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -35,17 +35,17 @@ namespace WinterMute { -class CBFile; +class BaseFile; -class CSXFile : public CBScriptable { +class SXFile : public BaseScriptable { public: - DECLARE_PERSISTENT(CSXFile, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXFile, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); - CSXFile(CBGame *inGame, CScStack *Stack); - virtual ~CSXFile(); + SXFile(BaseGame *inGame, ScStack *Stack); + virtual ~SXFile(); private: Common::SeekableReadStream *_readFile; Common::WriteStream *_writeFile; diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 22b08087b7..1c37a15aa9 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -40,26 +40,26 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CSXMath, true) +IMPLEMENT_PERSISTENT(SXMath, true) -CBScriptable *makeSXMath(CBGame *inGame) { - return new CSXMath(inGame); +BaseScriptable *makeSXMath(BaseGame *inGame) { + return new SXMath(inGame); } ////////////////////////////////////////////////////////////////////////// -CSXMath::CSXMath(CBGame *inGame): CBScriptable(inGame) { +SXMath::SXMath(BaseGame *inGame): BaseScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -CSXMath::~CSXMath() { +SXMath::~SXMath() { } ////////////////////////////////////////////////////////////////////////// -bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Abs ////////////////////////////////////////////////////////////////////////// @@ -250,7 +250,7 @@ bool CSXMath::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisSta ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMath::scGetProperty(const char *name) { +ScValue *SXMath::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -274,21 +274,21 @@ CScValue *CSXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -double CSXMath::degreeToRadian(double value) { +double SXMath::degreeToRadian(double value) { return value * (M_PI / 180.0f); } ////////////////////////////////////////////////////////////////////////// -double CSXMath::radianToDegree(double value) { +double SXMath::radianToDegree(double value) { return value * (180.0f / M_PI); } ////////////////////////////////////////////////////////////////////////// -bool CSXMath::persist(CBPersistMgr *persistMgr) { +bool SXMath::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index 422521233f..393342e5ca 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -34,13 +34,13 @@ namespace WinterMute { -class CSXMath : public CBScriptable { +class SXMath : public BaseScriptable { public: - DECLARE_PERSISTENT(CSXMath, CBScriptable) - CSXMath(CBGame *inGame); - virtual ~CSXMath(); - virtual CScValue *scGetProperty(const char *name); - virtual bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + DECLARE_PERSISTENT(SXMath, BaseScriptable) + SXMath(BaseGame *inGame); + virtual ~SXMath(); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); private: double degreeToRadian(double value); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index df2bf188ff..79ba978002 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -35,14 +35,14 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXMemBuffer, false) +IMPLEMENT_PERSISTENT(SXMemBuffer, false) -CBScriptable *makeSXMemBuffer(CBGame *inGame, CScStack *stack) { - return new CSXMemBuffer(inGame, stack); +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { + return new SXMemBuffer(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); _buffer = NULL; _size = 0; @@ -52,31 +52,31 @@ CSXMemBuffer::CSXMemBuffer(CBGame *inGame, CScStack *stack): CBScriptable(inGame } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::CSXMemBuffer(CBGame *inGame, void *Buffer): CBScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *Buffer): BaseScriptable(inGame) { _size = 0; _buffer = Buffer; } ////////////////////////////////////////////////////////////////////////// -CSXMemBuffer::~CSXMemBuffer() { +SXMemBuffer::~SXMemBuffer() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -void *CSXMemBuffer::scToMemBuffer() { +void *SXMemBuffer::scToMemBuffer() { return _buffer; } ////////////////////////////////////////////////////////////////////////// -void CSXMemBuffer::cleanup() { +void SXMemBuffer::cleanup() { if (_size) free(_buffer); _buffer = NULL; _size = 0; } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::resize(int newSize) { +bool SXMemBuffer::resize(int newSize) { int oldSize = _size; if (_size == 0) { @@ -102,7 +102,7 @@ bool CSXMemBuffer::resize(int newSize) { } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { +bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { if (_buffer == NULL) { script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; @@ -118,13 +118,13 @@ bool CSXMemBuffer::checkBounds(CScScript *script, int start, int length) { } ////////////////////////////////////////////////////////////////////////// -const char *CSXMemBuffer::scToString() { +const char *SXMemBuffer::scToString() { return "[membuffer object]"; } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // SetSize ////////////////////////////////////////////////////////////////////////// @@ -264,7 +264,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th stack->pushNULL(); else { void *pointer = *(void **)((byte *)_buffer + start); - CSXMemBuffer *buf = new CSXMemBuffer(_gameRef, pointer); + SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); stack->pushNative(buf, false); } return STATUS_OK; @@ -395,7 +395,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); int start = stack->pop()->getInt(); - /* CScValue *Val = */ stack->pop(); + /* ScValue *Val = */ stack->pop(); if (!checkBounds(script, start, sizeof(void *))) stack->pushBool(false); @@ -433,7 +433,7 @@ bool CSXMemBuffer::scCallMethod(CScScript *script, CScStack *stack, CScStack *th ////////////////////////////////////////////////////////////////////////// -CScValue *CSXMemBuffer::scGetProperty(const char *name) { +ScValue *SXMemBuffer::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -452,12 +452,12 @@ CScValue *CSXMemBuffer::scGetProperty(const char *name) { return _scValue; } - else return CBScriptable::scGetProperty(name); + else return BaseScriptable::scGetProperty(name); } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { +bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { /* ////////////////////////////////////////////////////////////////////////// // Length @@ -475,14 +475,14 @@ bool CSXMemBuffer::scSetProperty(const char *name, CScValue *value) { } return STATUS_OK; } - else*/ return CBScriptable::scSetProperty(name, value); + else*/ return BaseScriptable::scSetProperty(name, value); } ////////////////////////////////////////////////////////////////////////// -bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { +bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_size)); @@ -500,7 +500,7 @@ bool CSXMemBuffer::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXMemBuffer::scCompare(CBScriptable *val) { +int SXMemBuffer::scCompare(BaseScriptable *val) { if (_buffer == val->scToMemBuffer()) return 0; else return 1; } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index a9d78e50e4..c325181e3f 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -34,24 +34,24 @@ namespace WinterMute { -class CSXMemBuffer : public CBScriptable { +class SXMemBuffer : public BaseScriptable { public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXMemBuffer, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); - CSXMemBuffer(CBGame *inGame, CScStack *stack); - CSXMemBuffer(CBGame *inGame, void *buffer); - virtual ~CSXMemBuffer(); + SXMemBuffer(BaseGame *inGame, ScStack *stack); + SXMemBuffer(BaseGame *inGame, void *buffer); + virtual ~SXMemBuffer(); virtual void *scToMemBuffer(); int _size; private: bool resize(int newSize); void *_buffer; void cleanup(); - bool checkBounds(CScScript *script, int start, int length); + bool checkBounds(ScScript *script, int start, int length); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index cb0d32d1a3..b72e3e4b97 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -36,14 +36,14 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CSXObject, false) +IMPLEMENT_PERSISTENT(SXObject, false) -CBScriptable *makeSXObject(CBGame *inGame, CScStack *stack) { - return new CSXObject(inGame, stack); +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { + return new SXObject(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { +SXObject::SXObject(BaseGame *inGame, ScStack *stack): BaseObject(inGame) { int numParams = stack->pop()->getInt(0); for (int i = 0; i < numParams; i++) { addScript(stack->pop()->getString()); @@ -52,14 +52,14 @@ CSXObject::CSXObject(CBGame *inGame, CScStack *stack): CBObject(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXObject::~CSXObject() { +SXObject::~SXObject() { } ////////////////////////////////////////////////////////////////////////// -bool CSXObject::persist(CBPersistMgr *persistMgr) { - CBObject::persist(persistMgr); +bool SXObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index b4e869d5b3..d744c58042 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -34,11 +34,11 @@ namespace WinterMute { -class CSXObject : public CBObject { +class SXObject : public BaseObject { public: - DECLARE_PERSISTENT(CSXObject, CBObject) - CSXObject(CBGame *inGame, CScStack *Stack); - virtual ~CSXObject(); + DECLARE_PERSISTENT(SXObject, BaseObject) + SXObject(BaseGame *inGame, ScStack *Stack); + virtual ~SXObject(); }; diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index bd7541fadd..e645772b6f 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -37,19 +37,19 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CSXString, false) +IMPLEMENT_PERSISTENT(SXString, false) -CBScriptable *makeSXString(CBGame *inGame, CScStack *stack) { - return new CSXString(inGame, stack); +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { + return new SXString(inGame, stack); } ////////////////////////////////////////////////////////////////////////// -CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { +SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { _string = NULL; _capacity = 0; stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); if (val->isInt()) { _capacity = MAX(0, val->getInt()); @@ -66,13 +66,13 @@ CSXString::CSXString(CBGame *inGame, CScStack *stack): CBScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// -CSXString::~CSXString() { +SXString::~SXString() { if (_string) delete [] _string; } ////////////////////////////////////////////////////////////////////////// -void CSXString::setStringVal(const char *val) { +void SXString::setStringVal(const char *val) { int len = strlen(val); if (len >= _capacity) { _capacity = len + 1; @@ -86,20 +86,20 @@ void CSXString::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// -const char *CSXString::scToString() { +const char *SXString::scToString() { if (_string) return _string; else return "[null string]"; } ////////////////////////////////////////////////////////////////////////// -void CSXString::scSetString(const char *val) { +void SXString::scSetString(const char *val) { setStringVal(val); } ////////////////////////////////////////////////////////////////////////// -bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name) { +bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { ////////////////////////////////////////////////////////////////////////// // Substring ////////////////////////////////////////////////////////////////////////// @@ -108,7 +108,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS int start = stack->pop()->getInt(); int end = stack->pop()->getInt(); - if (end < start) CBUtils::swap(&start, &end); + if (end < start) BaseUtils::swap(&start, &end); //try { WideString str; @@ -138,7 +138,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS stack->correctParams(2); int start = stack->pop()->getInt(); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); int len = val->getInt(); if (!val->isNULL() && len <= 0) { @@ -245,11 +245,11 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Split") == 0) { stack->correctParams(1); - CScValue *val = stack->pop(); + ScValue *val = stack->pop(); char separators[MAX_PATH_LENGTH] = ","; if (!val->isNULL()) strcpy(separators, val->getString()); - CSXArray *array = new CSXArray(_gameRef); + SXArray *array = new SXArray(_gameRef); if (!array) { stack->pushNULL(); return STATUS_OK; @@ -299,9 +299,9 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS WideString &part = (*it); if (_gameRef->_textEncoding == TEXT_UTF8) - val = new CScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); else - val = new CScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); array->push(val); delete val; @@ -317,7 +317,7 @@ bool CSXString::scCallMethod(CScScript *script, CScStack *stack, CScStack *thisS ////////////////////////////////////////////////////////////////////////// -CScValue *CSXString::scGetProperty(const char *name) { +ScValue *SXString::scGetProperty(const char *name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -352,7 +352,7 @@ CScValue *CSXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CSXString::scSetProperty(const char *name, CScValue *value) { +bool SXString::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// @@ -377,9 +377,9 @@ bool CSXString::scSetProperty(const char *name, CScValue *value) { ////////////////////////////////////////////////////////////////////////// -bool CSXString::persist(CBPersistMgr *persistMgr) { +bool SXString::persist(BasePersistenceManager *persistMgr) { - CBScriptable::persist(persistMgr); + BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_capacity)); @@ -397,8 +397,8 @@ bool CSXString::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -int CSXString::scCompare(CBScriptable *val) { - return strcmp(_string, ((CSXString *)val)->_string); +int SXString::scCompare(BaseScriptable *val) { + return strcmp(_string, ((SXString *)val)->_string); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 52a1524dde..9a3bbfc80b 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -34,19 +34,19 @@ namespace WinterMute { -class CSXString : public CBScriptable { +class SXString : public BaseScriptable { public: - virtual int scCompare(CBScriptable *Val); - DECLARE_PERSISTENT(CSXString, CBScriptable) - CScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, CScValue *value); - bool scCallMethod(CScScript *script, CScStack *stack, CScStack *thisStack, const char *name); + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXString, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); void scSetString(const char *val); const char *scToString(); void setStringVal(const char *val); - CSXString(CBGame *inGame, CScStack *Stack); - virtual ~CSXString(); + SXString(BaseGame *inGame, ScStack *Stack); + virtual ~SXString(); private: char *_string; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 188cb2d15c..74cc7a57ee 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -32,16 +32,16 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CScStack, false) +IMPLEMENT_PERSISTENT(ScStack, false) ////////////////////////////////////////////////////////////////////////// -CScStack::CScStack(CBGame *inGame): CBBase(inGame) { +ScStack::ScStack(BaseGame *inGame): BaseClass(inGame) { _sP = -1; } ////////////////////////////////////////////////////////////////////////// -CScStack::~CScStack() { +ScStack::~ScStack() { #if _DEBUG //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); @@ -55,7 +55,7 @@ CScStack::~CScStack() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::pop() { +ScValue *ScStack::pop() { if (_sP < 0) { _gameRef->LOG(0, "Fatal: Stack underflow"); return NULL; @@ -66,14 +66,14 @@ CScValue *CScStack::pop() { ////////////////////////////////////////////////////////////////////////// -void CScStack::push(CScValue *val) { +void ScStack::push(ScValue *val) { _sP++; if (_sP < _values.getSize()) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { - CScValue *copyVal = new CScValue(_gameRef); + ScValue *copyVal = new ScValue(_gameRef); copyVal->copy(val); _values.add(copyVal); } @@ -81,11 +81,11 @@ void CScStack::push(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getPushValue() { +ScValue *ScStack::getPushValue() { _sP++; if (_sP >= _values.getSize()) { - CScValue *val = new CScValue(_gameRef); + ScValue *val = new ScValue(_gameRef); _values.add(val); } _values[_sP]->cleanup(); @@ -95,14 +95,14 @@ CScValue *CScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getTop() { +ScValue *ScStack::getTop() { if (_sP < 0 || _sP >= _values.getSize()) return NULL; else return _values[_sP]; } ////////////////////////////////////////////////////////////////////////// -CScValue *CScStack::getAt(int index) { +ScValue *ScStack::getAt(int index) { index = _sP - index; if (index < 0 || index >= _values.getSize()) return NULL; else return _values[index]; @@ -110,7 +110,7 @@ CScValue *CScStack::getAt(int index) { ////////////////////////////////////////////////////////////////////////// -void CScStack::correctParams(uint32 expectedParams) { +void ScStack::correctParams(uint32 expectedParams) { uint32 nuParams = (uint32)pop()->getInt(); if (expectedParams < nuParams) { // too many params @@ -124,7 +124,7 @@ void CScStack::correctParams(uint32 expectedParams) { } else if (expectedParams > nuParams) { // need more params while (expectedParams > nuParams) { //Push(null_val); - CScValue *nullVal = new CScValue(_gameRef); + ScValue *nullVal = new ScValue(_gameRef); nullVal->setNULL(); _values.insertAt(_sP - nuParams + 1, nullVal); nuParams++; @@ -140,9 +140,9 @@ void CScStack::correctParams(uint32 expectedParams) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushNULL() { +void ScStack::pushNULL() { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setNULL(); Push(val); delete val; @@ -152,9 +152,9 @@ void CScStack::pushNULL() { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushInt(int val) { +void ScStack::pushInt(int val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setInt(Val); Push(val); delete val; @@ -164,9 +164,9 @@ void CScStack::pushInt(int val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushFloat(double val) { +void ScStack::pushFloat(double val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setFloat(Val); Push(val); delete val; @@ -176,9 +176,9 @@ void CScStack::pushFloat(double val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushBool(bool val) { +void ScStack::pushBool(bool val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setBool(Val); Push(val); delete val; @@ -188,9 +188,9 @@ void CScStack::pushBool(bool val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushString(const char *val) { +void ScStack::pushString(const char *val) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setString(Val); Push(val); delete val; @@ -200,9 +200,9 @@ void CScStack::pushString(const char *val) { ////////////////////////////////////////////////////////////////////////// -void CScStack::pushNative(CBScriptable *val, bool persistent) { +void ScStack::pushNative(BaseScriptable *val, bool persistent) { /* - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->setNative(Val, Persistent); Push(val); delete val; @@ -213,7 +213,7 @@ void CScStack::pushNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -bool CScStack::persist(CBPersistMgr *persistMgr) { +bool ScStack::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 6460f901fe..3aacad0765 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -36,27 +36,27 @@ namespace WinterMute { -class CScValue; -class CBScriptable; +class ScValue; +class BaseScriptable; -class CScStack : public CBBase { +class ScStack : public BaseClass { public: - CScValue *getAt(int Index); - CScValue *getPushValue(); - DECLARE_PERSISTENT(CScStack, CBBase) - void pushNative(CBScriptable *val, bool persistent); + ScValue *getAt(int Index); + ScValue *getPushValue(); + DECLARE_PERSISTENT(ScStack, BaseClass) + void pushNative(BaseScriptable *val, bool persistent); void pushString(const char *val); void pushBool(bool val); void pushInt(int val); void pushFloat(double val); void pushNULL(); void correctParams(uint32 expectedParams); - CScValue *getTop(); - void push(CScValue *val); - CScValue *pop(); - CScStack(CBGame *inGame); - virtual ~CScStack(); - CBArray _values; + ScValue *getTop(); + void push(ScValue *val); + ScValue *pop(); + ScStack(BaseGame *inGame); + virtual ~ScStack(); + BaseArray _values; int _sP; }; diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index da47ed299f..0d8c34e719 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -40,10 +40,10 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -IMPLEMENT_PERSISTENT(CScValue, false) +IMPLEMENT_PERSISTENT(ScValue, false) ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { _type = VAL_NULL; _valBool = false; @@ -58,7 +58,7 @@ CScValue::CScValue(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { _type = VAL_BOOL; _valBool = val; @@ -73,7 +73,7 @@ CScValue::CScValue(CBGame *inGame, bool val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { _type = VAL_INT; _valInt = val; @@ -88,7 +88,7 @@ CScValue::CScValue(CBGame *inGame, int val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { _type = VAL_FLOAT; _valFloat = val; @@ -103,7 +103,7 @@ CScValue::CScValue(CBGame *inGame, double val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { +ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { _type = VAL_STRING; _valString = NULL; setStringVal(val); @@ -119,7 +119,7 @@ CScValue::CScValue(CBGame *inGame, const char *val): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -void CScValue::cleanup(bool ignoreNatives) { +void ScValue::cleanup(bool ignoreNatives) { deleteProps(); if (_valString) delete [] _valString; @@ -150,13 +150,13 @@ void CScValue::cleanup(bool ignoreNatives) { ////////////////////////////////////////////////////////////////////////// -CScValue::~CScValue() { +ScValue::~ScValue() { cleanup(); } ////////////////////////////////////////////////////////////////////////// -CScValue *CScValue::getProp(const char *name) { +ScValue *ScValue::getProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); if (_type == VAL_STRING && strcmp(name, "Length") == 0) { @@ -176,7 +176,7 @@ CScValue *CScValue::getProp(const char *name) { return _gameRef->_scValue; } - CScValue *ret = NULL; + ScValue *ret = NULL; if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); @@ -188,7 +188,7 @@ CScValue *CScValue::getProp(const char *name) { } ////////////////////////////////////////////////////////////////////////// -bool CScValue::deleteProp(const char *name) { +bool ScValue::deleteProp(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); _valIter = _valObject.find(name); @@ -203,7 +203,7 @@ bool CScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool setAsConst) { +bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { if (_type == VAL_VARIABLE_REF) return _valRef->setProp(name, val); @@ -213,14 +213,14 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set } if (DID_FAIL(ret)) { - CScValue *newVal = NULL; + ScValue *newVal = NULL; _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { newVal = _valIter->_value; } if (!newVal) - newVal = new CScValue(_gameRef); + newVal = new ScValue(_gameRef); else newVal->cleanup(); newVal->copy(val, copyWhole); @@ -235,7 +235,7 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set delete _valIter->_value; _valIter->_value = NULL; } - CScValue* val = new CScValue(_gameRef); + ScValue* val = new ScValue(_gameRef); val->Copy(Val, CopyWhole); val->_isConstVar = SetAsConst; _valObject[Name] = val; @@ -249,7 +249,7 @@ bool CScValue::setProp(const char *name, CScValue *val, bool copyWhole, bool set ////////////////////////////////////////////////////////////////////////// -bool CScValue::propExists(const char *name) { +bool ScValue::propExists(const char *name) { if (_type == VAL_VARIABLE_REF) return _valRef->propExists(name); _valIter = _valObject.find(name); @@ -259,10 +259,10 @@ bool CScValue::propExists(const char *name) { ////////////////////////////////////////////////////////////////////////// -void CScValue::deleteProps() { +void ScValue::deleteProps() { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - delete(CScValue *)_valIter->_value; + delete(ScValue *)_valIter->_value; _valIter++; } _valObject.clear(); @@ -270,7 +270,7 @@ void CScValue::deleteProps() { ////////////////////////////////////////////////////////////////////////// -void CScValue::CleanProps(bool includingNatives) { +void ScValue::CleanProps(bool includingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); @@ -279,7 +279,7 @@ void CScValue::CleanProps(bool includingNatives) { } ////////////////////////////////////////////////////////////////////////// -bool CScValue::isNULL() { +bool ScValue::isNULL() { if (_type == VAL_VARIABLE_REF) return _valRef->isNULL(); @@ -288,7 +288,7 @@ bool CScValue::isNULL() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isNative() { +bool ScValue::isNative() { if (_type == VAL_VARIABLE_REF) return _valRef->isNative(); @@ -297,7 +297,7 @@ bool CScValue::isNative() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isString() { +bool ScValue::isString() { if (_type == VAL_VARIABLE_REF) return _valRef->isString(); @@ -306,7 +306,7 @@ bool CScValue::isString() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isFloat() { +bool ScValue::isFloat() { if (_type == VAL_VARIABLE_REF) return _valRef->isFloat(); @@ -315,7 +315,7 @@ bool CScValue::isFloat() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isInt() { +bool ScValue::isInt() { if (_type == VAL_VARIABLE_REF) return _valRef->isInt(); @@ -324,7 +324,7 @@ bool CScValue::isInt() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isBool() { +bool ScValue::isBool() { if (_type == VAL_VARIABLE_REF) return _valRef->isBool(); @@ -333,7 +333,7 @@ bool CScValue::isBool() { ////////////////////////////////////////////////////////////////////////// -bool CScValue::isObject() { +bool ScValue::isObject() { if (_type == VAL_VARIABLE_REF) return _valRef->isObject(); @@ -342,7 +342,7 @@ bool CScValue::isObject() { ////////////////////////////////////////////////////////////////////////// -TValType CScValue::getTypeTolerant() { +TValType ScValue::getTypeTolerant() { if (_type == VAL_VARIABLE_REF) return _valRef->getType(); @@ -351,7 +351,7 @@ TValType CScValue::getTypeTolerant() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setBool(bool val) { +void ScValue::setBool(bool val) { if (_type == VAL_VARIABLE_REF) { _valRef->setBool(val); return; @@ -368,7 +368,7 @@ void CScValue::setBool(bool val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setInt(int val) { +void ScValue::setInt(int val) { if (_type == VAL_VARIABLE_REF) { _valRef->setInt(val); return; @@ -385,7 +385,7 @@ void CScValue::setInt(int val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setFloat(double val) { +void ScValue::setFloat(double val) { if (_type == VAL_VARIABLE_REF) { _valRef->setFloat(val); return; @@ -402,7 +402,7 @@ void CScValue::setFloat(double val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setString(const char *val) { +void ScValue::setString(const char *val) { if (_type == VAL_VARIABLE_REF) { _valRef->setString(val); return; @@ -418,12 +418,12 @@ void CScValue::setString(const char *val) { else _type = VAL_NULL; } -void CScValue::setString(const Common::String &val) { +void ScValue::setString(const Common::String &val) { setString(val.c_str()); } ////////////////////////////////////////////////////////////////////////// -void CScValue::setStringVal(const char *val) { +void ScValue::setStringVal(const char *val) { if (_valString) { delete [] _valString; _valString = NULL; @@ -442,7 +442,7 @@ void CScValue::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setNULL() { +void ScValue::setNULL() { if (_type == VAL_VARIABLE_REF) { _valRef->setNULL(); return; @@ -460,7 +460,7 @@ void CScValue::setNULL() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setNative(CBScriptable *val, bool persistent) { +void ScValue::setNative(BaseScriptable *val, bool persistent) { if (_type == VAL_VARIABLE_REF) { _valRef->setNative(val, persistent); return; @@ -487,7 +487,7 @@ void CScValue::setNative(CBScriptable *val, bool persistent) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setObject() { +void ScValue::setObject() { if (_type == VAL_VARIABLE_REF) { _valRef->setObject(); return; @@ -499,14 +499,14 @@ void CScValue::setObject() { ////////////////////////////////////////////////////////////////////////// -void CScValue::setReference(CScValue *val) { +void ScValue::setReference(ScValue *val) { _valRef = val; _type = VAL_VARIABLE_REF; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::getBool(bool defaultVal) { +bool ScValue::getBool(bool defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getBool(); @@ -533,7 +533,7 @@ bool CScValue::getBool(bool defaultVal) { ////////////////////////////////////////////////////////////////////////// -int CScValue::getInt(int defaultVal) { +int ScValue::getInt(int defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); switch (_type) { @@ -559,7 +559,7 @@ int CScValue::getInt(int defaultVal) { ////////////////////////////////////////////////////////////////////////// -double CScValue::getFloat(double defaultVal) { +double ScValue::getFloat(double defaultVal) { if (_type == VAL_VARIABLE_REF) return _valRef->getFloat(); @@ -585,7 +585,7 @@ double CScValue::getFloat(double defaultVal) { } ////////////////////////////////////////////////////////////////////////// -void *CScValue::getMemBuffer() { +void *ScValue::getMemBuffer() { if (_type == VAL_VARIABLE_REF) return _valRef->getMemBuffer(); @@ -596,7 +596,7 @@ void *CScValue::getMemBuffer() { ////////////////////////////////////////////////////////////////////////// -const char *CScValue::getString() { +const char *ScValue::getString() { if (_type == VAL_VARIABLE_REF) return _valRef->getString(); @@ -646,7 +646,7 @@ const char *CScValue::getString() { ////////////////////////////////////////////////////////////////////////// -CBScriptable *CScValue::getNative() { +BaseScriptable *ScValue::getNative() { if (_type == VAL_VARIABLE_REF) return _valRef->getNative(); @@ -656,13 +656,13 @@ CBScriptable *CScValue::getNative() { ////////////////////////////////////////////////////////////////////////// -TValType CScValue::getType() { +TValType ScValue::getType() { return _type; } ////////////////////////////////////////////////////////////////////////// -void CScValue::copy(CScValue *orig, bool copyWhole) { +void ScValue::copy(ScValue *orig, bool copyWhole) { _gameRef = orig->_gameRef; if (_valNative && !_persistent) { @@ -694,7 +694,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) { if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { orig->_valIter = orig->_valObject.begin(); while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new CScValue(_gameRef); + _valObject[orig->_valIter->_key] = new ScValue(_gameRef); _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } @@ -703,7 +703,7 @@ void CScValue::copy(CScValue *orig, bool copyWhole) { ////////////////////////////////////////////////////////////////////////// -void CScValue::setValue(CScValue *val) { +void ScValue::setValue(ScValue *val) { if (val->_type == VAL_VARIABLE_REF) { setValue(val->_valRef); return; @@ -725,7 +725,7 @@ void CScValue::setValue(CScValue *val) { _valNative->scSetString(val->getString()); break; default: - warning("CScValue::setValue - unhandled enum"); + warning("ScValue::setValue - unhandled enum"); break; } } @@ -735,7 +735,7 @@ void CScValue::setValue(CScValue *val) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::persist(CBPersistMgr *persistMgr) { +bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_persistent)); @@ -760,7 +760,7 @@ bool CScValue::persist(CBPersistMgr *persistMgr) { _valIter++; } } else { - CScValue *val; + ScValue *val; persistMgr->transfer("", &size); for (int i = 0; i < size; i++) { persistMgr->transfer("", &str); @@ -819,7 +819,7 @@ bool CScValue::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { +bool ScValue::saveAsText(BaseDynamicBuffer *buffer, int indent) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { buffer->putTextIndent(indent, "PROPERTY {\n"); @@ -835,7 +835,7 @@ bool CScValue::saveAsText(CBDynBuffer *buffer, int indent) { ////////////////////////////////////////////////////////////////////////// // -1 ... left is less, 0 ... equals, 1 ... left is greater -int CScValue::compare(CScValue *val1, CScValue *val2) { +int ScValue::compare(ScValue *val1, ScValue *val2) { // both natives? if (val1->isNative() && val2->isNative()) { // same class? @@ -871,14 +871,14 @@ int CScValue::compare(CScValue *val1, CScValue *val2) { ////////////////////////////////////////////////////////////////////////// -int CScValue::compareStrict(CScValue *val1, CScValue *val2) { +int ScValue::compareStrict(ScValue *val1, ScValue *val2) { if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return CScValue::compare(val1, val2); + else return ScValue::compare(val1, val2); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID) { +bool ScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); @@ -889,24 +889,24 @@ bool CScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableTyp ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, int value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, int value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, const char *value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, const char *value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, double value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, double value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -914,8 +914,8 @@ bool CScValue::setProperty(const char *propName, double value) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName, bool value) { - CScValue *val = new CScValue(_gameRef, value); +bool ScValue::setProperty(const char *propName, bool value) { + ScValue *val = new ScValue(_gameRef, value); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -923,8 +923,8 @@ bool CScValue::setProperty(const char *propName, bool value) { ////////////////////////////////////////////////////////////////////////// -bool CScValue::setProperty(const char *propName) { - CScValue *val = new CScValue(_gameRef); +bool ScValue::setProperty(const char *propName) { + ScValue *val = new ScValue(_gameRef); bool ret = DID_SUCCEED(setProp(propName, val)); delete val; return ret; @@ -934,7 +934,7 @@ bool CScValue::setProperty(const char *propName) { ////////////////////////////////////////////////////////////////////////// // IWmeDebugProp ////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType CScValue::dbgGetType() { +EWmeDebuggerPropType ScValue::dbgGetType() { switch (getType()) { case VAL_NULL: return WME_DBGPROP_NULL; @@ -956,70 +956,70 @@ EWmeDebuggerPropType CScValue::dbgGetType() { } ////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetValInt() { +int ScValue::dbgGetValInt() { return getInt(); } ////////////////////////////////////////////////////////////////////////// -double CScValue::dbgGetValFloat() { +double ScValue::dbgGetValFloat() { return getFloat(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetValBool() { +bool ScValue::dbgGetValBool() { return getBool(); } ////////////////////////////////////////////////////////////////////////// -const char *CScValue::dbgGetValString() { +const char *ScValue::dbgGetValString() { return getString(); } ////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *CScValue::dbgGetValNative() { +IWmeDebugObject *ScValue::dbgGetValNative() { return getNative(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(int value) { +bool ScValue::dbgSetVal(int value) { setInt(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(double value) { +bool ScValue::dbgSetVal(double value) { setFloat(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(bool value) { +bool ScValue::dbgSetVal(bool value) { setBool(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal(const char *value) { +bool ScValue::dbgSetVal(const char *value) { setString(value); return true; } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgSetVal() { +bool ScValue::dbgSetVal() { setNULL(); return true; } ////////////////////////////////////////////////////////////////////////// -int CScValue::dbgGetNumProperties() { +int ScValue::dbgGetNumProperties() { if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetNumProperties(); else return _valObject.size(); } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { +bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { if (_valNative && _valNative->_scProp) return _valNative->_scProp->dbgGetProperty(index, name, value); else { @@ -1039,7 +1039,7 @@ bool CScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **valu } ////////////////////////////////////////////////////////////////////////// -bool CScValue::dbgGetDescription(char *buf, int bufSize) { +bool ScValue::dbgGetDescription(char *buf, int bufSize) { if (_type == VAL_VARIABLE_REF) return _valRef->dbgGetDescription(buf, bufSize); diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index eaee3ed773..7a684d2334 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -38,25 +38,25 @@ namespace WinterMute { -class CScScript; -class CBScriptable; +class ScScript; +class BaseScriptable; -class CScValue : public CBBase, public IWmeDebugProp { +class ScValue : public BaseClass, public IWmeDebugProp { public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, CScScript *script, unsigned int scopeID); + bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID); - static int compare(CScValue *val1, CScValue *val2); - static int compareStrict(CScValue *val1, CScValue *val2); + static int compare(ScValue *val1, ScValue *val2); + static int compareStrict(ScValue *val1, ScValue *val2); TValType getTypeTolerant(); void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(CScValue, CBBase) + DECLARE_PERSISTENT(ScValue, BaseClass) bool _isConstVar; - bool saveAsText(CBDynBuffer *buffer, int indent); - void setValue(CScValue *val); + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + void setValue(ScValue *val); bool _persistent; bool propExists(const char *name); - void copy(CScValue *orig, bool copyWhole = false); + void copy(ScValue *orig, bool copyWhole = false); void setStringVal(const char *val); TValType getType(); bool getBool(bool defaultVal = false); @@ -64,7 +64,7 @@ public: double getFloat(double defaultVal = 0.0f); const char *getString(); void *getMemBuffer(); - CBScriptable *getNative(); + BaseScriptable *getNative(); bool deleteProp(const char *name); void deleteProps(); void CleanProps(bool includingNatives); @@ -74,9 +74,9 @@ public: void setString(const char *val); void setString(const Common::String &val); void setNULL(); - void setNative(CBScriptable *val, bool persistent = false); + void setNative(BaseScriptable *val, bool persistent = false); void setObject(); - void setReference(CScValue *val); + void setReference(ScValue *val); bool isNULL(); bool isNative(); bool isString(); @@ -84,10 +84,10 @@ public: bool isFloat(); bool isInt(); bool isObject(); - bool setProp(const char *name, CScValue *val, bool copyWhole = false, bool setAsConst = false); - CScValue *getProp(const char *name); - CBScriptable *_valNative; - CScValue *_valRef; + bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); + ScValue *getProp(const char *name); + BaseScriptable *_valNative; + ScValue *_valRef; protected: bool _valBool; int _valInt; @@ -95,14 +95,14 @@ protected: char *_valString; public: TValType _type; - CScValue(CBGame *inGame); - CScValue(CBGame *inGame, bool Val); - CScValue(CBGame *inGame, int Val); - CScValue(CBGame *inGame, double Val); - CScValue(CBGame *inGame, const char *Val); - virtual ~CScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; + ScValue(BaseGame *inGame); + ScValue(BaseGame *inGame, bool Val); + ScValue(BaseGame *inGame, int Val); + ScValue(BaseGame *inGame, double Val); + ScValue(BaseGame *inGame, const char *Val); + virtual ~ScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; bool setProperty(const char *propName, int value); bool setProperty(const char *propName, const char *value); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index e1819e3c65..06421e8632 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -33,10 +33,10 @@ namespace WinterMute { -IMPLEMENT_PERSISTENT(CBSound, false) +IMPLEMENT_PERSISTENT(BaseSound, false) ////////////////////////////////////////////////////////////////////////// -CBSound::CBSound(CBGame *inGame): CBBase(inGame) { +BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { _sound = NULL; _soundFilename = NULL; @@ -56,7 +56,7 @@ CBSound::CBSound(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBSound::~CBSound() { +BaseSound::~BaseSound() { if (_sound) _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; @@ -66,7 +66,7 @@ CBSound::~CBSound() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; @@ -88,7 +88,7 @@ bool CBSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool ////////////////////////////////////////////////////////////////////////// -bool CBSound::setSoundSimple() { +bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { if (_soundPosition) _sound->setPosition(_soundPosition); @@ -104,14 +104,14 @@ bool CBSound::setSoundSimple() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getLength() { +uint32 BaseSound::getLength() { if (_sound) return _sound->getLength(); else return 0; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::play(bool looping) { +bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); @@ -120,7 +120,7 @@ bool CBSound::play(bool looping) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::stop() { +bool BaseSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); @@ -129,7 +129,7 @@ bool CBSound::stop() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::pause(bool freezePaused) { +bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; if (freezePaused) _sound->_freezePaused = true; @@ -139,7 +139,7 @@ bool CBSound::pause(bool freezePaused) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::resume() { +bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); @@ -148,7 +148,7 @@ bool CBSound::resume() { ////////////////////////////////////////////////////////////////////////// -bool CBSound::persist(CBPersistMgr *persistMgr) { +bool BaseSound::persist(BasePersistenceManager *persistMgr) { if (persistMgr->_saving && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; @@ -182,19 +182,19 @@ bool CBSound::persist(CBPersistMgr *persistMgr) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::isPlaying() { +bool BaseSound::isPlaying() { return _sound && _sound->isPlaying(); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::isPaused() { +bool BaseSound::isPaused() { return _sound && _soundPaused; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPositionTime(uint32 time) { +bool BaseSound::setPositionTime(uint32 time) { if (!_sound) return STATUS_FAILED; _soundPosition = time; bool ret = _sound->setPosition(_soundPosition); @@ -205,7 +205,7 @@ bool CBSound::setPositionTime(uint32 time) { ////////////////////////////////////////////////////////////////////////// -uint32 CBSound::getPositionTime() { +uint32 BaseSound::getPositionTime() { if (!_sound) return 0; if (!_sound->isPlaying()) @@ -214,42 +214,42 @@ uint32 CBSound::getPositionTime() { } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolumePercent(int percent) { +bool BaseSound::setVolumePercent(int percent) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setVolume(int volume) { +bool BaseSound::setVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->setPrivateVolume(volume); } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPrivateVolume(int volume) { +bool BaseSound::setPrivateVolume(int volume) { if (!_sound) return STATUS_FAILED; else return _sound->_privateVolume = volume; } ////////////////////////////////////////////////////////////////////////// -int CBSound::getVolumePercent() { +int BaseSound::getVolumePercent() { if (!_sound) return 0; else return _sound->_privateVolume * 100 / 255; } ////////////////////////////////////////////////////////////////////////// -int CBSound::getVolume() { +int BaseSound::getVolume() { if (!_sound) return 0; else return _sound->_privateVolume; } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setLoopStart(uint32 pos) { +bool BaseSound::setLoopStart(uint32 pos) { if (!_sound) return STATUS_FAILED; else { @@ -259,7 +259,7 @@ bool CBSound::setLoopStart(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -bool CBSound::setPan(float pan) { +bool BaseSound::setPan(float pan) { if (_sound) return _sound->setPan(pan); else return STATUS_FAILED; @@ -267,7 +267,7 @@ bool CBSound::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// -bool CBSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { +bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) return STATUS_OK; diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index ef52194090..0b033de47d 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -36,8 +36,8 @@ namespace WinterMute { -class CBSoundBuffer; -class CBSound : public CBBase { +class BaseSoundBuffer; +class BaseSound : public BaseClass { public: bool setPan(float pan); int _soundPrivateVolume; @@ -57,7 +57,7 @@ public: bool _soundLooping; uint32 _soundLoopStart; uint32 _soundPosition; - DECLARE_PERSISTENT(CBSound, CBBase) + DECLARE_PERSISTENT(BaseSound, BaseClass) bool resume(); bool pause(bool freezePaused = false); bool stop(); @@ -68,8 +68,8 @@ public: char *_soundFilename; bool setSoundSimple(); bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - CBSound(CBGame *inGame); - virtual ~CBSound(); + BaseSound(BaseGame *inGame); + virtual ~BaseSound(); bool ApplyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); @@ -79,7 +79,7 @@ private: float _sFXParam2; float _sFXParam3; float _sFXParam4; - CBSoundBuffer *_sound; + BaseSoundBuffer *_sound; }; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index a868f99823..b8c19c2985 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -50,7 +50,7 @@ namespace WinterMute { #define MAX_NONSTREAMED_FILE_SIZE 1024*1024 ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { _stream = NULL; _handle = NULL; // _sync = NULL; @@ -71,7 +71,7 @@ CBSoundBuffer::CBSoundBuffer(CBGame *inGame): CBBase(inGame) { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer::~CBSoundBuffer() { +BaseSoundBuffer::~BaseSoundBuffer() { stop(); if (_handle) { @@ -88,13 +88,13 @@ CBSoundBuffer::~CBSoundBuffer() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { +void BaseSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 BlockSize) { _streamed = Streamed; } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { +bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); #if 0 if (_stream) { @@ -132,15 +132,15 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { if (!_stream) { return STATUS_FAILED; } - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); return STATUS_OK; #if 0 BASS_FILEPROCS fileProc; - fileProc.close = CBSoundBuffer::FileCloseProc; - fileProc.read = CBSoundBuffer::FileReadProc; - fileProc.seek = CBSoundBuffer::FileSeekProc; - fileProc.length = CBSoundBuffer::FileLenProc; + fileProc.close = BaseSoundBuffer::FileCloseProc; + fileProc.read = BaseSoundBuffer::FileReadProc; + fileProc.seek = BaseSoundBuffer::FileSeekProc; + fileProc.length = BaseSoundBuffer::FileLenProc; _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); if (!_stream) { @@ -148,7 +148,7 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { return STATUS_FAILED; } - CBUtils::setString(&_filename, filename); + BaseUtils::setString(&_filename, filename); /* bool res; @@ -196,7 +196,7 @@ bool CBSoundBuffer::loadFromFile(const char *filename, bool forceReload) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::play(bool looping, uint32 startSample) { +bool BaseSoundBuffer::play(bool looping, uint32 startSample) { if (startSample != 0) { warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); } @@ -220,7 +220,7 @@ bool CBSoundBuffer::play(bool looping, uint32 startSample) { } ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setLooping(bool looping) { +void BaseSoundBuffer::setLooping(bool looping) { warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); _looping = looping; #if 0 @@ -233,7 +233,7 @@ void CBSoundBuffer::setLooping(bool looping) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::resume() { +bool BaseSoundBuffer::resume() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); } @@ -242,7 +242,7 @@ bool CBSoundBuffer::resume() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::stop() { +bool BaseSoundBuffer::stop() { if (_stream && _handle) { g_system->getMixer()->stopHandle(*_handle); } @@ -251,7 +251,7 @@ bool CBSoundBuffer::stop() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::pause() { +bool BaseSoundBuffer::pause() { if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, true); } @@ -260,7 +260,7 @@ bool CBSoundBuffer::pause() { } ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getLength() { +uint32 BaseSoundBuffer::getLength() { if (_stream) { uint32 len = _stream->getLength().msecs(); return len * 1000; @@ -270,17 +270,17 @@ uint32 CBSoundBuffer::getLength() { ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::setType(Audio::Mixer::SoundType type) { +void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { _type = type; } ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::updateVolume() { +void BaseSoundBuffer::updateVolume() { setVolume(_privateVolume); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setVolume(int volume) { +bool BaseSoundBuffer::setVolume(int volume) { _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; if (_stream && _handle) { byte vol = (byte)(_volume); @@ -291,14 +291,14 @@ bool CBSoundBuffer::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPrivateVolume(int volume) { +bool BaseSoundBuffer::setPrivateVolume(int volume) { _privateVolume = volume; return setVolume(_privateVolume); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::isPlaying() { +bool BaseSoundBuffer::isPlaying() { if (_stream && _handle) { return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); } else { @@ -308,7 +308,7 @@ bool CBSoundBuffer::isPlaying() { ////////////////////////////////////////////////////////////////////////// -uint32 CBSoundBuffer::getPosition() { +uint32 BaseSoundBuffer::getPosition() { if (_stream && _handle) { uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); return pos; @@ -318,8 +318,8 @@ uint32 CBSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPosition(uint32 pos) { - warning("CBSoundBuffer::SetPosition - not implemented yet"); +bool BaseSoundBuffer::setPosition(uint32 pos) { + warning("BaseSoundBuffer::SetPosition - not implemented yet"); #if 0 if (_stream) { QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); @@ -330,7 +330,7 @@ bool CBSoundBuffer::setPosition(uint32 pos) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setLoopStart(uint32 pos) { +bool BaseSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; #if 0 if (_stream) { @@ -340,7 +340,7 @@ bool CBSoundBuffer::setLoopStart(uint32 pos) { } if (_loopStart > 0) { QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, CBSoundBuffer::LoopSyncProc, (void *)this); + _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, BaseSoundBuffer::LoopSyncProc, (void *)this); } } #endif @@ -348,8 +348,8 @@ bool CBSoundBuffer::setLoopStart(uint32 pos) { } #if 0 ////////////////////////////////////////////////////////////////////////// -void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - CBSoundBuffer *soundBuf = static_cast(user); +void BaseSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { + BaseSoundBuffer *soundBuf = static_cast(user); QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) @@ -357,7 +357,7 @@ void CBSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void } #endif ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::setPan(float pan) { +bool BaseSoundBuffer::setPan(float pan) { if (_handle) { g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); } @@ -365,8 +365,8 @@ bool CBSoundBuffer::setPan(float pan) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("CBSoundBuffer::ApplyFX - not implemented yet"); +bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + warning("BaseSoundBuffer::ApplyFX - not implemented yet"); switch (type) { case SFX_ECHO: break; diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index a491bd49ad..9c85a02b39 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -41,12 +41,12 @@ class SoundHandle; namespace WinterMute { -class CBFile; -class CBSoundBuffer : public CBBase { +class BaseFile; +class BaseSoundBuffer : public BaseClass { public: - CBSoundBuffer(CBGame *inGame); - virtual ~CBSoundBuffer(); + BaseSoundBuffer(BaseGame *inGame); + virtual ~BaseSoundBuffer(); bool pause(); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index c2174dea6a..22b22a5db6 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -44,24 +44,24 @@ namespace WinterMute { // Construction/Destruction ////////////////////////////////////////////////////////////////////// -//IMPLEMENT_PERSISTENT(CBSoundMgr, true); +//IMPLEMENT_PERSISTENT(BaseSoundMgr, true); ////////////////////////////////////////////////////////////////////////// -CBSoundMgr::CBSoundMgr(CBGame *inGame): CBBase(inGame) { +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame): BaseClass(inGame) { _soundAvailable = false; _volumeMaster = 255; } ////////////////////////////////////////////////////////////////////////// -CBSoundMgr::~CBSoundMgr() { +BaseSoundMgr::~BaseSoundMgr() { saveSettings(); cleanup(); } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::cleanup() { +bool BaseSoundMgr::cleanup() { for (uint32 i = 0; i < _sounds.size(); i++) delete _sounds[i]; _sounds.clear(); @@ -72,14 +72,14 @@ bool CBSoundMgr::cleanup() { } ////////////////////////////////////////////////////////////////////////// -void CBSoundMgr::saveSettings() { +void BaseSoundMgr::saveSettings() { if (_soundAvailable) { _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); } } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initialize() { +bool BaseSoundMgr::initialize() { _soundAvailable = false; if (!g_system->getMixer()->isReady()) { @@ -93,7 +93,7 @@ bool CBSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::initLoop() { +bool BaseSoundMgr::initLoop() { if (!_soundAvailable) return STATUS_OK; #if 0 @@ -105,11 +105,11 @@ bool CBSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// -CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) return NULL; - CBSoundBuffer *sound; + BaseSoundBuffer *sound; // try to switch WAV to OGG file (if available) AnsiString ext = PathUtil::getExtension(filename); @@ -123,7 +123,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp } } - sound = new CBSoundBuffer(_gameRef); + sound = new BaseSoundBuffer(_gameRef); if (!sound) return NULL; sound->setStreaming(streamed); @@ -149,7 +149,7 @@ CBSoundBuffer *CBSoundMgr::addSound(const char *filename, Audio::Mixer::SoundTyp } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { +bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { if (!sound) return STATUS_FAILED; @@ -163,7 +163,7 @@ bool CBSoundMgr::addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { +bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i] == sound) { delete _sounds[i]; @@ -177,7 +177,7 @@ bool CBSoundMgr::removeSound(CBSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { +bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { if (!_soundAvailable) return STATUS_OK; @@ -200,13 +200,13 @@ bool CBSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { +bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { return setVolume(type, percent * 255 / 100); } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { +byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { int volume = 0; switch (type) { @@ -225,7 +225,7 @@ byte CBSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolume(byte value) { +bool BaseSoundMgr::setMasterVolume(byte value) { _volumeMaster = value; for (uint32 i = 0; i < _sounds.size(); i++) { _sounds[i]->updateVolume(); @@ -234,25 +234,25 @@ bool CBSoundMgr::setMasterVolume(byte value) { } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::setMasterVolumePercent(byte percent) { +bool BaseSoundMgr::setMasterVolumePercent(byte percent) { setMasterVolume(percent * 255 / 100); return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolumePercent() { +byte BaseSoundMgr::getMasterVolumePercent() { return getMasterVolume() * 100 / 255; } ////////////////////////////////////////////////////////////////////////// -byte CBSoundMgr::getMasterVolume() { +byte BaseSoundMgr::getMasterVolume() { return (byte)_volumeMaster; } ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::pauseAll(bool includingMusic) { +bool BaseSoundMgr::pauseAll(bool includingMusic) { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { @@ -266,7 +266,7 @@ bool CBSoundMgr::pauseAll(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// -bool CBSoundMgr::resumeAll() { +bool BaseSoundMgr::resumeAll() { for (uint32 i = 0; i < _sounds.size(); i++) { if (_sounds[i]->_freezePaused) { @@ -280,7 +280,7 @@ bool CBSoundMgr::resumeAll() { ////////////////////////////////////////////////////////////////////////// -float CBSoundMgr::posToPan(int x, int y) { +float BaseSoundMgr::posToPan(int x, int y) { float relPos = (float)x / ((float)_gameRef->_renderer->_width); float minPan = -0.7f; diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 2c05bbfcb8..53caffbe61 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -35,14 +35,14 @@ #include "common/array.h" namespace WinterMute { -class CBSoundBuffer; -class CBSoundMgr : public CBBase { +class BaseSoundBuffer; +class BaseSoundMgr : public BaseClass { public: float posToPan(int x, int y); bool resumeAll(); bool pauseAll(bool includingMusic = true); bool cleanup(); - //DECLARE_PERSISTENT(CBSoundMgr, CBBase); + //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); byte getMasterVolumePercent(); byte getMasterVolume(); bool setMasterVolume(byte percent); @@ -52,15 +52,15 @@ public: bool setVolume(Audio::Mixer::SoundType type, int volume); uint32 _volumeOriginal; int _volumeMaster; - bool removeSound(CBSoundBuffer *sound); - CBSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(CBSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool removeSound(BaseSoundBuffer *sound); + BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); bool initLoop(); bool initialize(); bool _soundAvailable; - CBSoundMgr(CBGame *inGame); - virtual ~CBSoundMgr(); - Common::Array _sounds; + BaseSoundMgr(BaseGame *inGame); + virtual ~BaseSoundMgr(); + Common::Array _sounds; void saveSettings(); }; -- cgit v1.2.3 From f54f262bb56d251d131109a81cad7811e240ff4f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 21 Jul 2012 21:17:08 +0200 Subject: WINTERMUTE: Fix a few signed/unsigned and float->int warnings. --- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index a913cc52ba..cb3468c4f3 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -97,8 +97,8 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; - for (int i = 0; i < str.size(); i++) { - textWidth += getCharWidth(str[i]); + for (int i = 0; (uint32)i < str.size(); i++) { + textWidth += getCharWidth((byte)str[i]); } return textWidth; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 212f11d2f6..54e612ff42 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -168,7 +168,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 else scale = BaseUtils::randomFloat(_scale1, _scale2); int lifeTime; - if (_lifeTimeZBased) lifeTime = _lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100; + if (_lifeTimeZBased) lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); float angle = BaseUtils::randomAngle(_angle1, _angle2); -- cgit v1.2.3 From 742521c20db68e965761ba9309bb0a3dea379217 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 07:24:48 +0200 Subject: WINTERMUTE: Redo base_file_manager, to use FSLists for registering/opening packages. This is helpfull for consistency between registering and lookup, and allows for explicit removal/adding of sub_paths for the engine. But most importantly it keeps the loading consistent and non-duplicated for detection. --- engines/wintermute/base/base_file_manager.cpp | 171 +++++++++++------------- engines/wintermute/base/base_file_manager.h | 14 +- engines/wintermute/base/file/base_disk_file.cpp | 57 +++----- engines/wintermute/base/file/base_package.cpp | 4 +- engines/wintermute/base/file/base_package.h | 2 +- 5 files changed, 108 insertions(+), 140 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index a2c81b8a8c..4dcc1c6948 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -50,6 +50,7 @@ #include "common/fs.h" #include "common/file.h" #include "common/savefile.h" +#include "common/fs.h" namespace WinterMute { @@ -75,15 +76,8 @@ BaseFileManager::~BaseFileManager() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::cleanup() { // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); - - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; _packagePaths.clear(); - // delete file entries _filesIter = _files.begin(); while (_filesIter != _files.end()) { @@ -226,7 +220,7 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { // unmount all non-local packages for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cD > 0) _packages[i]->close(); + if (_packages[i]->_cd > 0) _packages[i]->close(); } @@ -235,24 +229,25 @@ bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::addPath(TPathType type, const Common::String &path) { - if (path.c_str() == NULL || strlen(path.c_str()) < 1) return STATUS_FAILED; +bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { + if (path.getName().c_str() == NULL || strlen(path.getName().c_str()) < 1) return STATUS_FAILED; - bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); +// bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; +/* char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; if (buffer == NULL) return STATUS_FAILED; strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\"); + if (!slashed) strcat(buffer, "\\");*/ //BasePlatform::strlwr(buffer); switch (type) { case PATH_SINGLE: - _singlePaths.push_back(buffer); + // _singlePaths.push_back(path); + error("TODO: Allow adding single-paths"); break; case PATH_PACKAGE: - _packagePaths.push_back(buffer); + _packagePaths.push_back(path); break; } @@ -262,12 +257,12 @@ bool BaseFileManager::addPath(TPathType type, const Common::String &path) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::reloadPaths() { // delete registered paths - for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i]; - _singlePaths.clear(); +/* for (uint32 i = 0; i < _singlePaths.size(); i++) + delete [] _singlePaths[i];*/ + //_singlePaths.clear(); - for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i]; +/* for (uint32 i = 0; i < _packagePaths.size(); i++) + delete [] _packagePaths[i];*/ _packagePaths.clear(); return initPaths(); @@ -289,16 +284,17 @@ bool BaseFileManager::initPaths() { for (int i = 0; i < numPaths; i++) { char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - addPath(PATH_SINGLE, path); + error("BaseFileManager::initPaths - Game wants to add customPath: %s", path); // TODO +// addPath(PATH_SINGLE, path); } delete[] path; path = NULL; } - addPath(PATH_SINGLE, ".\\"); - +// addPath(PATH_SINGLE, ".\\"); // package files paths - addPath(PATH_PACKAGE, "./"); + const Common::FSNode gameData(ConfMan.get("path")); + addPath(PATH_PACKAGE, gameData); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); @@ -306,16 +302,32 @@ bool BaseFileManager::initPaths() { for (int i = 0; i < numPaths; i++) { char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); if (path && strlen(path) > 0) { - addPath(PATH_PACKAGE, path); + error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path); // TODO +// addPath(PATH_PACKAGE, path); } delete[] path; path = NULL; } - addPath(PATH_PACKAGE, "data"); + + Common::FSNode dataSubFolder = gameData.getChild("data"); + if (dataSubFolder.exists()) { + addPath(PATH_PACKAGE, dataSubFolder); + } return STATUS_OK; } +bool BaseFileManager::registerPackages(const Common::FSList &fslist) { + for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { + warning("Adding %s", (*it).getName().c_str()); + if ((*it).getName().contains(".dcp")) { + if (registerPackage((*it).createReadStream())) { + addPath(PATH_PACKAGE, (*it)); + } + } + } + warning(" Registered %d files in %d package(s)", _files.size(), _packages.size()); +} ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { @@ -324,11 +336,24 @@ bool BaseFileManager::registerPackages() { _gameRef->LOG(0, "Scanning packages..."); debugC(kWinterMuteDebugFileAccess, "Scanning packages"); - Common::ArchiveMemberList files; +/* Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, "*.dcp"); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { registerPackage((*it)->getName().c_str()); + }*/ + // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail + // and that has to be like that to support the detection-scheme. + Common::FSList files; + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + (*it).getChildren(files, Common::FSNode::kListFilesOnly); + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { + if (!fileIt->getName().contains(".dcp")) + continue; + warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + registerPackage((*fileIt).createReadStream()); + } } #if 0 AnsiString extension = AnsiString(PACKAGE_EXTENSION); @@ -373,7 +398,10 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); return STATUS_OK; } + return registerPackage(package, filename); +} +bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; @@ -392,25 +420,25 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear TPackageHeader hdr; hdr.readFromStream(package); // package->read(&hdr, sizeof(TPackageHeader), 1, f); - if (hdr.Magic1 != PACKAGE_MAGIC_1 || hdr.Magic2 != PACKAGE_MAGIC_2 || hdr.PackageVersion > PACKAGE_VERSION) { + if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return STATUS_OK; } - if (hdr.PackageVersion != PACKAGE_VERSION) { + if (hdr._packageVersion != PACKAGE_VERSION) { _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { uint32 dirOffset; dirOffset = package->readUint32LE(); dirOffset += absoluteOffset; package->seek(dirOffset, SEEK_SET); } - for (uint32 i = 0; i < hdr.NumDirs; i++) { + for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(_gameRef); if (!pkg) return STATUS_FAILED; @@ -420,10 +448,10 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear byte nameLength = package->readByte(); pkg->_name = new char[nameLength]; package->read(pkg->_name, nameLength); - pkg->_cD = package->readByte(); - pkg->_priority = hdr.Priority; + pkg->_cd = package->readByte(); + pkg->_priority = hdr._priority; - if (!hdr.MasterIndex) pkg->_cD = 0; // override CD to fixed disk + if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk _packages.push_back(pkg); @@ -439,7 +467,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear package->read(name, nameLength); // v2 - xor name - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { for (int k = 0; k < nameLength; k++) { ((byte *)name)[k] ^= 'D'; } @@ -458,7 +486,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear compLength = package->readUint32LE(); flags = package->readUint32LE(); - if (hdr.PackageVersion == PACKAGE_VERSION) { + if (hdr._packageVersion == PACKAGE_VERSION) { timeDate1 = package->readUint32LE(); timeDate2 = package->readUint32LE(); } @@ -474,7 +502,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear _files[name] = file; } else { // current package has lower CD number or higher priority, than the registered - if (pkg->_cD < _filesIter->_value->_package->_cD || pkg->_priority > _filesIter->_value->_package->_priority) { + if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { _filesIter->_value->_package = pkg; _filesIter->_value->_offset = offset; _filesIter->_value->_length = length; @@ -511,13 +539,21 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { Common::File *ret = new Common::File(); char filename[MAX_PATH_LENGTH]; - for (uint32 i = 0; i < _packagePaths.size(); i++) { + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + Common::String packageName = (*it).getName(); + if (packageName == (name + ".dcp")) + ret->open((*it)); + if (ret->isOpen()) { + return ret; + } + } +/* for (uint32 i = 0; i < _packagePaths.size(); i++) { sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; } - } + }*/ sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); @@ -530,61 +566,6 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { } -////////////////////////////////////////////////////////////////////////// -Common::File *BaseFileManager::openSingleFile(const Common::String &name) { - restoreCurrentDir(); - - Common::File *ret = NULL; - char filename[MAX_PATH_LENGTH]; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(filename, "%s%s", _singlePaths[i], name.c_str()); - ret->open(filename); - if (ret->isOpen()) - return ret; - } - - // didn't find in search paths, try to open directly - ret->open(name); - if (ret->isOpen()) { - return ret; - } else { - delete ret; - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::getFullPath(const Common::String &filename, char *fullname) { - restoreCurrentDir(); - - Common::File f; - bool found = false; - - for (uint32 i = 0; i < _singlePaths.size(); i++) { - sprintf(fullname, "%s%s", _singlePaths[i], filename.c_str()); - f.open(fullname); - if (f.isOpen()) { - f.close(); - found = true; - break; - } - } - - if (!found) { - f.open(filename.c_str()); - if (f.isOpen()) { - f.close(); - found = true; - strcpy(fullname, filename.c_str()); - } - } - - return found; -} - - ////////////////////////////////////////////////////////////////////////// BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { char *upc_name = new char[strlen(filename.c_str()) + 1]; @@ -703,7 +684,7 @@ bool BaseFileManager::setBasePath(const Common::String &path) { ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::findPackageSignature(Common::File *f, uint32 *offset) { +bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; byte signature[8]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 469108bee8..78e6cb737f 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -32,6 +32,7 @@ #include "engines/wintermute/base/file/base_file_entry.h" #include "common/archive.h" #include "common/str.h" +#include "common/fs.h" namespace Common { class File; @@ -41,39 +42,38 @@ namespace WinterMute { class BaseFile; class BaseFileManager: BaseClass { public: - bool findPackageSignature(Common::File *f, uint32 *offset); + bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool cleanup(); bool setBasePath(const Common::String &path); bool restoreCurrentDir(); char *_basePath; - bool getFullPath(const Common::String &filename, char *fullname); Common::SeekableReadStream *openFileRaw(const Common::String &filename); bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); BaseFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openSingleFile(const Common::String &name); Common::File *openPackage(const Common::String &name); + bool registerPackages(const Common::FSList &fslist); bool registerPackages(); bool initPaths(); bool reloadPaths(); typedef enum { PATH_PACKAGE, PATH_SINGLE } TPathType; - bool addPath(TPathType type, const Common::String &path); + bool addPath(TPathType type, const Common::FSNode &path); bool requestCD(int cd, char *packageFile, const char *filename); Common::SeekableReadStream *loadSaveGame(const Common::String &filename); bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); BaseFileManager(BaseGame *inGame = NULL); virtual ~BaseFileManager(); - Common::Array _singlePaths; - Common::Array _packagePaths; +// Common::FSList _singlePaths; + Common::FSList _packagePaths; Common::Array _packages; Common::Array _openFiles; - Common::HashMap _files; private: + bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; bool isValidPackage(const AnsiString &fileName) const; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 6c89fc22f1..b4653c2c80 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -36,6 +36,7 @@ #include "common/memstream.h" #include "common/file.h" #include "common/zlib.h" +#include "common/archive.h" namespace WinterMute { @@ -50,27 +51,13 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - for (uint32 i = 0; i < fileManager->_singlePaths.size(); i++) { - sprintf(fullPath, "%s%s", fileManager->_singlePaths[i], filename.c_str()); - correctSlashes(fullPath); - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; - } - } - - // if we didn't find it in search paths, try to open directly - if (!file) { - strcpy(fullPath, filename.c_str()); - correctSlashes(fullPath); - - Common::File *tempFile = new Common::File(); - if (tempFile->open(fullPath)) { - file = tempFile; - } else { - delete tempFile; + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + file = (*it)->createReadStream(); + break; } } @@ -83,38 +70,38 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; if (compressed) { - uint32 DataOffset, CompSize, UncompSize; - DataOffset = file->readUint32LE(); - CompSize = file->readUint32LE(); - UncompSize = file->readUint32LE(); + uint32 dataOffset, compSize, uncompSize; + dataOffset = file->readUint32LE(); + compSize = file->readUint32LE(); + uncompSize = file->readUint32LE(); - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { + byte *compBuffer = new byte[compSize]; + if (!compBuffer) { error("Error allocating memory for compressed file '%s'", filename.c_str()); delete file; return NULL; } - byte *data = new byte[UncompSize]; + byte *data = new byte[uncompSize]; if (!data) { error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] CompBuffer; + delete [] compBuffer; delete file; return NULL; } - file->seek(DataOffset + prefixSize, SEEK_SET); - file->read(CompBuffer, CompSize); + file->seek(dataOffset + prefixSize, SEEK_SET); + file->read(compBuffer, compSize); - if (Common::uncompress(data, (unsigned long *)&UncompSize, CompBuffer, CompSize) != true) { + if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); - delete [] CompBuffer; + delete [] compBuffer; delete file; return NULL; } - delete [] CompBuffer; + delete [] compBuffer; - return new Common::MemoryReadStream(data, UncompSize, DisposeAfterUse::YES); + return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); delete file; file = NULL; } else { diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 03a80f3d8d..24f7c23422 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -43,7 +43,7 @@ namespace WinterMute { BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { _file = NULL; _name = NULL; - _cD = 0; + _cd = 0; _priority = 0; _boundToExe = false; } @@ -89,7 +89,7 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu Common::SeekableReadStream *BasePackage::getFilePointer() { Common::File *file = _gameRef->_fileManager->openPackage(_name); if (!file) { - _gameRef->_fileManager->requestCD(_cD, _name, ""); + _gameRef->_fileManager->requestCD(_cd, _name, ""); file = _gameRef->_fileManager->openPackage(_name); } return file; diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index bf45087f91..2f305ea049 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -49,7 +49,7 @@ public: bool close(); bool open(); char *_name; - int _cD; + int _cd; Common::SeekableReadStream *_file; BasePackage(BaseGame *inGame); virtual ~BasePackage(); -- cgit v1.2.3 From a549977cffae9a5f1be41d9b07d42908648e8f6d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 21:02:25 +0200 Subject: WINTERMUTE: Use FSNodes to parse relative paths used by the games. --- engines/wintermute/base/file/base_disk_file.cpp | 28 +++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index b4653c2c80..d1a8f02fa5 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -37,6 +37,8 @@ #include "common/file.h" #include "common/zlib.h" #include "common/archive.h" +#include "common/tokenizer.h" +#include "common/config-manager.h" namespace WinterMute { @@ -50,7 +52,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; - + // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); @@ -60,7 +62,29 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil break; } } - + // The filename can be an explicit path, thus we need to chop it up, expecting the path the game + // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + if (!file) { + if (filename.contains(':')) + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + if (filename.contains('\\')) { + Common::StringTokenizer path(filename, "\\"); + + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSNode curNode = gameDataDir; + while (!path.empty()) { + Common::String pathPart = path.nextToken(); + Common::FSNode nextNode(curNode.getChild(pathPart)); + if (nextNode.exists() && nextNode.isReadable()) { + curNode = nextNode; + } + if (!curNode.isDirectory()) { + file = curNode.createReadStream(); + break; + } + } + } + } if (file) { uint32 magic1, magic2; magic1 = file->readUint32LE(); -- cgit v1.2.3 From 3bcbd1881c9a22a594707726154c568d187e313b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:27:07 +0200 Subject: WINTERMUTE: Avoid opening files when checking hasFile() --- engines/wintermute/base/base_file_manager.cpp | 13 +++++---- engines/wintermute/base/file/base_disk_file.cpp | 37 +++++++++++++++++++++++++ engines/wintermute/base/file/base_disk_file.h | 1 + engines/wintermute/base/file/base_resources.cpp | 19 ++++++++++--- engines/wintermute/base/file/base_resources.h | 3 +- 5 files changed, 62 insertions(+), 11 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 4dcc1c6948..f651835fe4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -582,12 +582,13 @@ BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) } bool BaseFileManager::hasFile(const Common::String &filename) { - //TODO: Do this in a much simpler fashion - Common::SeekableReadStream *stream = openFile(filename, true, false); - if (!stream) { - return false; - } - delete stream; + if (diskFileExists(filename)) + return true; + if (getPackageEntry(filename)) + return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. + if (BaseResources::hasFile(filename)) + return true; + return false; return true; } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index d1a8f02fa5..c20fd9f342 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -48,6 +48,43 @@ void correctSlashes(char *fileName) { } } +bool diskFileExists(const Common::String& filename) { + Common::SeekableReadStream *file = NULL; + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + return true; + } + } + // The filename can be an explicit path, thus we need to chop it up, expecting the path the game + // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + if (filename.contains(':')) + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + if (filename.contains('\\')) { + Common::StringTokenizer path(filename, "\\"); + + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSNode curNode = gameDataDir; + while (!path.empty()) { + Common::String pathPart = path.nextToken(); + Common::FSNode nextNode(curNode.getChild(pathPart)); + if (nextNode.exists() && nextNode.isReadable()) { + curNode = nextNode; + } + if (!curNode.isDirectory()) { + if (curNode.exists() && curNode.isReadable()) + return true; + else + return false; + } + } + } + return false; +} + Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index e688a12b50..b0ba32cb84 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -36,6 +36,7 @@ class SeekableReadStream; namespace WinterMute { Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); +bool diskFileExists(const Common::String& filename); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 9b1c9fee04..f7aaf6393a 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2806,15 +2806,26 @@ unsigned char systemfont[] = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 } ; -Common::SeekableReadStream *BaseResources::getFile(const Common::String &fileName) { - if (scumm_stricmp(fileName.c_str(), "invalid.bmp") == 0) { +Common::SeekableReadStream *BaseResources::getFile(const Common::String &filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "invalid_debug.bmp") == 0) { + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(fileName.c_str(), "syste_font.bmp") == 0) { + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); } return NULL; } +bool BaseResources::hasFile(const Common::String& filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { + return true; + } + return false; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 6316cecd15..2959f9882f 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -36,7 +36,8 @@ namespace WinterMute { class BaseResources { public: - static Common::SeekableReadStream *getFile(const Common::String &fileName); + static Common::SeekableReadStream *getFile(const Common::String &filename); + static bool hasFile(const Common::String& filename); }; } // end of namespace WinterMute -- cgit v1.2.3 From 4c3421288d2d74396579f35b25a7b78e14afa7f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:29:07 +0200 Subject: WINTERMUTE: Add an audio-debug-channel and reduce the use of warning() --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/sound/base_sound_buffer.cpp | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f651835fe4..0a59a3b134 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -472,7 +472,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const ((byte *)name)[k] ^= 'D'; } } - + debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory name[nameLength - 1] = '\0'; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index b8c19c2985..e1dba2120d 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/base/sound/base_sound_buffer.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" #include "audio/audiostream.h" #include "audio/mixer.h" #include "audio/decoders/vorbis.h" @@ -95,13 +96,7 @@ void BaseSoundBuffer::setStreaming(bool Streamed, uint32 NumBlocks, uint32 Block ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - warning("BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); -#if 0 - if (_stream) { - BASS_StreamFree(_stream); - _stream = NULL; - } -#endif + debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = _gameRef->_fileManager->openFile(filename, true, false); @@ -123,11 +118,11 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _file = new Common::SeekableSubReadStream(_file, 0, waveSize); _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); } else { - warning("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); } } } else { - warning("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); } if (!_stream) { return STATUS_FAILED; -- cgit v1.2.3 From 30ada3c13f63ef35ccdd21ca76fb45aa9fb1dc3c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:31:02 +0200 Subject: WINTERMUTE: Check for failure when decoding images. --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 8 ++++++-- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 0de31349fd..772f7c35ba 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -116,9 +116,11 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed return STATUS_OK; } -void BaseSurfaceOSystem::finishLoad() { +bool BaseSurfaceOSystem::finishLoad() { BaseImage *image = new BaseImage(_gameRef); - image->loadFile(_filename); + if (!image->loadFile(_filename)) { + return false; + } _width = image->getSurface()->w; _height = image->getSurface()->h; @@ -188,6 +190,8 @@ void BaseSurfaceOSystem::finishLoad() { delete image; _loaded = true; + + return true; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index bece031fe7..3a8d64703f 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -85,7 +85,7 @@ public: private: Graphics::Surface *_surface; bool _loaded; - void finishLoad(); + bool finishLoad(); bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); uint32 getPixel(Graphics::Surface *surface, int x, int y); -- cgit v1.2.3 From f6a5a2a0d57d2e0829aa93ac0b30d3c0e1bf8838 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 22:55:54 +0200 Subject: WINTERMUTE: Wrap away base_script_holder's _filename field in getters/setters, avoiding direct writes. --- engines/wintermute/base/base_game.cpp | 14 ++++++-------- engines/wintermute/base/base_object.cpp | 4 ++-- engines/wintermute/base/base_region.cpp | 3 +-- engines/wintermute/base/base_script_holder.cpp | 8 ++++++-- engines/wintermute/base/base_script_holder.h | 4 +++- engines/wintermute/base/base_sprite.cpp | 6 ++---- engines/wintermute/base/font/base_font_bitmap.cpp | 3 +-- engines/wintermute/base/font/base_font_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font_truetype.cpp | 3 +-- engines/wintermute/base/particles/part_particle.cpp | 5 +++-- 10 files changed, 27 insertions(+), 27 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 0adc938895..da2c01a17f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -396,9 +396,8 @@ bool BaseGame::cleanup() { _viewportSP = -1; delete[] _name; - delete[] _filename; _name = NULL; - _filename = NULL; + setFilename(NULL); for (int i = 0; i < 7; i++) { delete[] _caption[i]; _caption[i] = NULL; @@ -679,8 +678,7 @@ bool BaseGame::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); @@ -1662,8 +1660,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursor") == 0) { stack->correctParams(0); - if (!_activeCursor || !_activeCursor->_filename) stack->pushNULL(); - else stack->pushString(_activeCursor->_filename); + if (!_activeCursor || !_activeCursor->getFilename()) stack->pushNULL(); + else stack->pushString(_activeCursor->getFilename()); return STATUS_OK; } @@ -1938,8 +1936,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursor") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->_filename) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->_filename); + if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) stack->pushNULL(); + else stack->pushString(_cursorNoninteractive->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 4ab121ded9..2002f01dc8 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -227,8 +227,8 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { stack->correctParams(0); - if (!_cursor || !_cursor->_filename) stack->pushNULL(); - else stack->pushString(_cursor->_filename); + if (!_cursor || !_cursor->getFilename()) stack->pushNULL(); + else stack->pushString(_cursor->getFilename()); return STATUS_OK; } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index e336b92789..95fa163550 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -104,8 +104,7 @@ bool BaseRegion::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index f803a9191f..4235353c1e 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -72,8 +72,12 @@ bool BaseScriptHolder::cleanup() { ////////////////////////////////////////////////////////////////////// void BaseScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) delete [] _filename; - + if (_filename != NULL) { + delete [] _filename; + _filename = NULL; + } + if (filename == NULL) + return; _filename = new char [strlen(filename) + 1]; if (_filename != NULL) strcpy(_filename, filename); } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 52711572c1..ef1c389dcb 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -52,8 +52,8 @@ public: virtual bool listen(BaseScriptHolder *param1, uint32 param2); bool applyEvent(const char *eventName, bool unbreakable = false); void setFilename(const char *filename); + const char *getFilename() { return _filename; } bool parseProperty(byte *buffer, bool complete = true); - char *_filename; bool _freezable; bool _ready; @@ -65,6 +65,8 @@ public: virtual const char *scToString(); virtual void scDebuggerDesc(char *buf, int bufSize); // IWmeObject +private: + char *_filename; public: virtual bool sendEvent(const char *eventName); }; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 046a40bacf..f44e3d4024 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -66,7 +66,7 @@ void BaseSprite::setDefaults() { _currentFrame = -1; _looping = false; _lastFrameTime = 0; - _filename = NULL; + setFilename(NULL); _finished = false; _changed = false; _paused = false; @@ -160,9 +160,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c } } - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); - + setFilename(filename); return ret; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index cb3468c4f3..9a3caf2669 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -252,8 +252,7 @@ bool BaseFontBitmap::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 220a16e14f..9adc62c829 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -53,7 +53,7 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->_filename); + if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); delete _fonts[i]; } _fonts.removeAll(); @@ -74,7 +74,7 @@ BaseFont *BaseFontStorage::addFont(const char *filename) { if (!filename) return NULL; for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->_filename, filename) == 0) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { _fonts[i]->_refCount++; return _fonts[i]; } diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index bcf8621a40..9782d1d7db 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -416,8 +416,7 @@ bool BaseFontTT::loadFile(const char *filename) { bool ret; - _filename = new char [strlen(filename) + 1]; - strcpy(_filename, filename); + setFilename(filename); if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 93b9f3659d..e36cec6f47 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -73,7 +73,7 @@ PartParticle::~PartParticle(void) { ////////////////////////////////////////////////////////////////////////// bool PartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->_filename && scumm_stricmp(filename, _sprite->_filename) == 0) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename, _sprite->getFilename()) == 0) { _sprite->reset(); return STATUS_OK; } @@ -240,7 +240,8 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_fadeStartAlpha)); if (persistMgr->_saving) { - persistMgr->transfer(TMEMBER(_sprite->_filename)); + const char *filename = _sprite->getFilename(); + persistMgr->transfer(TMEMBER(filename)); } else { char *filename; persistMgr->transfer(TMEMBER(filename)); -- cgit v1.2.3 From 8c378f794e0398e646eb3598c9e27c09b4d68dfc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:17:32 +0200 Subject: WINTERMUTE: Wrap _name in base_named_object in getters/setters. --- engines/wintermute/base/base_game.cpp | 9 ++++----- engines/wintermute/base/base_named_object.cpp | 4 ++++ engines/wintermute/base/base_named_object.h | 3 ++- engines/wintermute/base/base_persistence_manager.cpp | 4 ++-- engines/wintermute/base/base_region.cpp | 4 ++-- engines/wintermute/base/base_script_holder.cpp | 17 ++++++++++++----- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/particles/part_force.cpp | 9 ++++++++- 9 files changed, 37 insertions(+), 19 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index da2c01a17f..8ef45e4106 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -395,8 +395,7 @@ bool BaseGame::cleanup() { _viewportStack.removeAll(); _viewportSP = -1; - delete[] _name; - _name = NULL; + setName(NULL); setFilename(NULL); for (int i = 0; i < 7; i++) { delete[] _caption[i]; @@ -1780,7 +1779,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int fileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? _name : Val->getString(), fileNum); + sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum); if (!Common::File::exists(filename)) break; fileNum++; @@ -2160,7 +2159,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } ////////////////////////////////////////////////////////////////////////// @@ -4346,7 +4345,7 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Timer: %d", _timer); _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->_name, 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 97b9f53353..ad95d83211 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -57,6 +57,10 @@ BaseNamedObject::~BaseNamedObject(void) { ////////////////////////////////////////////////////////////////////// void BaseNamedObject::setName(const char *name) { delete[] _name; + _name = NULL; + + if (name == NULL) + return; _name = new char [strlen(name) + 1]; if (_name != NULL) strcpy(_name, name); diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index f7b496ead8..32e4d561d7 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -35,13 +35,14 @@ namespace WinterMute { class BaseNamedObject : public BaseClass { + char *_name; public: BaseNamedObject(BaseGame *inGame); BaseNamedObject(); virtual ~BaseNamedObject(void); BaseNamedObject(TDynamicConstructor, TDynamicConstructor); - char *_name; + const char *getName() { return _name; } void setName(const char *name); }; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 18dc8ed11c..610229644c 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -212,7 +212,7 @@ bool BasePersistenceManager::initSave(const char *desc) { // new in ver 2 putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->_name); + putString(_gameRef->getName()); // thumbnail data size bool thumbnailOK = false; @@ -314,7 +314,7 @@ bool BasePersistenceManager::initLoad(const char *filename) { } _saving = false; - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->_name) != 0) { + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 95fa163550..d654f69b9c 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -324,7 +324,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } @@ -381,7 +381,7 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); else buffer->putTextIndent(indent, "%s {\n", nameOverride); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 4235353c1e..c4d8b9b5c2 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -227,7 +227,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { // Name ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Name") == 0) { - _scValue->setString(_name); + _scValue->setString(getName()); return _scValue; } @@ -272,7 +272,14 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_name)); + if (persistMgr->_saving) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + const char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + } _scripts.persist(persistMgr); return STATUS_OK; @@ -284,7 +291,7 @@ bool BaseScriptHolder::addScript(const char *filename) { for (int i = 0; i < _scripts.getSize(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, _name); + _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); return STATUS_OK; } } @@ -456,9 +463,9 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { strcpy(buf, scToString()); - if (_name && strcmp(_name, "") != 0) { + if (getName() && strcmp(getName(), "") != 0) { strcat(buf, " Name: "); - strcat(buf, _name); + strcat(buf, getName()); } if (_filename) { strcat(buf, " File: "); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index f44e3d4024..7b3e104d84 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -428,7 +428,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float ////////////////////////////////////////////////////////////////////////// bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _name); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 54e612ff42..76fe3c79de 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -367,7 +367,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->getName()) == 0) { force = _forces[i]; break; } @@ -402,7 +402,7 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->_name) == 0) { + if (scumm_stricmp(name, _forces[i]->getName()) == 0) { delete _forces[i]; _forces.removeAt(i); return STATUS_OK; diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index ba60e8b41c..7311ea21f6 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -48,7 +48,14 @@ PartForce::~PartForce(void) { ////////////////////////////////////////////////////////////////////////// bool PartForce::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_name)); + if (persistMgr->_saving) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + const char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + } persistMgr->transfer(TMEMBER(_pos)); persistMgr->transfer(TMEMBER(_direction)); persistMgr->transfer(TMEMBER_INT(_type)); -- cgit v1.2.3 From a249b096c03d1cc3437f4e16abe92758f584947d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:26:18 +0200 Subject: WINTERMUTE: Remove Base as superclass for base_package. --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/file/base_package.cpp | 9 +++++---- engines/wintermute/base/file/base_package.h | 13 ++++++------- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 0a59a3b134..2fd5521e37 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -439,7 +439,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const } for (uint32 i = 0; i < hdr._numDirs; i++) { - BasePackage *pkg = new BasePackage(_gameRef); + BasePackage *pkg = new BasePackage(this); if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 24f7c23422..a95be25a81 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -40,12 +40,13 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BasePackage::BasePackage(BaseGame *inGame): BaseClass(inGame) { +BasePackage::BasePackage(BaseFileManager *fileMan)/*: BaseClass(inGame) */{ _file = NULL; _name = NULL; _cd = 0; _priority = 0; _boundToExe = false; + _fileManager = fileMan; } @@ -87,10 +88,10 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::File *file = _gameRef->_fileManager->openPackage(_name); + Common::File *file = _fileManager->openPackage(_name); if (!file) { - _gameRef->_fileManager->requestCD(_cd, _name, ""); - file = _gameRef->_fileManager->openPackage(_name); + _fileManager->requestCD(_cd, _name, ""); + file = _fileManager->openPackage(_name); } return file; } diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 2f305ea049..af180ac7bf 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -29,16 +29,16 @@ #ifndef WINTERMUTE_BPACKAGE_H #define WINTERMUTE_BPACKAGE_H - -#include "engines/wintermute/base/base.h" +#include "common/stream.h" namespace Common { class SeekableReadStream; } namespace WinterMute { - -class BasePackage : public BaseClass { +class BaseFileManager; +class BasePackage { + BaseFileManager *_fileManager; public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); @@ -51,9 +51,8 @@ public: char *_name; int _cd; Common::SeekableReadStream *_file; - BasePackage(BaseGame *inGame); - virtual ~BasePackage(); - + BasePackage(BaseFileManager *fileMan); + ~BasePackage(); }; } // end of namespace WinterMute -- cgit v1.2.3 From 4f1b03eac1be560bbaaa3f379ddd4084693df64f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 22 Jul 2012 23:36:13 +0200 Subject: WINTERMUTE: Remove Base as superclass for base_file_entry --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/base_file_manager.h | 1 + engines/wintermute/base/file/base_disk_file.cpp | 4 ---- engines/wintermute/base/file/base_disk_file.h | 4 +--- engines/wintermute/base/file/base_file_entry.cpp | 4 ++-- engines/wintermute/base/file/base_file_entry.h | 7 +++---- engines/wintermute/base/file/base_package.cpp | 1 - engines/wintermute/base/file/base_resources.cpp | 1 - 8 files changed, 8 insertions(+), 16 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 2fd5521e37..70818bcb61 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -492,7 +492,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const } _filesIter = _files.find(name); if (_filesIter == _files.end()) { - BaseFileEntry *file = new BaseFileEntry(_gameRef); + BaseFileEntry *file = new BaseFileEntry(); file->_package = pkg; file->_offset = offset; file->_length = length; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 78e6cb737f..7799f5193a 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BFILEMANAGER_H #include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/base.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index c20fd9f342..21f7c7c189 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/wintypes.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/base_file_manager.h" @@ -49,7 +47,6 @@ void correctSlashes(char *fileName) { } bool diskFileExists(const Common::String& filename) { - Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); @@ -86,7 +83,6 @@ bool diskFileExists(const Common::String& filename) { } Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { - char fullPath[MAX_PATH_LENGTH]; uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index b0ba32cb84..13d5c3e03c 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -29,9 +29,7 @@ #ifndef WINTERMUTE_BDISKFILE_H #define WINTERMUTE_BDISKFILE_H -namespace Common { -class SeekableReadStream; -} +#include "common/stream.h" namespace WinterMute { diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index d3e0fee7b0..43527f9fc0 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -25,13 +25,13 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" + #include "engines/wintermute/base/file/base_file_entry.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry(BaseGame *inGame): BaseClass(inGame) { +BaseFileEntry::BaseFileEntry(){ _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 0e0375e42d..086a70e7ed 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -29,14 +29,13 @@ #ifndef WINTERMUTE_BFILEENTRY_H #define WINTERMUTE_BFILEENTRY_H - -#include "engines/wintermute/base/base.h" +#include "common/str.h" namespace WinterMute { class BasePackage; -class BaseFileEntry : public BaseClass { +class BaseFileEntry { public: uint32 _timeDate2; uint32 _timeDate1; @@ -47,7 +46,7 @@ public: uint32 _length; uint32 _offset; BasePackage *_package; - BaseFileEntry(BaseGame *inGame); + BaseFileEntry(); virtual ~BaseFileEntry(); }; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a95be25a81..303d6eea17 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/file.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index f7aaf6393a..73c06271d7 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/file/base_resources.h" #include "common/str.h" #include "common/memstream.h" -- cgit v1.2.3 From 8b6e4fc7527eb5c56755c068d8c5b75951298fe5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 00:14:34 +0200 Subject: WINTERMUTE: Privatize/remove unused/internal functions in BaseFileManager --- engines/wintermute/base/base_file_manager.cpp | 188 +++----------------------- engines/wintermute/base/base_file_manager.h | 49 +++---- 2 files changed, 44 insertions(+), 193 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 70818bcb61..da49f188c1 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -60,8 +60,6 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { - _basePath = NULL; - initPaths(); registerPackages(); } @@ -98,9 +96,6 @@ bool BaseFileManager::cleanup() { delete _packages[i]; _packages.clear(); - delete[] _basePath; - _basePath = NULL; - return STATUS_OK; } @@ -164,54 +159,7 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin file->write(buffer, bufferSize); file->finalize(); delete file; -#if 0 - RestoreCurrentDir(); - - BaseUtils::CreatePath(filename, false); - - FILE *f = fopen(filename, "wb"); - if (!f) { - _gameRef->LOG(0, "Error opening file '%s' for writing.", filename); - return STATUS_FAILED; - } - - if (PrefixBuffer && PrefixSize) { - fwrite(PrefixBuffer, PrefixSize, 1, f); - } - - if (Compressed) { - uint32 CompSize = BufferSize + (BufferSize / 100) + 12; // 1% extra space - byte *CompBuffer = new byte[CompSize]; - if (!CompBuffer) { - _gameRef->LOG(0, "Error allocating compression buffer while saving '%s'", filename); - Compressed = false; - } else { - if (compress(CompBuffer, (uLongf *)&CompSize, Buffer, BufferSize) == Z_OK) { - uint32 magic = DCGF_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - magic = COMPRESSED_FILE_MAGIC; - fwrite(&magic, sizeof(uint32), 1, f); - - uint32 DataOffset = 5 * sizeof(uint32); - fwrite(&DataOffset, sizeof(uint32), 1, f); - - fwrite(&CompSize, sizeof(uint32), 1, f); - fwrite(&BufferSize, sizeof(uint32), 1, f); - - fwrite(CompBuffer, CompSize, 1, f); - } else { - _gameRef->LOG(0, "Error compressing data while saving '%s'", filename); - Compressed = false; - } - - delete [] CompBuffer; - } - } - if (!Compressed) fwrite(Buffer, BufferSize, 1, f); - - fclose(f); -#endif return STATUS_OK; } @@ -230,16 +178,8 @@ bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (path.getName().c_str() == NULL || strlen(path.getName().c_str()) < 1) return STATUS_FAILED; - -// bool slashed = (path[path.size() - 1] == '\\' || path[path.size() - 1] == '/'); - -/* char *buffer = new char [strlen(path.c_str()) + 1 + (slashed ? 0 : 1)]; - if (buffer == NULL) return STATUS_FAILED; - - strcpy(buffer, path.c_str()); - if (!slashed) strcat(buffer, "\\");*/ - //BasePlatform::strlwr(buffer); + if (!path.exists()) + return STATUS_FAILED; switch (type) { case PATH_SINGLE: @@ -257,12 +197,7 @@ bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::reloadPaths() { // delete registered paths -/* for (uint32 i = 0; i < _singlePaths.size(); i++) - delete [] _singlePaths[i];*/ //_singlePaths.clear(); - -/* for (uint32 i = 0; i < _packagePaths.size(); i++) - delete [] _packagePaths[i];*/ _packagePaths.clear(); return initPaths(); @@ -272,8 +207,6 @@ bool BaseFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - restoreCurrentDir(); - AnsiString pathList; int numPaths; @@ -319,29 +252,22 @@ bool BaseFileManager::initPaths() { bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { - warning("Adding %s", (*it).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it).createReadStream())) { addPath(PATH_PACKAGE, (*it)); } } } - warning(" Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + return true; } ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - restoreCurrentDir(); - _gameRef->LOG(0, "Scanning packages..."); debugC(kWinterMuteDebugFileAccess, "Scanning packages"); -/* Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, "*.dcp"); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - registerPackage((*it)->getName().c_str()); - }*/ // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; @@ -355,34 +281,7 @@ bool BaseFileManager::registerPackages() { registerPackage((*fileIt).createReadStream()); } } -#if 0 - AnsiString extension = AnsiString(PACKAGE_EXTENSION); - - for (int i = 0; i < _packagePaths.getSize(); i++) { - boost::filesystem::path absPath = boost::filesystem::syste_complete(_packagePaths[i]); - - //_gameRef->LOG(0, "Scanning: %s", absPath.string().c_str()); - //printf("Scanning: %s\n", absPath.string().c_str()); - if (!exists(absPath)) continue; - - // scan files - boost::filesystem::directory_iterator endIter; - for (boost::filesystem::directory_iterator dit(absPath); dit != endIter; ++dit) { - if (!is_directory((*dit).status())) { - AnsiString fileName = (*dit).path().string(); - - if (!IsValidPackage(fileName)) continue; - - warning("%s", fileName.c_str()); - //printf("%s\n", fileName.c_str()); - if (!StringUtil::CompareNoCase(extension, PathUtil::GetExtension(fileName))) continue; - warning("Registered"); - RegisterPackage(absPath.string().c_str(), dit->path().filename().string().c_str()); - } - } - } -#endif debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); @@ -391,7 +290,6 @@ bool BaseFileManager::registerPackages() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { -// FILE *f = fopen(filename, "rb"); Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { @@ -419,7 +317,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const TPackageHeader hdr; hdr.readFromStream(package); -// package->read(&hdr, sizeof(TPackageHeader), 1, f); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; @@ -456,9 +353,9 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const // read file entries - uint32 NumFiles = package->readUint32LE(); + uint32 numFiles = package->readUint32LE(); - for (uint32 j = 0; j < NumFiles; j++) { + for (uint32 j = 0; j < numFiles; j++) { char *name; uint32 offset, length, compLength, flags, timeDate1, timeDate2; @@ -533,12 +430,7 @@ bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { ////////////////////////////////////////////////////////////////////////// Common::File *BaseFileManager::openPackage(const Common::String &name) { //TODO: Is it really necessary to do this when we have the ScummVM-system? - - //RestoreCurrentDir(); - Common::File *ret = new Common::File(); - char filename[MAX_PATH_LENGTH]; - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { Common::String packageName = (*it).getName(); if (packageName == (name + ".dcp")) @@ -547,19 +439,12 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { return ret; } } -/* for (uint32 i = 0; i < _packagePaths.size(); i++) { - sprintf(filename, "%s%s.%s", _packagePaths[i], name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; - } - }*/ - sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); +/* sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; - } + }*/ warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; @@ -594,17 +479,9 @@ bool BaseFileManager::hasFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) return NULL; - //_gameRef->LOG(0, "open file: %s", filename); - /*#ifdef __WIN32__ - if (_gameRef->_debugDebugMode && _gameRef->_debugAbsolutePathWarning && AbsPathWarning) { - char Drive[_MAX_DRIVE]; - _splitpath(filename, Drive, NULL, NULL, NULL); - if (Drive[0] != '\0') { - _gameRef->LOG(0, "WARNING: Referencing absolute path '%s'. The game will NOT work on another computer.", filename); - } - } - #endif*/ + if (strcmp(filename.c_str(), "") == 0) + return NULL; + debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); if (file && keepTrackOf) _openFiles.push_back(file); @@ -627,8 +504,6 @@ bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { - restoreCurrentDir(); - Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { @@ -640,50 +515,23 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - - ret = openDiskFile(filename, this); - if (ret) return ret; + if (ret) + return ret; ret = openPkgFile(filename, this); - if (ret) return ret; + if (ret) + return ret; ret = BaseResources::getFile(filename); - if (ret) return ret; + if (ret) + return ret; warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::restoreCurrentDir() { - if (!_basePath) return STATUS_OK; - else { - /*if (!chdir(_basePath)) return STATUS_OK; - else return STATUS_FAILED;*/ - warning("BaseFileManager::RestoreCurrentDir - ignored"); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::setBasePath(const Common::String &path) { - cleanup(); - - if (path.c_str()) { - _basePath = new char[path.size() + 1]; - strcpy(_basePath, path.c_str()); - } - - initPaths(); - registerPackages(); - - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 7799f5193a..b91609bc45 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -29,8 +29,8 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/file/base_package.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" @@ -41,44 +41,47 @@ class File; namespace WinterMute { class BaseFile; +class BaseFileEntry; class BaseFileManager: BaseClass { public: - bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool cleanup(); - bool setBasePath(const Common::String &path); - bool restoreCurrentDir(); - char *_basePath; - Common::SeekableReadStream *openFileRaw(const Common::String &filename); + bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + Common::SeekableReadStream *loadSaveGame(const Common::String &filename); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + + BaseFileManager(BaseGame *inGame = NULL); + virtual ~BaseFileManager(); + // Used only by BasePersistenceManager + bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); + // Used only for detection + bool registerPackages(const Common::FSList &fslist); + // Used by BasePackage only BaseFileEntry *getPackageEntry(const Common::String &filename); Common::File *openPackage(const Common::String &name); - bool registerPackages(const Common::FSList &fslist); - bool registerPackages(); - bool initPaths(); - bool reloadPaths(); + bool requestCD(int cd, char *packageFile, const char *filename); +private: typedef enum { - PATH_PACKAGE, PATH_SINGLE + PATH_PACKAGE, + PATH_SINGLE } TPathType; + bool reloadPaths(); + bool initPaths(); bool addPath(TPathType type, const Common::FSNode &path); - bool requestCD(int cd, char *packageFile, const char *filename); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(BaseGame *inGame = NULL); - virtual ~BaseFileManager(); -// Common::FSList _singlePaths; + bool registerPackages(); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); Common::FSList _packagePaths; +// Common::FSList _singlePaths; + bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); + bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); + bool registerPackage(const Common::String &filename, bool searchSignature = false); + bool isValidPackage(const AnsiString &fileName) const; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; -private: - bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); - bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::HashMap::iterator _filesIter; - bool isValidPackage(const AnsiString &fileName) const; - }; } // end of namespace WinterMute -- cgit v1.2.3 From 61e011ada98f780d28bbea53f3c702f2bb3ed2bd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 00:40:38 +0200 Subject: WINTERMUTE: Reenable direct package-loading for now --- engines/wintermute/base/base_file_manager.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index da49f188c1..772af11c13 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -439,12 +439,11 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { return ret; } } - -/* sprintf(filename, "%s.%s", name.c_str(), PACKAGE_EXTENSION); + Common::String filename = Common::String::format("%s.%s", name.c_str(), PACKAGE_EXTENSION); ret->open(filename); if (ret->isOpen()) { return ret; - }*/ + } warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); delete ret; return NULL; -- cgit v1.2.3 From 93864d4e39f6335684bee9d8dc291ce9af32ca7b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:08:57 +0200 Subject: WINTERMUTE: Remove Base as superclass for BaseImage --- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/gfx/base_image.cpp | 13 ++++--------- engines/wintermute/base/gfx/base_image.h | 10 ++++------ engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 2 +- .../wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 +- 5 files changed, 11 insertions(+), 18 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 68cfb8a7ea..9f87f392e5 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -65,7 +65,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(_gameRef); + _thumbnail = new BaseImage(_gameRef->_fileManager); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 533c3a866e..bdc7cb76e2 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -26,9 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/graphics/transparent_surface.h" #include "engines/wintermute/utils/string_util.h" @@ -44,11 +42,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage(BaseGame *inGame, FIBITMAP *bitmap): BaseClass(inGame) { -#if 0 - _bitmap = bitmap; -#endif - _bitmap = NULL; +BaseImage::BaseImage(BaseFileManager *fileManager) { + _fileManager = fileManager; _palette = NULL; _surface = NULL; _decoder = NULL; @@ -86,13 +81,13 @@ bool BaseImage::loadFile(const Common::String &filename) { error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); } _filename = filename; - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename.c_str()); + Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); if (!file) return STATUS_FAILED; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); - _gameRef->_fileManager->closeFile(file); + _fileManager->closeFile(file); return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 4b43e36a6d..7f344b5c1c 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BIMAGE_H #define WINTERMUTE_BIMAGE_H -#include "engines/wintermute/base/base.h" #include "graphics/surface.h" #include "graphics/pixelformat.h" #include "graphics/decoders/image_decoder.h" @@ -37,14 +36,13 @@ #include "common/str.h" #include "common/stream.h" -struct FIBITMAP; - namespace WinterMute { class BaseSurface; -class BaseImage: BaseClass { +class BaseFileManager; +class BaseImage { public: - BaseImage(BaseGame *inGame, FIBITMAP *bitmap = NULL); + BaseImage(BaseFileManager *fileManager); ~BaseImage(); bool loadFile(const Common::String &filename); @@ -63,10 +61,10 @@ public: private: Common::String _filename; Graphics::ImageDecoder *_decoder; - FIBITMAP *_bitmap; const Graphics::Surface *_surface; Graphics::Surface *_deletableSurface; const byte *_palette; + BaseFileManager *_fileManager; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ec69a80095..24e3ddb0ae 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -561,7 +561,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Fix this warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); - BaseImage *screenshot = new BaseImage(_gameRef); + BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); screenshot->copyFrom(_renderSurface); return screenshot; #if 0 diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 772f7c35ba..c8cbe99f73 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -117,7 +117,7 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed } bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(_gameRef); + BaseImage *image = new BaseImage(_gameRef->_fileManager); if (!image->loadFile(_filename)) { return false; } -- cgit v1.2.3 From d1f7730ec25b409f3651167640dd48b7dd8046be Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:28:42 +0200 Subject: WINTERMUTE: Encapsulate BaseRenderer::_rectList and replace it by Common::Array --- engines/wintermute/base/base_sub_frame.cpp | 4 ++-- engines/wintermute/base/gfx/base_renderer.cpp | 10 +++++++--- engines/wintermute/base/gfx/base_renderer.h | 10 ++++++---- 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index d6a8c2490f..05b7d21dfe 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -209,9 +209,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->_rectList.add(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) return STATUS_OK; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index c46115d70a..63c23169b7 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -72,7 +72,7 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { point.x = x; point.y = y; - for (int i = _rectList.getSize() - 1; i >= 0; i--) { + for (int i = _rectList.size() - 1; i >= 0; i--) { if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { if (_rectList[i]->_precise) { // frame @@ -106,10 +106,10 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// void BaseRenderer::deleteRectList() { - for (int i = 0; i < _rectList.getSize(); i++) { + for (int i = 0; i < _rectList.size(); i++) { delete _rectList[i]; } - _rectList.removeAll(); + _rectList.clear(); } @@ -254,4 +254,8 @@ bool BaseRenderer::pointInViewport(Point32 *p) { return true; } +void BaseRenderer::addRectToList(BaseActiveRect *rect) { + _rectList.push_back(rect); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 118cda0ec6..32dced0878 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -29,10 +29,10 @@ #ifndef WINTERMUTE_BRENDERER_H #define WINTERMUTE_BRENDERER_H - -#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" #include "common/rect.h" +#include "common/array.h" namespace WinterMute { @@ -117,8 +117,10 @@ public: int _bPP; int _height; int _width; - - BaseArray _rectList; + + void addRectToList(BaseActiveRect *rect); +private: + Common::Array _rectList; }; BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp -- cgit v1.2.3 From 4b0ede4685bd1f02e86572f110ab906be265930a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 01:40:49 +0200 Subject: Rename BaseGame::SaveGame -> saveGame --- engines/wintermute/base/base_game.cpp | 6 +++--- engines/wintermute/base/base_game.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8ef45e4106..6897a37776 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1513,7 +1513,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack char *desc = new char[strlen(xdesc) + 1]; strcpy(desc, xdesc); stack->pushBool(true); - if (DID_FAIL(SaveGame(slot, desc, quick))) { + if (DID_FAIL(saveGame(slot, desc, quick))) { stack->pop(); stack->pushBool(false); } @@ -3157,7 +3157,7 @@ bool BaseGame::showCursor() { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::SaveGame(int slot, const char *desc, bool quickSave) { +bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); @@ -4458,7 +4458,7 @@ void BaseGame::autoSaveOnExit() { if (!_autoSaveOnExit) return; if (_state == GAME_FROZEN) return; - SaveGame(_autoSaveSlot, "autosave", true); + saveGame(_autoSaveSlot, "autosave", true); } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 77fa6b3a8b..4a5adb4e39 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -296,7 +296,7 @@ public: virtual bool cleanup(); virtual bool loadGame(int slot); virtual bool loadGame(const char *filename); - virtual bool SaveGame(int slot, const char *desc, bool quickSave = false); + virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); BaseSprite *_cursorNoninteractive; -- cgit v1.2.3 From 927eb9a9e8f8dab6995c83367739bbf280886c2d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 02:05:37 +0200 Subject: WINTERMUTE: Some more BaseFileManager-cleanup --- engines/wintermute/base/base_file_manager.cpp | 29 +++++++++------------------ engines/wintermute/base/base_file_manager.h | 1 - 2 files changed, 9 insertions(+), 21 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 772af11c13..57f59a144c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -108,7 +108,8 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { - if (mustExist) _gameRef->LOG(0, "Error opening file '%s'", filename.c_str()); + if (mustExist) + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); return NULL; } @@ -123,13 +124,13 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz buffer = new byte[file->size() + 1]; if (buffer == NULL) { - _gameRef->LOG(0, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); closeFile(file); return NULL; } if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - _gameRef->LOG(0, "Error reading file '%s'", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); delete [] buffer; return NULL; @@ -265,8 +266,7 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - _gameRef->LOG(0, "Scanning packages..."); - debugC(kWinterMuteDebugFileAccess, "Scanning packages"); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Scanning packages"); // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. @@ -282,8 +282,7 @@ bool BaseFileManager::registerPackages() { } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - _gameRef->LOG(0, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } @@ -293,7 +292,7 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { - _gameRef->LOG(0, " Error opening package file '%s'. Ignoring.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Error opening package file '%s'. Ignoring.", filename.c_str()); return STATUS_OK; } return registerPackage(package, filename); @@ -318,13 +317,13 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const TPackageHeader hdr; hdr.readFromStream(package); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - _gameRef->LOG(0, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete package; return STATUS_OK; } if (hdr._packageVersion != PACKAGE_VERSION) { - _gameRef->LOG(0, " Warning: package file '%s' is outdated.", filename.c_str()); + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } // new in v2 @@ -416,16 +415,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::isValidPackage(const AnsiString &fileName) const { - AnsiString plainName = PathUtil::getFileNameWithoutExtension(fileName); - - // check for device-type specific packages - if (StringUtil::startsWith(plainName, "xdevice_", true)) { - return StringUtil::compareNoCase(plainName, "xdevice_" + _gameRef->getDeviceType()); - } - return true; -} ////////////////////////////////////////////////////////////////////////// Common::File *BaseFileManager::openPackage(const Common::String &name) { diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index b91609bc45..8dfde06f74 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -77,7 +77,6 @@ private: bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); bool registerPackage(const Common::String &filename, bool searchSignature = false); - bool isValidPackage(const AnsiString &fileName) const; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; -- cgit v1.2.3 From 7a818009b4c20df1811c0b158b0f8acfe0e3d208 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 02:23:14 +0200 Subject: WINTERMUTE: Clean out unused utils. --- engines/wintermute/base/base_game.cpp | 1 + engines/wintermute/base/scriptables/script_engine.cpp | 2 +- engines/wintermute/base/scriptables/script_engine.h | 1 - 3 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 6897a37776..d3da177a92 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -60,6 +60,7 @@ #include "engines/wintermute/base/scriptables/script_ext_math.h" #include "engines/wintermute/video/video_player.h" #include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "common/savefile.h" #include "common/textconsole.h" diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 44add054c5..e8544d8cd6 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_file_manager.h" - +#include "engines/wintermute/utils/utils.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 06d61b4156..6d2ed92e4f 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,6 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" namespace WinterMute { -- cgit v1.2.3 From 448911930d8d6bf43a67769d50ee4048f296b7f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:01:05 +0200 Subject: WINTERMUTE: Remove unused code from platform_osystem.h --- engines/wintermute/base/base_active_rect.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 7 +++---- engines/wintermute/base/base_file_manager.cpp | 22 ++++++++++------------ engines/wintermute/base/base_game.cpp | 13 +++++++------ engines/wintermute/base/base_sub_frame.cpp | 2 +- .../wintermute/base/base_transition_manager.cpp | 7 +++---- .../wintermute/base/font/base_font_truetype.cpp | 4 +++- engines/wintermute/base/scriptables/script.cpp | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 20 ++++++++++---------- .../wintermute/base/scriptables/script_engine.h | 3 +-- .../base/scriptables/script_ext_file.cpp | 12 ++++++++---- 11 files changed, 48 insertions(+), 46 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 493b35bf12..598324e10b 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -65,7 +65,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion * _owner = owner; _region = region; BasePlatform::copyRect(&_rect, ®ion->_rect); - BasePlatform::offsetRect(&_rect, -offsetX, -offsetY); + _rect.offsetRect(-offsetX, -offsetY); _zoomX = 100; _zoomY = 100; _precise = true; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4dcdf82347..c5f170bb43 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" #include "common/util.h" namespace WinterMute { @@ -67,7 +66,7 @@ bool BaseFader::update() { uint32 time; - if (_system) time = BasePlatform::getTime() - _startTime; + if (_system) time = g_system->getMillis() - _startTime; else time = _gameRef->_timer - _startTime; if (time >= _duration) _currentAlpha = _targetAlpha; @@ -115,7 +114,7 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = BasePlatform::getTime(); + if (_system) _startTime = g_system->getMillis(); else _startTime = _gameRef->_timer; return STATUS_OK; @@ -138,7 +137,7 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = BasePlatform::getTime(); + if (_system) _startTime = g_system->getMillis(); else _startTime = _gameRef->_timer; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 57f59a144c..1eb27ad0c4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -372,9 +372,11 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const // some old version of ProjectMan writes invalid directory entries // so at least prevent strupr from corrupting memory name[nameLength - 1] = '\0'; - - - BasePlatform::strupr(name); + + Common::String upcName = name; + upcName.toUppercase(); + delete[] name; + name = NULL; offset = package->readUint32LE(); offset += absoluteOffset; @@ -386,7 +388,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const timeDate1 = package->readUint32LE(); timeDate2 = package->readUint32LE(); } - _filesIter = _files.find(name); + _filesIter = _files.find(upcName.c_str()); if (_filesIter == _files.end()) { BaseFileEntry *file = new BaseFileEntry(); file->_package = pkg; @@ -395,7 +397,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const file->_compressedLength = compLength; file->_flags = flags; - _files[name] = file; + _files[upcName.c_str()] = file; } else { // current package has lower CD number or higher priority, than the registered if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { @@ -406,7 +408,6 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const _filesIter->_value->_flags = flags; } } - delete [] name; } } @@ -441,16 +442,13 @@ Common::File *BaseFileManager::openPackage(const Common::String &name) { ////////////////////////////////////////////////////////////////////////// BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { - char *upc_name = new char[strlen(filename.c_str()) + 1]; - strcpy(upc_name, filename.c_str()); - BasePlatform::strupr(upc_name); + Common::String upc_name = filename; + upc_name.toUppercase(); BaseFileEntry *ret = NULL; - _filesIter = _files.find(upc_name); + _filesIter = _files.find(upc_name.c_str()); if (_filesIter != _files.end()) ret = _filesIter->_value; - delete [] upc_name; - return ret; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index d3da177a92..e72deb4be2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -62,6 +62,7 @@ #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/platform_osystem.h" #include "common/savefile.h" #include "common/textconsole.h" #include "common/util.h" @@ -589,7 +590,7 @@ void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { bool BaseGame::initLoop() { _viewportSP = -1; - _currentTime = BasePlatform::getTime(); + _currentTime = g_system->getMillis(); getDebugMgr()->onGameTick(); _renderer->initLoop(); @@ -2183,7 +2184,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)BasePlatform::getTime()); + _scValue->setInt((int)g_system->getMillis()); return _scValue; } @@ -4405,9 +4406,9 @@ void BaseGame::getMousePos(Point32 *pos) { bool BaseGame::miniUpdate() { if (!_miniUpdateEnabled) return STATUS_OK; - if (BasePlatform::getTime() - _lastMiniUpdate > 200) { + if (g_system->getMillis() - _lastMiniUpdate > 200) { if (_soundMgr) _soundMgr->initLoop(); - _lastMiniUpdate = BasePlatform::getTime(); + _lastMiniUpdate = g_system->getMillis(); } return STATUS_OK; } @@ -4440,8 +4441,8 @@ bool BaseGame::isDoubleClick(int buttonIndex) { int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - if (_lastClick[buttonIndex].time == 0 || BasePlatform::getTime() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = BasePlatform::getTime(); + if (_lastClick[buttonIndex].time == 0 || g_system->getMillis() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = g_system->getMillis(); _lastClick[buttonIndex].posX = pos.x; _lastClick[buttonIndex].posY = pos.y; return false; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 05b7d21dfe..d30d38ef70 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -262,7 +262,7 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple Rect32 rect; BasePlatform::setRectEmpty(&rect); if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!BasePlatform::equalRect(&rect, &_rect)) + if (!(rect == _rect)) buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); if (_hotspotX != 0 || _hotspotY != 0) diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index b524636af7..e4665756e2 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" namespace WinterMute { @@ -88,7 +87,7 @@ bool BaseTransitionMgr::update() { if (!_started) { _started = true; - _lastTime = BasePlatform::getTime(); + _lastTime = g_system->getMillis(); } switch (_type) { @@ -97,7 +96,7 @@ bool BaseTransitionMgr::update() { break; case TRANSITION_FADE_OUT: { - uint32 time = BasePlatform::getTime() - _lastTime; + uint32 time = g_system->getMillis() - _lastTime; int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); @@ -108,7 +107,7 @@ bool BaseTransitionMgr::update() { break; case TRANSITION_FADE_IN: { - uint32 time = BasePlatform::getTime() - _lastTime; + uint32 time = g_system->getMillis() - _lastTime; int alpha = (int)((float)time / (float)FADE_DURATION * 255); alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 9782d1d7db..88eec8469f 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -641,13 +641,15 @@ bool BaseFontTT::initFont() { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { + //TODO: Try to fallback from Arial to FreeSans + /* // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return STATUS_FAILED; - } + }*/ } if (file) { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 45544831e3..11fe6ff0cc 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1148,7 +1148,7 @@ bool ScScript::sleep(uint32 duration) { _state = SCRIPT_SLEEPING; if (_gameRef->_state == GAME_FROZEN) { - _waitTime = BasePlatform::getTime() + duration; + _waitTime = g_system->getMillis() + duration; _waitFrozen = true; } else { _waitTime = _gameRef->_timer + duration; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e8544d8cd6..472e9d9fec 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -176,7 +176,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig if (!ignoreCache) { for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = BasePlatform::getTime(); + _cachedScripts[i]->_timestamp = g_system->getMillis(); *outSize = _cachedScripts[i]->_size; return _cachedScripts[i]->_buffer; } @@ -216,7 +216,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = BasePlatform::getTime(); + uint32 MinTime = g_system->getMillis(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; @@ -275,7 +275,7 @@ bool ScEngine::tick() { case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= BasePlatform::getTime()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run(); } else { if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); } @@ -314,25 +314,25 @@ bool ScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = BasePlatform::getTime(); - while (_scripts[i]->_state == SCRIPT_RUNNING && BasePlatform::getTime() - StartTime < _scripts[i]->_timeSlice) { + uint32 StartTime = g_system->getMillis(); + while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - StartTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - StartTime); + if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = BasePlatform::getTime(); + if (isProfiling) startTime = g_system->getMillis(); while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, BasePlatform::getTime() - startTime); + if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); } _currentScript = NULL; } @@ -670,7 +670,7 @@ void ScEngine::enableProfiling() { // destroy old data, if any _scriptTimes.clear(); - _profilingStartTime = BasePlatform::getTime(); + _profilingStartTime = g_system->getMillis(); _isProfiling = true; } @@ -687,7 +687,7 @@ void ScEngine::disableProfiling() { ////////////////////////////////////////////////////////////////////////// void ScEngine::dumpStats() { error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = BasePlatform::getTime() - _profilingStartTime; + /* uint32 totalTime = g_system->getMillis() - _profilingStartTime; typedef std::vector > TimeVector; TimeVector times; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 6d2ed92e4f..3d85192aa6 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,6 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/wme_debugger.h" -#include "engines/wintermute/platform_osystem.h" namespace WinterMute { @@ -47,7 +46,7 @@ public: class CScCachedScript { public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = BasePlatform::getTime(); + _timestamp = g_system->getMillis(); _buffer = new byte[size]; if (_buffer) memcpy(_buffer, buffer, size); _size = size; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index ffa362a938..383b956555 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -182,7 +182,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "Delete") == 0) { stack->correctParams(0); close(); - stack->pushBool(BasePlatform::deleteFile(_filename) != false); + error("SXFile-Method: \"Delete\" not supported"); + //stack->pushBool(BasePlatform::deleteFile(_filename) != false); + stack->pushBool(false); return STATUS_OK; } @@ -191,11 +193,13 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { stack->correctParams(2); - const char *Dest = stack->pop()->getString(); - bool Overwrite = stack->pop()->getBool(true); + const char *dest = stack->pop()->getString(); + bool overwrite = stack->pop()->getBool(true); close(); - stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + error("SXFile-Method: Copy not supported"); + //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(false); return STATUS_OK; } -- cgit v1.2.3 From aedb0aea505e764c4c7bab1f90520b380be4d688 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:22:49 +0200 Subject: WINTERMUTE: Remove dcgf.h from almost all includes. --- engines/wintermute/base/base.cpp | 1 - engines/wintermute/base/base_active_rect.cpp | 1 - engines/wintermute/base/base_fader.cpp | 1 - engines/wintermute/base/base_file_manager.cpp | 1 - engines/wintermute/base/base_frame.cpp | 1 - engines/wintermute/base/base_keyboard_state.cpp | 1 - engines/wintermute/base/base_named_object.cpp | 1 - engines/wintermute/base/base_object.cpp | 1 - engines/wintermute/base/base_parser.cpp | 1 - engines/wintermute/base/base_point.cpp | 1 - engines/wintermute/base/base_quick_msg.cpp | 1 - engines/wintermute/base/base_region.cpp | 1 - engines/wintermute/base/base_save_thumb_helper.cpp | 1 - engines/wintermute/base/base_script_holder.cpp | 1 - engines/wintermute/base/base_scriptable.cpp | 1 - engines/wintermute/base/base_sprite.cpp | 1 - engines/wintermute/base/base_sub_frame.cpp | 1 - engines/wintermute/base/base_surface_storage.cpp | 1 - engines/wintermute/base/base_transition_manager.cpp | 1 - engines/wintermute/base/file/BPkgFile.cpp | 1 - engines/wintermute/base/file/base_file.cpp | 1 - engines/wintermute/base/file/base_package.cpp | 1 - engines/wintermute/base/file/base_save_thumb_file.cpp | 1 - engines/wintermute/base/font/base_font.cpp | 1 - engines/wintermute/base/font/base_font_bitmap.cpp | 1 - engines/wintermute/base/font/base_font_storage.cpp | 1 - engines/wintermute/base/font/base_font_truetype.cpp | 1 - engines/wintermute/base/gfx/base_renderer.cpp | 1 - engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 - engines/wintermute/base/particles/part_emitter.cpp | 1 - engines/wintermute/base/particles/part_force.cpp | 1 - engines/wintermute/base/particles/part_particle.cpp | 2 -- engines/wintermute/base/scriptables/script.cpp | 1 - engines/wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 - engines/wintermute/base/sound/base_sound_manager.cpp | 1 - 36 files changed, 37 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 4b62a7553a..b81261cdaf 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 598324e10b..0283ee274e 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_region.h" diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index c5f170bb43..8ed2fb3f0b 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" #include "common/util.h" diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1eb27ad0c4..5d399c33a1 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 2a729a882a..8278c48299 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index ad014762d4..a12f70f3ba 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_keyboard_state.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index ad95d83211..0821c9325b 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_named_object.h" namespace WinterMute { diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 2002f01dc8..44823acf1a 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/scriptables/script_value.h" diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index b07d98eca8..b7a221daf5 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 76d8d85c70..99e8c609df 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index 856a214f80..6e435b3ee0 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_quick_msg.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index d654f69b9c..22b5a99937 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 9f87f392e5..b63f280f05 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index c4d8b9b5c2..20eb2d13e1 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/ad/ad_game.h" #include "engines/wintermute/base/base_script_holder.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 6da67db3fb..40aa2871b5 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 7b3e104d84..86dbefdd70 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index d30d38ef70..2ac011917c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_active_rect.h" diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 7067c2a607..8e6931f54b 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index e4665756e2..53dd99aac2 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp index 5e1ebc5922..be37571901 100644 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ b/engines/wintermute/base/file/BPkgFile.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index d4109bb259..b2c0b31db9 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "common/memstream.h" diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 303d6eea17..a0f56ddf83 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/file.h" diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a2295b70a5..a6d56f281e 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 0c86517fc7..e9d245782a 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/font/base_font_bitmap.h" #include "engines/wintermute/base/font/base_font_truetype.h" diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9a3caf2669..8fd13a6835 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font_bitmap.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 9adc62c829..338273f338 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 88eec8469f..18966c662c 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/utils/path_util.h" diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 63c23169b7..a40b3204a5 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/gfx/base_surface.h" diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 24e3ddb0ae..70d1268e5a 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 76fe3c79de..bfe050cbe0 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/math/vector2.h" diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 7311ea21f6..6a8f328349 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/particles/part_force.h" #include "engines/wintermute/base/base_persistence_manager.h" diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index e36cec6f47..37f374a3e5 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/base_sprite.h" @@ -34,7 +33,6 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -#include namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 11fe6ff0cc..bdd11ca06a 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/base_game.h" diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 472e9d9fec..c275ebf5af 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/scriptables/script_value.h" diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index e1dba2120d..0b7fc840bf 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound_manager.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 22b22a5db6..a73b20e404 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/utils/path_util.h" -- cgit v1.2.3 From c7eda9abc80d1912148cae4292b94620c67a9c19 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 03:42:27 +0200 Subject: WINTERMUTE: Encapsulate and distance BasePersistenceManager from Base. --- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_game.cpp | 4 ++-- engines/wintermute/base/base_keyboard_state.cpp | 4 ++-- .../wintermute/base/base_persistence_manager.cpp | 16 ++++++++------ engines/wintermute/base/base_persistence_manager.h | 25 ++++++++++++---------- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/particles/part_force.cpp | 2 +- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 4 ++-- .../wintermute/base/scriptables/script_engine.cpp | 2 +- .../base/scriptables/script_ext_file.cpp | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 2 +- .../base/scriptables/script_ext_string.cpp | 2 +- .../wintermute/base/scriptables/script_value.cpp | 2 +- engines/wintermute/base/sound/base_sound.cpp | 4 ++-- 20 files changed, 47 insertions(+), 42 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 8ed2fb3f0b..4e7c608482 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -166,7 +166,7 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_targetAlpha)); persistMgr->transfer(TMEMBER(_system)); - if (_system && !persistMgr->_saving) _startTime = 0; + if (_system && !persistMgr->getIsSaving()) _startTime = 0; return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index e72deb4be2..301f79691d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3547,7 +3547,7 @@ bool BaseGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) + if (!persistMgr->getIsSaving()) cleanup(); BaseObject::persist(persistMgr); @@ -3631,7 +3631,7 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot)); persistMgr->transfer(TMEMBER(_cursorHidden)); - if (!persistMgr->_saving) + if (!persistMgr->getIsSaving()) _quitting = false; return STATUS_OK; diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index a12f70f3ba..db0f1db94d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -215,7 +215,7 @@ bool BaseKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if(!persistMgr->_saving) cleanup(); + //if(!persistMgr->getIsSaving()) cleanup(); BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); @@ -225,7 +225,7 @@ bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_currentPrintable)); persistMgr->transfer(TMEMBER(_currentShift)); - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum for (int i = 0; i < 323; i++) { _keyStates[i] = false; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 610229644c..da38806888 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -36,6 +36,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/wintermute.h" #include "graphics/decoders/bmp.h" #include "common/memstream.h" #include "common/str.h" @@ -51,7 +52,7 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix): BaseClass(inGame) { +BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) { _saving = false; // _buffer = NULL; // _bufferSize = 0; @@ -315,7 +316,7 @@ bool BasePersistenceManager::initLoad(const char *filename) { _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - _gameRef->LOG(0, "ERROR: Saved game name doesn't match current game"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; } @@ -325,8 +326,9 @@ bool BasePersistenceManager::initLoad(const char *filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { - _gameRef->LOG(0, "ERROR: Saved game version is newer than current game"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; } @@ -336,8 +338,8 @@ bool BasePersistenceManager::initLoad(const char *filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { - _gameRef->LOG(0, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - _gameRef->LOG(0, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; @@ -746,7 +748,7 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { if (_saving) { SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - _gameRef->LOG(0, "Warning: invalid instance '%s'", name); + debugC(kWinterMuteDebugSaveGame, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(classID); diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index a400c612dc..a59f797668 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -30,7 +30,7 @@ #define WINTERMUTE_BPERSISTMGR_H -#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" #include "engines/wintermute/math/rect32.h" #include "engines/savestate.h" #include "common/stream.h" @@ -41,17 +41,10 @@ namespace WinterMute { class Vector2; - -class BasePersistenceManager : public BaseClass { +class BaseGame; +class BasePersistenceManager { public: char *_savedDescription; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; Common::String _savePrefix; Common::String _savedName; bool saveFile(const char *filename); @@ -75,7 +68,7 @@ public: bool putBytes(byte *buffer, uint32 size); uint32 _offset; - bool _saving; + bool getIsSaving() { return _saving; } uint32 _richBufferSize; byte *_richBuffer; @@ -107,6 +100,16 @@ private: bool putTimeDate(const TimeDate &t); Common::WriteStream *_saveStream; Common::SeekableReadStream *_loadStream; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + bool _saving; + // Separate from Base, as this class can do SOME operations without a _gameRef. + BaseGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 20eb2d13e1..62ed4f67f2 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -271,7 +271,7 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_filename)); persistMgr->transfer(TMEMBER(_freezable)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 8e6931f54b..0dd10f6bdc 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -147,7 +147,7 @@ bool BaseSurfaceStorage::restoreAll() { bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { - if(!persistMgr->_saving) cleanup(false); + if(!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 8fd13a6835..2e752d4f2e 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -463,7 +463,7 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER(_widthsFrame)); - if (persistMgr->_saving) + if (persistMgr->getIsSaving()) persistMgr->putBytes(_widths, sizeof(_widths)); else persistMgr->getBytes(_widths, sizeof(_widths)); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 338273f338..84c80c73cb 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -123,7 +123,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) cleanup(false); + if (!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); _fonts.persist(persistMgr); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 18966c662c..c371177bac 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -606,7 +606,7 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { // persist layers int numLayers; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); @@ -620,7 +620,7 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { } } - if (!persistMgr->_saving) { + if (!persistMgr->getIsSaving()) { for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; _fallbackFont = _font = _deletableFont = NULL; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index bfe050cbe0..6bfff0799e 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -1161,7 +1161,7 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { _sprites.persist(persistMgr); int numForces; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numForces = _forces.getSize(); persistMgr->transfer(TMEMBER(numForces)); for (int i = 0; i < _forces.getSize(); i++) { @@ -1177,7 +1177,7 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { } int numParticles; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { numParticles = _particles.getSize(); persistMgr->transfer(TMEMBER(numParticles)); for (int i = 0; i < _particles.getSize(); i++) { diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 6a8f328349..7b2f117b4f 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -47,7 +47,7 @@ PartForce::~PartForce(void) { ////////////////////////////////////////////////////////////////////////// bool PartForce::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 37f374a3e5..b63a82f926 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -237,7 +237,7 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_exponentialGrowth)); persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { const char *filename = _sprite->getFilename(); persistMgr->transfer(TMEMBER(filename)); } else { diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index bdd11ca06a..52490c0710 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1199,7 +1199,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_gameRef)); // buffer - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { persistMgr->transfer(TMEMBER(_bufferSize)); persistMgr->putBytes(_buffer, _bufferSize); @@ -1249,7 +1249,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_unbreakable)); persistMgr->transfer(TMEMBER(_parentScript)); - if (!persistMgr->_saving) _tracingMode = false; + if (!persistMgr->getIsSaving()) _tracingMode = false; return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index c275ebf5af..59ec113d1f 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -448,7 +448,7 @@ bool ScEngine::resetScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->_saving) cleanup(); + if (!persistMgr->getIsSaving()) cleanup(); persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currentScript)); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 383b956555..92943f7485 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -730,7 +730,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_textMode)); uint32 pos = 0; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { pos = getPos(); persistMgr->transfer(TMEMBER(pos)); } else { diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 79ba978002..b625fad400 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -486,7 +486,7 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_size)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); } else { if (_size > 0) { diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index e645772b6f..5e01e5e29c 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -383,7 +383,7 @@ bool SXString::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_capacity)); - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); } else { if (_capacity > 0) { diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 0d8c34e719..6d12c34914 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -748,7 +748,7 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { int size; const char *str; - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { size = _valObject.size(); persistMgr->transfer("", &size); _valIter = _valObject.begin(); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 06421e8632..1853d7abfd 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -149,7 +149,7 @@ bool BaseSound::resume() { ////////////////////////////////////////////////////////////////////////// bool BaseSound::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->_saving && _sound) { + if (persistMgr->getIsSaving() && _sound) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; @@ -159,7 +159,7 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { _soundFreezePaused = _sound->_freezePaused; } - if (persistMgr->_saving) { + if (persistMgr->getIsSaving()) { _sFXType = SFX_NONE; _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } -- cgit v1.2.3 From 5bcc47646451c8c1cfe358ff69f5e7f77336fc91 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 04:37:25 +0200 Subject: WINTERMUTE: Initialize the BaseGame reference in BasePersistenceManager --- engines/wintermute/base/base_persistence_manager.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index da38806888..bcdb93a93e 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -59,6 +59,7 @@ BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *sav _offset = 0; _saveStream = NULL; _loadStream = NULL; + _gameRef = inGame; _richBuffer = NULL; _richBufferSize = 0; -- cgit v1.2.3 From 88fe4e3106e4eb7f3c179dfdb3b5a2f4fd3c7e2c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 23 Jul 2012 04:40:31 +0200 Subject: WINTERMUTE: Handle the "language/" subdirectory separately for choice of language. Since we don't have the same launcher the games have, we'll have to avoid including ALL the datafiles, as the localization-dcps are usually intended to work alone. For now, it's hardcoded to only load english. --- engines/wintermute/base/base_file_manager.cpp | 28 ++++++++++++++++++++------- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/file/base_package.cpp | 7 ++++--- engines/wintermute/base/file/base_package.h | 2 ++ 4 files changed, 29 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 5d399c33a1..1ff82d5e18 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -246,7 +246,10 @@ bool BaseFileManager::initPaths() { if (dataSubFolder.exists()) { addPath(PATH_PACKAGE, dataSubFolder); } - + Common::FSNode languageSubFolder = gameData.getChild("language"); + if (languageSubFolder.exists()) { + addPath(PATH_PACKAGE, languageSubFolder); + } return STATUS_OK; } @@ -254,7 +257,7 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { - if (registerPackage((*it).createReadStream())) { + if (registerPackage((*it))) { addPath(PATH_PACKAGE, (*it)); } } @@ -276,8 +279,16 @@ bool BaseFileManager::registerPackages() { for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().contains(".dcp")) continue; + // Avoid registering all the language files + // TODO: Select based on the gameDesc. + if (fileIt->getParent().getName() == "language") { + Common::String parentName = fileIt->getParent().getName(); + Common::String dcpName = fileIt->getName(); + if (fileIt->getName() != "english.dcp") + continue; + } warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); - registerPackage((*fileIt).createReadStream()); + registerPackage((*fileIt)); } } @@ -287,7 +298,7 @@ bool BaseFileManager::registerPackages() { } ////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { +/*bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { Common::File *package = new Common::File(); package->open(filename); if (!package->isOpen()) { @@ -295,12 +306,14 @@ bool BaseFileManager::registerPackage(const Common::String &filename , bool sear return STATUS_OK; } return registerPackage(package, filename); -} +}*/ -bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const Common::String &filename, bool searchSignature) { +bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; - + Common::SeekableReadStream * package = file.createReadStream(); + if (!package) + return STATUS_FAILED; if (searchSignature) { uint32 offset; if (!findPackageSignature(package, &offset)) { @@ -335,6 +348,7 @@ bool BaseFileManager::registerPackage(Common::SeekableReadStream *package, const for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(this); + pkg->_fsnode = file; if (!pkg) return STATUS_FAILED; pkg->_boundToExe = boundToExe; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 8dfde06f74..f859e39b00 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -75,8 +75,8 @@ private: Common::FSList _packagePaths; // Common::FSList _singlePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); - bool registerPackage(Common::SeekableReadStream *stream, const Common::String &filename = "", bool searchSignature = false); - bool registerPackage(const Common::String &filename, bool searchSignature = false); + bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); +// bool registerPackage(const Common::String &filename, bool searchSignature = false); Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a0f56ddf83..427f2f46f8 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -86,12 +86,13 @@ bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *bu ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::File *file = _fileManager->openPackage(_name); + Common::SeekableReadStream *stream = _fsnode.createReadStream(); +/* Common::File *file = _fileManager->openPackage(_name); if (!file) { _fileManager->requestCD(_cd, _name, ""); file = _fileManager->openPackage(_name); - } - return file; + }*/ + return stream; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index af180ac7bf..673655a710 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -30,6 +30,7 @@ #define WINTERMUTE_BPACKAGE_H #include "common/stream.h" +#include "common/fs.h" namespace Common { class SeekableReadStream; @@ -43,6 +44,7 @@ public: Common::SeekableReadStream *getFilePointer(); void closeFilePointer(Common::SeekableReadStream *&file); + Common::FSNode _fsnode; bool _boundToExe; byte _priority; bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); -- cgit v1.2.3 From 579810d296a355f003b5bfc00aeed00ff7247ec6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:14:38 +0200 Subject: WINTERMUTE: Use hasSuffix instead of contains to verify file-extensions. --- engines/wintermute/base/base_file_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1ff82d5e18..1e3e94c4f4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -277,7 +277,7 @@ bool BaseFileManager::registerPackages() { warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { - if (!fileIt->getName().contains(".dcp")) + if (!fileIt->getName().hasSuffix(".dcp")) continue; // Avoid registering all the language files // TODO: Select based on the gameDesc. -- cgit v1.2.3 From ec7362d13e8edc4ccf64ee004592cb10db8bc6f4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:30:22 +0200 Subject: WINTERMUTE: Clean up and comment base_disk_file. --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 76 +++++++++++++------------ engines/wintermute/base/file/base_disk_file.h | 2 +- 3 files changed, 42 insertions(+), 38 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1e3e94c4f4..addce1dea4 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -514,7 +514,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - ret = openDiskFile(filename, this); + ret = openDiskFile(filename); if (ret) return ret; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 21f7c7c189..09a83f5768 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -46,43 +46,63 @@ void correctSlashes(char *fileName) { } } -bool diskFileExists(const Common::String& filename) { - // Try directly from SearchMan first - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, filename); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { - if ((*it)->getName() == filename) { - return true; - } - } +// Parse a relative path in the game-folder, and if it exists, return a FSNode to it. +static Common::FSNode getNodeForRelativePath(const Common::String& filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + + // Absolute path: TODO: Add specific fallbacks here. if (filename.contains(':')) error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + + // Relative path: if (filename.contains('\\')) { Common::StringTokenizer path(filename, "\\"); - + + // Start traversing relative to the game-data-dir const Common::FSNode gameDataDir(ConfMan.get("path")); Common::FSNode curNode = gameDataDir; + + // Parse all path-elements while (!path.empty()) { + // Get the next path-component by slicing on '\\' Common::String pathPart = path.nextToken(); + // Get the next FSNode in the chain, if it exists as a child from the previous. Common::FSNode nextNode(curNode.getChild(pathPart)); if (nextNode.exists() && nextNode.isReadable()) { curNode = nextNode; } + // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { - if (curNode.exists() && curNode.isReadable()) - return true; - else - return false; + assert(path.empty()); + return curNode; + break; } } } + // Return an invalid FSNode to mark that we didn't find the requested file. + return Common::FSNode(); +} + +bool diskFileExists(const Common::String& filename) { + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + if ((*it)->getName() == filename) { + return true; + } + } + // File wasn't found in SearchMan, try to parse the path as a relative path. + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + return true; + } return false; } -Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager) { +Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; // Try directly from SearchMan first @@ -95,27 +115,11 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFil break; } } - // The filename can be an explicit path, thus we need to chop it up, expecting the path the game - // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + // File wasn't found in SearchMan, try to parse the path as a relative path. if (!file) { - if (filename.contains(':')) - error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); - if (filename.contains('\\')) { - Common::StringTokenizer path(filename, "\\"); - - const Common::FSNode gameDataDir(ConfMan.get("path")); - Common::FSNode curNode = gameDataDir; - while (!path.empty()) { - Common::String pathPart = path.nextToken(); - Common::FSNode nextNode(curNode.getChild(pathPart)); - if (nextNode.exists() && nextNode.isReadable()) { - curNode = nextNode; - } - if (!curNode.isDirectory()) { - file = curNode.createReadStream(); - break; - } - } + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + file = searchNode.createReadStream(); } } if (file) { diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 13d5c3e03c..0653b2e854 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -33,7 +33,7 @@ namespace WinterMute { -Common::SeekableReadStream *openDiskFile(const Common::String &filename, BaseFileManager *fileManager); +Common::SeekableReadStream *openDiskFile(const Common::String &filename); bool diskFileExists(const Common::String& filename); } // end of namespace WinterMute -- cgit v1.2.3 From c59965ad4faca67be0dad554bc291a97f2691dff Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 24 Jul 2012 18:49:01 +0200 Subject: WINTERMUTE: Make sure we don't skip path-components. --- engines/wintermute/base/file/base_disk_file.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 09a83f5768..c03a9b61e7 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -69,14 +69,19 @@ static Common::FSNode getNodeForRelativePath(const Common::String& filename) { Common::String pathPart = path.nextToken(); // Get the next FSNode in the chain, if it exists as a child from the previous. Common::FSNode nextNode(curNode.getChild(pathPart)); + if (!nextNode.exists()) { + // Return an invalid FSNode. + return Common::FSNode(); + } if (nextNode.exists() && nextNode.isReadable()) { curNode = nextNode; } // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { - assert(path.empty()); + if (!path.empty()) { + error("Relative path %s reached a file before the end of the path", filename.c_str()); + } return curNode; - break; } } } -- cgit v1.2.3 From 8be1e095fd6ab78f8f90633d254643f5bb45ffd4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 00:08:39 +0200 Subject: WINTERMUTE: Avoid starting up the engine to perform detection. --- engines/wintermute/base/base_file_manager.cpp | 13 ++-- engines/wintermute/base/base_file_manager.h | 12 ++-- engines/wintermute/base/file/base_package.cpp | 14 ++-- engines/wintermute/base/file/dcpackage.h | 96 +++++++++++++++++++++++++++ engines/wintermute/base/gfx/base_image.cpp | 10 +-- 5 files changed, 120 insertions(+), 25 deletions(-) create mode 100644 engines/wintermute/base/file/dcpackage.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index addce1dea4..d54fe96854 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_file_entry.h" @@ -37,9 +35,8 @@ #include "engines/wintermute/base/file/base_resources.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/dcpackage.h" +#include "engines/wintermute/base/file/dcpackage.h" #include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/textconsole.h" @@ -58,12 +55,11 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(BaseGame *inGame): BaseClass(inGame) { +BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) { initPaths(); registerPackages(); } - ////////////////////////////////////////////////////////////////////// BaseFileManager::~BaseFileManager() { cleanup(); @@ -207,6 +203,9 @@ bool BaseFileManager::reloadPaths() { #define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { + if (!_gameRef) // This function only works when the game-registry is loaded + return STATUS_FAILED; + AnsiString pathList; int numPaths; @@ -506,6 +505,8 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + if (!_gameRef) + error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index f859e39b00..cacdb8bf2d 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -29,20 +29,17 @@ #ifndef WINTERMUTE_BFILEMANAGER_H #define WINTERMUTE_BFILEMANAGER_H -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/file/base_package.h" #include "common/archive.h" #include "common/str.h" #include "common/fs.h" - -namespace Common { -class File; -} +#include "common/file.h" namespace WinterMute { class BaseFile; class BaseFileEntry; -class BaseFileManager: BaseClass { +class BaseGame; +class BasePackage; +class BaseFileManager { public: bool cleanup(); @@ -77,6 +74,7 @@ private: bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); // bool registerPackage(const Common::String &filename, bool searchSignature = false); + BaseGame *_gameRef; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 427f2f46f8..1706a7a50b 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -57,10 +57,10 @@ BasePackage::~BasePackage() { ////////////////////////////////////////////////////////////////////////// bool BasePackage::open() { - if (_file) return STATUS_OK; + if (_file) return true; else { _file = getFilePointer(); - return _file ? STATUS_OK : STATUS_FAILED; + return _file ? true : false; } } @@ -69,18 +69,18 @@ bool BasePackage::open() { bool BasePackage::close() { delete _file; _file = NULL; - return STATUS_OK; + return true; } ////////////////////////////////////////////////////////////////////////// bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { bool ret; - if (DID_FAIL(ret = open())) return ret; + if (!(ret = open())) return ret; else { - if (file->seek(offset, SEEK_SET)) return STATUS_FAILED; - if (file->read(buffer, size) != 1) return STATUS_FAILED; - else return STATUS_OK; + if (file->seek(offset, SEEK_SET)) return false; + if (file->read(buffer, size) != 1) return false; + else return true; } } diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h new file mode 100644 index 0000000000..5e47edba56 --- /dev/null +++ b/engines/wintermute/base/file/dcpackage.h @@ -0,0 +1,96 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef _DCPACKAGE_H_ +#define _DCPACKAGE_H_ + + +#define PACKAGE_MAGIC_1 0xDEC0ADDE +#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" +#define PACKAGE_VERSION 0x00000200 +#define PACKAGE_EXTENSION "dcp" + +#include "common/stream.h" + +namespace WinterMute { + +struct TPackageHeader { + uint32 _magic1; + uint32 _magic2; + uint32 _packageVersion; + uint32 _gameVersion; + byte _priority; + byte _cd; + bool _masterIndex; + uint32 _creationTime; + char _desc[100]; + uint32 _numDirs; + // TODO: Move this out of the header. + void readFromStream(Common::ReadStream *stream) { + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); + + _gameVersion = stream->readUint32LE(); + + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + _creationTime = stream->readUint32LE(); + + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); + } +}; + +/* +v2: uint32 DirOffset + + +Dir: byte NameLength + char Name [NameLength] + byte CD; + uint32 NumEntries + + +Entry: byte NameLength + char Name [NameLength] + uint32 Offset + uint32 Length + uint32 CompLength + uint32 Flags +v2: uint32 TimeDate1 + uint32 TimeDate2 // not used + +*/ + +} // end of namespace WinterMute + +#endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index bdc7cb76e2..2c18b64110 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -82,14 +82,14 @@ bool BaseImage::loadFile(const Common::String &filename) { } _filename = filename; Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) return STATUS_FAILED; + if (!file) return false; _decoder->loadStream(*file); _surface = _decoder->getSurface(); _palette = _decoder->getPalette(); _fileManager->closeFile(file); - return STATUS_OK; + return true; } byte BaseImage::getAlphaAt(int x, int y) { @@ -113,7 +113,7 @@ bool BaseImage::saveBMPFile(const char *filename) { if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; else return STATUS_FAILED; #endif - return STATUS_FAILED; + return false; } @@ -133,7 +133,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { return STATUS_OK; } else return STATUS_FAILED; #endif - return STATUS_FAILED; + return false; } @@ -258,7 +258,7 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { _deletableSurface = NULL; } _surface = _deletableSurface = temp.scale(newWidth, newHeight); - return STATUS_OK; + return true; } } // end of namespace WinterMute -- cgit v1.2.3 From 7521d0f26545381a740307d3a1d2f52e53462bfa Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 00:31:12 +0200 Subject: WINTERMUTE: Cleanup in BaseFileManager --- engines/wintermute/base/base_file_manager.cpp | 62 ++++++++------------------- engines/wintermute/base/base_file_manager.h | 6 +-- 2 files changed, 22 insertions(+), 46 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index d54fe96854..3317b01c6f 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -31,14 +31,14 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_resources.h" +#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/file/dcpackage.h" -#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" +#include "common/tokenizer.h" #include "common/textconsole.h" #include "common/util.h" #include "common/config-manager.h" @@ -96,7 +96,6 @@ bool BaseFileManager::cleanup() { -#define MAX_FILE_SIZE 10000000 ////////////////////////////////////////////////////////////////////// byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; @@ -108,15 +107,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz return NULL; } - /* - if (File->GetSize() > MAX_FILE_SIZE) { - _gameRef->LOG(0, "File '%s' exceeds the maximum size limit (%d bytes)", Filename, MAX_FILE_SIZE); - CloseFile(File); - return NULL; - } - */ - - buffer = new byte[file->size() + 1]; if (buffer == NULL) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); @@ -207,39 +197,36 @@ bool BaseFileManager::initPaths() { return STATUS_FAILED; AnsiString pathList; - int numPaths; // single files paths pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); - numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - error("BaseFileManager::initPaths - Game wants to add customPath: %s", path); // TODO -// addPath(PATH_SINGLE, path); + Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); +// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); + while (!entries->empty()) { + Common::String path = entries->nextToken(); + if (path.size() > 0) { + error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO + // addPath(PATH_SINGLE, path); } - delete[] path; - path = NULL; } -// addPath(PATH_SINGLE, ".\\"); + delete entries; + entries = NULL; // package files paths const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); - numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - - for (int i = 0; i < numPaths; i++) { - char *path = BaseUtils::strEntry(i, pathList.c_str(), ';'); - if (path && strlen(path) > 0) { - error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path); // TODO -// addPath(PATH_PACKAGE, path); + entries = new Common::StringTokenizer(pathList, ";"); + while (!entries->empty()) { + Common::String path = entries->nextToken(); + if (path.size() > 0) { + error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO + // addPath(PATH_SINGLE, path); } - delete[] path; - path = NULL; } + delete entries; + entries = NULL; Common::FSNode dataSubFolder = gameData.getChild("data"); if (dataSubFolder.exists()) { @@ -296,17 +283,6 @@ bool BaseFileManager::registerPackages() { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -/*bool BaseFileManager::registerPackage(const Common::String &filename , bool searchSignature) { - Common::File *package = new Common::File(); - package->open(filename); - if (!package->isOpen()) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Error opening package file '%s'. Ignoring.", filename.c_str()); - return STATUS_OK; - } - return registerPackage(package, filename); -}*/ - bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; bool boundToExe = false; diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index cacdb8bf2d..776fc32df1 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -70,15 +70,15 @@ private: bool registerPackages(); Common::SeekableReadStream *openFileRaw(const Common::String &filename); Common::FSList _packagePaths; -// Common::FSList _singlePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); -// bool registerPackage(const Common::String &filename, bool searchSignature = false); - BaseGame *_gameRef; Common::Array _packages; Common::Array _openFiles; Common::HashMap _files; Common::HashMap::iterator _filesIter; + // This class is intentionally not a subclass of Base, as it needs to be used by + // the detector too, without launching the entire engine: + BaseGame *_gameRef; }; } // end of namespace WinterMute -- cgit v1.2.3 From ab8d13ee5806f7d9cf6e352482934ad371a55e11 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:20:17 +0200 Subject: WINTERMUTE: Change the DCP-file access to work as an Common::Archive. --- engines/wintermute/base/base_file_manager.cpp | 236 ++-------------------- engines/wintermute/base/base_file_manager.h | 12 +- engines/wintermute/base/file/BPkgFile.cpp | 107 ---------- engines/wintermute/base/file/BPkgFile.h | 49 ----- engines/wintermute/base/file/base_file_entry.cpp | 53 +++++ engines/wintermute/base/file/base_file_entry.h | 6 +- engines/wintermute/base/file/base_package.cpp | 245 ++++++++++++++++++----- engines/wintermute/base/file/base_package.h | 58 ++++-- 8 files changed, 320 insertions(+), 446 deletions(-) delete mode 100644 engines/wintermute/base/file/BPkgFile.cpp delete mode 100644 engines/wintermute/base/file/BPkgFile.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 3317b01c6f..2661081528 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -29,13 +29,10 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" -#include "engines/wintermute/base/file/base_file_entry.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/file/dcpackage.h" #include "engines/wintermute/wintermute.h" #include "common/str.h" #include "common/tokenizer.h" @@ -71,31 +68,18 @@ bool BaseFileManager::cleanup() { // delete registered paths _packagePaths.clear(); - // delete file entries - _filesIter = _files.begin(); - while (_filesIter != _files.end()) { - delete _filesIter->_value; - _filesIter++; - } - _files.clear(); - // close open files for (uint32 i = 0; i < _openFiles.size(); i++) { delete _openFiles[i]; } _openFiles.clear(); - // delete packages - for (uint32 i = 0; i < _packages.size(); i++) - delete _packages[i]; _packages.clear(); return STATUS_OK; } - - ////////////////////////////////////////////////////////////////////// byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { byte *buffer = NULL; @@ -149,19 +133,6 @@ bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uin return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::requestCD(int cd, char *packageFile, const char *filename) { - // unmount all non-local packages - for (uint32 i = 0; i < _packages.size(); i++) { - if (_packages[i]->_cd > 0) _packages[i]->close(); - } - - - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { if (!path.exists()) @@ -189,8 +160,6 @@ bool BaseFileManager::reloadPaths() { return initPaths(); } - -#define TEMP_BUFFER_SIZE 32768 ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { if (!_gameRef) // This function only works when the game-registry is loaded @@ -248,7 +217,6 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { } } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return true; } @@ -278,177 +246,44 @@ bool BaseFileManager::registerPackages() { } } - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); +// debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { - uint32 absoluteOffset = 0; - bool boundToExe = false; - Common::SeekableReadStream * package = file.createReadStream(); - if (!package) - return STATUS_FAILED; - if (searchSignature) { - uint32 offset; - if (!findPackageSignature(package, &offset)) { - delete package; - return STATUS_OK; - } else { - package->seek(offset, SEEK_SET); - absoluteOffset = offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(package); - if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete package; - return STATUS_OK; - } - - if (hdr._packageVersion != PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); - } - - // new in v2 - if (hdr._packageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = package->readUint32LE(); - dirOffset += absoluteOffset; - package->seek(dirOffset, SEEK_SET); - } - - for (uint32 i = 0; i < hdr._numDirs; i++) { - BasePackage *pkg = new BasePackage(this); - pkg->_fsnode = file; - if (!pkg) return STATUS_FAILED; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = package->readByte(); - pkg->_name = new char[nameLength]; - package->read(pkg->_name, nameLength); - pkg->_cd = package->readByte(); - pkg->_priority = hdr._priority; - - if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk - _packages.push_back(pkg); - - - // read file entries - uint32 numFiles = package->readUint32LE(); - - for (uint32 j = 0; j < numFiles; j++) { - char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; + PackageSet *pack = new PackageSet(file, filename, searchSignature); + _packages.add(file.getName(), pack, pack->getPriority() , true); - nameLength = package->readByte(); - name = new char[nameLength]; - package->read(name, nameLength); - - // v2 - xor name - if (hdr._packageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; - - Common::String upcName = name; - upcName.toUppercase(); - delete[] name; - name = NULL; - - offset = package->readUint32LE(); - offset += absoluteOffset; - length = package->readUint32LE(); - compLength = package->readUint32LE(); - flags = package->readUint32LE(); - - if (hdr._packageVersion == PACKAGE_VERSION) { - timeDate1 = package->readUint32LE(); - timeDate2 = package->readUint32LE(); - } - _filesIter = _files.find(upcName.c_str()); - if (_filesIter == _files.end()) { - BaseFileEntry *file = new BaseFileEntry(); - file->_package = pkg; - file->_offset = offset; - file->_length = length; - file->_compressedLength = compLength; - file->_flags = flags; - - _files[upcName.c_str()] = file; - } else { - // current package has lower CD number or higher priority, than the registered - if (pkg->_cd < _filesIter->_value->_package->_cd || pkg->_priority > _filesIter->_value->_package->_priority) { - _filesIter->_value->_package = pkg; - _filesIter->_value->_offset = offset; - _filesIter->_value->_length = length; - _filesIter->_value->_compressedLength = compLength; - _filesIter->_value->_flags = flags; - } - } - } - } - - - delete package; return STATUS_OK; } - ////////////////////////////////////////////////////////////////////////// -Common::File *BaseFileManager::openPackage(const Common::String &name) { - //TODO: Is it really necessary to do this when we have the ScummVM-system? - Common::File *ret = new Common::File(); - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - Common::String packageName = (*it).getName(); - if (packageName == (name + ".dcp")) - ret->open((*it)); - if (ret->isOpen()) { - return ret; - } - } - Common::String filename = Common::String::format("%s.%s", name.c_str(), PACKAGE_EXTENSION); - ret->open(filename); - if (ret->isOpen()) { - return ret; +Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &filename) { + Common::String upcName = filename; + upcName.toUppercase(); + Common::SeekableReadStream *file = NULL; + char fileName[MAX_PATH_LENGTH]; + strcpy(fileName, upcName.c_str()); + + // correct slashes + for (int32 i = 0; i < upcName.size(); i++) { + if (upcName[i] == '/') + upcName.setChar('\\', (uint32)i); } - warning("BaseFileManager::OpenPackage - Couldn't load file %s", name.c_str()); - delete ret; - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry *BaseFileManager::getPackageEntry(const Common::String &filename) { - Common::String upc_name = filename; - upc_name.toUppercase(); - - BaseFileEntry *ret = NULL; - _filesIter = _files.find(upc_name.c_str()); - if (_filesIter != _files.end()) ret = _filesIter->_value; - - return ret; + Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + file = entry->createReadStream(); + return file; } bool BaseFileManager::hasFile(const Common::String &filename) { if (diskFileExists(filename)) return true; - if (getPackageEntry(filename)) + if (_packages.hasFile(filename)) return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. if (BaseResources::hasFile(filename)) return true; return false; - return true; } ////////////////////////////////////////////////////////////////////////// @@ -495,7 +330,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f if (ret) return ret; - ret = openPkgFile(filename, this); + ret = openPkgFile(filename); if (ret) return ret; @@ -507,37 +342,4 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return NULL; } - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 776fc32df1..89d1e5b46b 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -35,10 +35,7 @@ #include "common/file.h" namespace WinterMute { -class BaseFile; -class BaseFileEntry; class BaseGame; -class BasePackage; class BaseFileManager { public: bool cleanup(); @@ -55,10 +52,6 @@ public: bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); // Used only for detection bool registerPackages(const Common::FSList &fslist); - // Used by BasePackage only - BaseFileEntry *getPackageEntry(const Common::String &filename); - Common::File *openPackage(const Common::String &name); - bool requestCD(int cd, char *packageFile, const char *filename); private: typedef enum { PATH_PACKAGE, @@ -69,13 +62,12 @@ private: bool addPath(TPathType type, const Common::FSNode &path); bool registerPackages(); Common::SeekableReadStream *openFileRaw(const Common::String &filename); + Common::SeekableReadStream *openPkgFile(const Common::String &filename); Common::FSList _packagePaths; bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); - Common::Array _packages; + Common::SearchSet _packages; Common::Array _openFiles; - Common::HashMap _files; - Common::HashMap::iterator _filesIter; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: BaseGame *_gameRef; diff --git a/engines/wintermute/base/file/BPkgFile.cpp b/engines/wintermute/base/file/BPkgFile.cpp deleted file mode 100644 index be37571901..0000000000 --- a/engines/wintermute/base/file/BPkgFile.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/BPkgFile.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "common/util.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace WinterMute { - -// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size -// as such it is not renamed to follow the convention of the rest of the files. - -// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. -class CBPkgFile : public Common::SeekableReadStream { - uint32 _size; - Common::SeekableReadStream *_stream; -public: - CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { - delete _stream; - } - virtual uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } - virtual bool eos() const { - return _stream->eos(); - } - virtual int32 pos() const { - return _stream->pos(); - } - virtual int32 size() const { - return _size; - } - virtual bool seek(int32 offset, int whence = SEEK_SET) { - return _stream->seek(offset, whence); - } -}; - -Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager) { - BaseFileEntry *fileEntry; - Common::SeekableReadStream *file = NULL; - char fileName[MAX_PATH_LENGTH]; - strcpy(fileName, filename.c_str()); - - // correct slashes - for (uint32 i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '/') fileName[i] = '\\'; - } - - fileEntry = fileManager->getPackageEntry(fileName); - if (!fileEntry) return NULL; - - file = fileEntry->_package->getFilePointer(); - if (!file) return NULL; - - // TODO: Cleanup - bool compressed = (fileEntry->_compressedLength != 0); - /* _size = fileEntry->_length; */ - - if (compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES)); - } else { - file = new Common::SeekableSubReadStream(file, fileEntry->_offset, fileEntry->_offset + fileEntry->_length, DisposeAfterUse::YES); - } - if (file->size() == 0) { - file = new CBPkgFile(file, fileEntry->_length); - } - - file->seek(0); - - return file; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/file/BPkgFile.h b/engines/wintermute/base/file/BPkgFile.h deleted file mode 100644 index ca1b1f837d..0000000000 --- a/engines/wintermute/base/file/BPkgFile.h +++ /dev/null @@ -1,49 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BPKGFILE_H -#define WINTERMUTE_BPKGFILE_H - -#include "engines/wintermute/base/file/base_file_entry.h" - -// This file is only needed until the next merge/rebase, as wrapCompressedStream now can set a known size -// as such it is not renamed to follow the convention of the rest of the files. - -namespace Common { -class SeekableReadStream; -class File; -} - -namespace WinterMute { - -class BaseFileManager; -Common::SeekableReadStream *openPkgFile(const Common::String &filename, BaseFileManager *fileManager); - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 43527f9fc0..5032650704 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -27,8 +27,61 @@ */ #include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/base_package.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" namespace WinterMute { +// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. +class CBPkgFile : public Common::SeekableReadStream { + uint32 _size; + Common::SeekableReadStream *_stream; +public: + CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} + virtual ~CBPkgFile() { + delete _stream; + } + virtual uint32 read(void *dataPtr, uint32 dataSize) { + return _stream->read(dataPtr, dataSize); + } + virtual bool eos() const { + return _stream->eos(); + } + virtual int32 pos() const { + return _stream->pos(); + } + virtual int32 size() const { + return _size; + } + virtual bool seek(int32 offset, int whence = SEEK_SET) { + return _stream->seek(offset, whence); + } +}; + +Common::SeekableReadStream *BaseFileEntry::createReadStream() const { + Common::SeekableReadStream *file = _package->getFilePointer(); + if (!file) return NULL; + + // TODO: Cleanup + bool compressed = (_compressedLength != 0); + /* _size = fileEntry->_length; */ + + if (compressed) { + // TODO: Really, most of this logic might be doable directly in the fileEntry? + // But for now, this should get us rolling atleast. + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); + } else { + file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); + } + if (file->size() == 0) { + file = new CBPkgFile(file, _length); + } + + file->seek(0); + + return file; +} ////////////////////////////////////////////////////////////////////////// BaseFileEntry::BaseFileEntry(){ diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 086a70e7ed..b94a6cd9fc 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -29,14 +29,18 @@ #ifndef WINTERMUTE_BFILEENTRY_H #define WINTERMUTE_BFILEENTRY_H +#include "common/archive.h" #include "common/str.h" +#include "common/stream.h" namespace WinterMute { class BasePackage; -class BaseFileEntry { +class BaseFileEntry : public Common::ArchiveMember { public: + virtual Common::SeekableReadStream *createReadStream() const; + virtual Common::String getName() const { return _filename; } uint32 _timeDate2; uint32 _timeDate1; uint32 _flags; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 1706a7a50b..6987cad3e6 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -27,78 +27,229 @@ */ #include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/dcpackage.h" +#include "engines/wintermute/wintermute.h" #include "common/file.h" #include "common/stream.h" +#include "common/debug.h" namespace WinterMute { -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////////// -BasePackage::BasePackage(BaseFileManager *fileMan)/*: BaseClass(inGame) */{ - _file = NULL; - _name = NULL; +BasePackage::BasePackage() { + _name = ""; _cd = 0; _priority = 0; _boundToExe = false; - _fileManager = fileMan; } +Common::SeekableReadStream *BasePackage::getFilePointer() { + Common::SeekableReadStream *stream = _fsnode.createReadStream(); -////////////////////////////////////////////////////////////////////////// -BasePackage::~BasePackage() { - if (_name) delete [] _name; - closeFilePointer(_file); + return stream; } - -////////////////////////////////////////////////////////////////////////// -bool BasePackage::open() { - if (_file) return true; - else { - _file = getFilePointer(); - return _file ? true : false; +static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) return false; + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + } + return false; + } +PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { + uint32 absoluteOffset = 0; + _priority = 0; + bool boundToExe = false; + Common::SeekableReadStream *stream = file.createReadStream(); + if (!stream) + return; + if (searchSignature) { + uint32 offset; + if (!findPackageSignature(stream, &offset)) { + delete stream; + return; + } else { + stream->seek(offset, SEEK_SET); + absoluteOffset = offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(stream); + if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete stream; + return; + } + + if (hdr._packageVersion != PACKAGE_VERSION) { + debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); + } + _priority = hdr._priority; + // new in v2 + if (hdr._packageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = stream->readUint32LE(); + dirOffset += absoluteOffset; + stream->seek(dirOffset, SEEK_SET); + } + assert(hdr._numDirs == 1); + for (uint32 i = 0; i < hdr._numDirs; i++) { + BasePackage *pkg = new BasePackage(); + if (!pkg) return; + pkg->_fsnode = file; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = stream->readByte(); + char *pkgName = new char[nameLength]; + stream->read(pkgName, nameLength); + pkg->_name = pkgName; + pkg->_cd = stream->readByte(); + pkg->_priority = hdr._priority; + delete[] pkgName; + pkgName = NULL; + + if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk + _packages.push_back(pkg); + + + // read file entries + uint32 numFiles = stream->readUint32LE(); + + for (uint32 j = 0; j < numFiles; j++) { + char *name; + uint32 offset, length, compLength, flags, timeDate1, timeDate2; + + nameLength = stream->readByte(); + name = new char[nameLength]; + stream->read(name, nameLength); + + // v2 - xor name + if (hdr._packageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); + warning( "Package contains %s", name); + // some old version of ProjectMan writes invalid directory entries + // so at least prevent strupr from corrupting memory + name[nameLength - 1] = '\0'; + + Common::String upcName = name; + upcName.toUppercase(); + delete[] name; + name = NULL; + + offset = stream->readUint32LE(); + offset += absoluteOffset; + length = stream->readUint32LE(); + compLength = stream->readUint32LE(); + flags = stream->readUint32LE(); + + if (hdr._packageVersion == PACKAGE_VERSION) { + timeDate1 = stream->readUint32LE(); + timeDate2 = stream->readUint32LE(); + } + _filesIter = _files.find(upcName.c_str()); + if (_filesIter == _files.end()) { + BaseFileEntry *fileEntry = new BaseFileEntry(); + fileEntry->_package = pkg; + fileEntry->_offset = offset; + fileEntry->_length = length; + fileEntry->_compressedLength = compLength; + fileEntry->_flags = flags; + + _files[upcName.c_str()] = Common::ArchiveMemberPtr(fileEntry); + } else { + // current package has higher priority than the registered + // TODO: This cast might be a bit ugly. + BaseFileEntry *filePtr = (BaseFileEntry*) &*(_filesIter->_value); + if (pkg->_priority > filePtr->_package->_priority) { + filePtr->_package = pkg; + filePtr->_offset = offset; + filePtr->_length = length; + filePtr->_compressedLength = compLength; + filePtr->_flags = flags; + } + } + } + } + debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + delete stream; +} -////////////////////////////////////////////////////////////////////////// -bool BasePackage::close() { - delete _file; - _file = NULL; - return true; +PackageSet::~PackageSet() { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + delete *it; + } + _packages.clear(); } +bool PackageSet::hasFile(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return (it != _files.end()); +} -////////////////////////////////////////////////////////////////////////// -bool BasePackage::read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size) { - bool ret; - if (!(ret = open())) return ret; - else { - if (file->seek(offset, SEEK_SET)) return false; - if (file->read(buffer, size) != 1) return false; - else return true; +int PackageSet::listMembers(Common::ArchiveMemberList &list) const { + Common::HashMap::const_iterator it = _files.begin(); + Common::HashMap::const_iterator end = _files.end(); + int count = 0; + for (; it != end; ++it) { + const Common::ArchiveMemberPtr ptr(it->_value); + list.push_back(ptr); + count++; } + return count; } -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::SeekableReadStream *stream = _fsnode.createReadStream(); -/* Common::File *file = _fileManager->openPackage(_name); - if (!file) { - _fileManager->requestCD(_cd, _name, ""); - file = _fileManager->openPackage(_name); - }*/ - return stream; +const Common::ArchiveMemberPtr PackageSet::getMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return Common::ArchiveMemberPtr(it->_value); } -////////////////////////////////////////////////////////////////////////// -void BasePackage::closeFilePointer(Common::SeekableReadStream *&file) { - delete file; - file = NULL; +Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + if (it != _files.end()) + return it->_value->createReadStream(); + return NULL; } } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 673655a710..b9a7bc5934 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -29,32 +29,60 @@ #ifndef WINTERMUTE_BPACKAGE_H #define WINTERMUTE_BPACKAGE_H +#include "common/archive.h" #include "common/stream.h" #include "common/fs.h" -namespace Common { -class SeekableReadStream; -} - namespace WinterMute { -class BaseFileManager; class BasePackage { - BaseFileManager *_fileManager; public: Common::SeekableReadStream *getFilePointer(); - void closeFilePointer(Common::SeekableReadStream *&file); - Common::FSNode _fsnode; bool _boundToExe; byte _priority; - bool read(Common::SeekableReadStream *file, uint32 offset, byte *buffer, uint32 size); - bool close(); - bool open(); - char *_name; + Common::String _name; int _cd; - Common::SeekableReadStream *_file; - BasePackage(BaseFileManager *fileMan); - ~BasePackage(); + BasePackage(); +}; + +class PackageSet : public Common::Archive { +public: + virtual ~PackageSet(); + + PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); + /** + * Check if a member with the given name is present in the Archive. + * Patterns are not allowed, as this is meant to be a quick File::exists() + * replacement. + */ + virtual bool hasFile(const Common::String &name) const; + + /** + * Add all members of the Archive to list. + * Must only append to list, and not remove elements from it. + * + * @return the number of names added to list + */ + virtual int listMembers(Common::ArchiveMemberList &list) const; + + /** + * Returns a ArchiveMember representation of the given file. + */ + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; + + /** + * Create a stream bound to a member with the specified name in the + * archive. If no member with this name exists, 0 is returned. + * @return the newly created input stream + */ + virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + + int getPriority() const { return _priority; } +private: + byte _priority; + Common::Array _packages; + Common::HashMap _files; + Common::HashMap::iterator _filesIter; }; } // end of namespace WinterMute -- cgit v1.2.3 From b05b6210b73d47461de9392c4936a5cb4dde57e1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:32:54 +0200 Subject: WINTERMUTE: Forgot to add this change to last commit (SQUASHME) --- engines/wintermute/base/file/base_disk_file.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index c03a9b61e7..35546b0001 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/BPkgFile.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/base_file_manager.h" #include "common/stream.h" -- cgit v1.2.3 From 28759d7aa3b3b6ef9e01a806fe277ca83d7ee30d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 03:33:24 +0200 Subject: WINTERMUTE: Move SaveGame-file-saving handling over to BasePersistenceManager --- engines/wintermute/base/base_file_manager.cpp | 21 --------------------- engines/wintermute/base/base_file_manager.h | 3 --- .../wintermute/base/base_persistence_manager.cpp | 16 ++++++++++++++-- engines/wintermute/base/base_persistence_manager.h | 2 +- 4 files changed, 15 insertions(+), 27 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 2661081528..156aff61fe 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -112,27 +112,6 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz return buffer; } -Common::SeekableReadStream *BaseFileManager::loadSaveGame(const Common::String &filename) { - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::InSaveFile *file = saveMan->openForLoading(filename); - return file; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed, byte *prefixBuffer, uint32 prefixSize) { - // TODO - warning("Implement SaveFile"); - - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - file->finalize(); - delete file; - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { if (!path.exists()) diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 89d1e5b46b..e3c20378bb 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -43,13 +43,10 @@ public: bool closeFile(Common::SeekableReadStream *File); bool hasFile(const Common::String &filename); Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - Common::SeekableReadStream *loadSaveGame(const Common::String &filename); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); BaseFileManager(BaseGame *inGame = NULL); virtual ~BaseFileManager(); - // Used only by BasePersistenceManager - bool saveFile(const Common::String &filename, byte *buffer, uint32 bufferSize, bool compressed = false, byte *prefixBuffer = NULL, uint32 prefixSize = 0); // Used only for detection bool registerPackages(const Common::FSList &fslist); private: diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bcdb93a93e..5f8a2114c1 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -359,8 +359,20 @@ bool BasePersistenceManager::initLoad(const char *filename) { ////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::saveFile(const char *filename) { - return _gameRef->_fileManager->saveFile(filename, ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(), ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(), _gameRef->_compressedSavegames, _richBuffer, _richBufferSize); +bool BasePersistenceManager::saveFile(const Common::String &filename) { + byte *prefixBuffer = _richBuffer; + uint32 prefixSize = _richBufferSize; + byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); + uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); + + Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + bool retVal = !file->err(); + file->finalize(); + delete file; + return retVal; } diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index a59f797668..78d3230c47 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -47,7 +47,7 @@ public: char *_savedDescription; Common::String _savePrefix; Common::String _savedName; - bool saveFile(const char *filename); + bool saveFile(const Common::String &filename); uint32 getDWORD(); void putDWORD(uint32 val); char *getString(); -- cgit v1.2.3 From 45c5eb5cab069ea9ca4302a637f4621d460c790d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 05:08:13 +0200 Subject: WINTERMUTE: Privatize/Protect variables that don't need to be public. --- engines/wintermute/base/base.h | 4 +- engines/wintermute/base/base_fader.h | 1 + engines/wintermute/base/base_game.cpp | 9 +- engines/wintermute/base/base_game.h | 227 +++++++++++---------- engines/wintermute/base/base_object.h | 67 +++--- .../wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/base_persistence_manager.h | 2 +- engines/wintermute/base/base_save_thumb_helper.h | 1 + engines/wintermute/base/base_string_table.cpp | 12 +- engines/wintermute/base/base_string_table.h | 4 +- .../wintermute/base/file/base_save_thumb_file.cpp | 6 +- engines/wintermute/base/font/base_font_bitmap.h | 3 +- engines/wintermute/base/gfx/base_renderer.h | 18 +- engines/wintermute/base/gfx/base_surface.h | 12 +- engines/wintermute/base/particles/part_emitter.h | 85 ++++---- engines/wintermute/base/scriptables/script.h | 18 +- .../wintermute/base/scriptables/script_ext_array.h | 1 + .../wintermute/base/scriptables/script_ext_date.h | 2 +- .../base/scriptables/script_ext_mem_buffer.h | 3 +- .../base/scriptables/script_ext_object.h | 1 - engines/wintermute/base/scriptables/script_value.h | 2 +- engines/wintermute/base/sound/base_sound_buffer.h | 7 +- 22 files changed, 244 insertions(+), 243 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index 0265ce97d5..8c6aad12e6 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -49,10 +49,10 @@ public: bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); BaseClass(); - BaseGame *_gameRef; BaseClass(BaseGame *GameOwner); virtual ~BaseClass(); - + BaseGame *_gameRef; +protected: Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; /* std::map _editorProps; diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 36dd8a1d53..4401bd0ebd 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -46,6 +46,7 @@ public: DECLARE_PERSISTENT(BaseFader, BaseObject) BaseFader(BaseGame *inGame); virtual ~BaseFader(); +private: bool _active; byte _red; byte _green; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 301f79691d..fcf45f18f2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -104,7 +104,6 @@ BaseGame::BaseGame(): BaseObject(this) { _debugLogFile = NULL; _debugDebugMode = false; - _debugAbsolutePathWarning = true; _debugShowFPS = false; _systemFont = NULL; @@ -180,7 +179,7 @@ BaseGame::BaseGame(): BaseObject(this) { _compressedSavegames = true; _editorMode = false; - _doNotExpandStrings = false; + //_doNotExpandStrings = false; _engineLogCallback = NULL; _engineLogCallbackData = NULL; @@ -3241,7 +3240,6 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - _debugAbsolutePathWarning = false; if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; //if(DID_FAIL(ret = cleanup())) goto load_finish; @@ -3259,7 +3257,6 @@ bool BaseGame::loadGame(const char *filename) { getDebugMgr()->onGameInit(); load_finish: - _debugAbsolutePathWarning = true; _indicatorDisplay = false; delete pm; @@ -3555,7 +3552,6 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_activeObject)); persistMgr->transfer(TMEMBER(_capturedObject)); persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_doNotExpandStrings)); persistMgr->transfer(TMEMBER(_editorMode)); persistMgr->transfer(TMEMBER(_fader)); persistMgr->transfer(TMEMBER(_freezeLevel)); @@ -3838,14 +3834,11 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (!pm) return STATUS_FAILED; - _debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(filename))) { - _debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _debugAbsolutePathWarning = true; strcpy(buffer, pm->_savedDescription); delete pm; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 4a5adb4e39..34dec89d20 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -105,54 +105,21 @@ public: TTextEncoding _textEncoding; bool _textRTL; - BaseSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - virtual bool resetContent(); void DEBUG_DumpClassRegistry(); bool setWaitCursor(const char *filename); - char *_localSaveDir; - bool _saveDirChecked; - int _indicatorProgress; -protected: - bool _indicatorDisplay; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - - bool _richSavedGames; - char *_savedGameExt; - - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - BaseSurface *_saveLoadImage; - bool displayIndicator(); + int _indicatorProgress; // TODO: Hide - bool _reportTextureFormat; -public: int _thumbnailWidth; int _thumbnailHeight; - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; bool _editorMode; - - bool _doNotExpandStrings; void getOffset(int *offsetX, int *offsetY); void setOffset(int offsetX, int offsetY); int getSequence(); + int _offsetY; int _offsetX; float _offsetPercentX; @@ -181,20 +148,16 @@ public: BaseSurfaceStorage *_surfaceStorage; BaseFontStorage *_fontStorage; BaseGame(); - virtual ~BaseGame(); + void DEBUG_DebugDisable(); void DEBUG_DebugEnable(const char *filename = NULL); bool _debugDebugMode; - bool _debugAbsolutePathWarning; void *_debugLogFile; int _sequence; virtual bool loadFile(const char *filename); virtual bool loadBuffer(byte *buffer, bool complete = true); - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; int _viewportSP; @@ -203,22 +166,8 @@ public: int _settingsResHeight; char *_settingsGameFile; bool _suppressScriptErrors; - bool _mouseLeftDown; -protected: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - BaseFader *_fader; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); -public: + bool _mouseLeftDown; // TODO: Hide + virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface virtual ScValue *scGetProperty(const char *name); @@ -228,68 +177,33 @@ public: // compatibility bits bool _compatKillMethodThreads; -private: - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; -public: const char* getGameId() { return _gameId.c_str(); } void setGameId(const Common::String& gameId) { _gameId = gameId; } uint32 _surfaceGCCycleTime; - bool _smartCache; - bool _videoSubtitles; - bool _subtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; + bool _smartCache; // RO + bool _subtitles; // RO + int _scheduledLoadSlot; bool _loading; - bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); - void setWindowTitle(); + virtual bool handleMouseWheel(int delta); bool _quitting; virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); virtual bool handleKeypress(Common::Event *event, bool printable = false); virtual void handleKeyRelease(Common::Event *event); -protected: - int _freezeLevel; -public: + bool unfreeze(); bool freeze(bool includingMusic = true); bool focusWindow(UIWindow *window); - VideoPlayer *_videoPlayer; - VideoTheoraPlayer *_theoraPlayer; bool _loadInProgress; UIWindow *_focusedWindow; bool _editorForceScripts; -protected: - static void afterLoadRegion(void *region, void *data); - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); -public: + static void invalidateValues(void *value, void *data); bool loadSettings(const char *filename); - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - BaseSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; + bool displayWindows(bool inGame = false); BaseRegistry *_registry; bool _useD3D; @@ -298,10 +212,9 @@ public: virtual bool loadGame(const char *filename); virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - - BaseSprite *_cursorNoninteractive; + BaseObject *_activeObject; - BaseKeyboardState *_keyboardState; + bool _interactive; TGameState _state; TGameState _origState; @@ -322,14 +235,7 @@ public: void quickMessage(const char *text); void quickMessageForm(char *fmt, ...); bool displayQuickMsg(); - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - BaseArray _regObjects; -public: virtual bool displayContent(bool update = true, bool displayAll = false); virtual bool displayContentSimple(); bool _forceNonStreamedSounds; @@ -350,13 +256,114 @@ public: BaseSaveThumbHelper *_cachedThumbnail; AnsiString getDataDir(); void addMem(int bytes); - bool _touchInterface; bool _constrainedMemory; - AnsiString getDeviceType() const; +protected: + BaseSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + BaseFader *_fader; + + bool _indicatorDisplay; + bool displayIndicator(); + + int _freezeLevel; + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; + static void afterLoadRegion(void *region, void *data); private: + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); + + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + + char *_localSaveDir; + bool _saveDirChecked; + bool _richSavedGames; + char *_savedGameExt; + + char *_loadImageName; + char *_saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + + BaseSurface *_saveLoadImage; + + bool _reportTextureFormat; + + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + + bool _videoSubtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + + bool _personalizedSave; + + bool emptySaveSlot(int slot); + bool isSaveSlotUsed(int slot); + bool getSaveSlotDescription(int slot, char *buffer); + bool getSaveSlotFilename(int slot, char *buffer); + void setWindowTitle(); + + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + BaseSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + + BaseSprite *_cursorNoninteractive; + BaseKeyboardState *_keyboardState; + + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + BaseDebugger *_debugMgr; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; + + AnsiString getDeviceType() const; struct LastClickInfo { LastClickInfo() { diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index c05501b145..c1e3172a77 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -44,27 +44,9 @@ class ScValue; class ScStack; class ScScript; class BaseObject : public BaseScriptHolder { -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - uint32 _alphaColor; - float _scale; - float _scaleX; - float _scaleY; - float _relativeScale; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(BaseSound *sound); +protected: bool _autoSoundPanning; uint32 _sFXStart; - int _sFXVolume; bool setSFXTime(uint32 time); bool setSFXVolume(int volume); bool resumeSFX(); @@ -72,12 +54,37 @@ public: bool stopSFX(bool deleteSound = true); bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); BaseSound *_sFX; - TSFXType _sFXType; float _sFXParam1; float _sFXParam2; float _sFXParam3; float _sFXParam4; + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + float _scaleX; + float _scaleY; + float _relativeScale; + bool _editorSelected; + bool _editorAlwaysRegister; + bool _ready; + Rect32 _rect; + bool _rectSet; + int _iD; + char *_soundEvent; +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _scale; + uint32 _alphaColor; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(BaseSound *sound); + int _sFXVolume; virtual bool handleMouseWheel(int delta); virtual bool handleMouse(TMouseEvent event, TMouseButton button); @@ -88,10 +95,10 @@ public: bool cleanup(); const char *getCaption(int caseVal = 1); void setCaption(const char *caption, int caseVal = 1); - bool _editorSelected; - bool _editorAlwaysRegister; + bool _editorOnly; bool _is3D; + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) virtual bool showCursor(); BaseSprite *_cursor; @@ -99,22 +106,18 @@ public: BaseSprite *_activeCursor; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); virtual bool listen(BaseScriptHolder *param1, uint32 param2); - bool _ready; - bool _registrable; + + bool _movable; bool _zoomable; bool _shadowable; - Rect32 _rect; - bool _rectSet; - int _iD; - bool _movable; - BaseObject(BaseGame *inGame); - virtual ~BaseObject(); - char *_caption[7]; - char *_soundEvent; int _posY; int _posX; + bool _registrable; + char *_caption[7]; bool _saveState; + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); // base virtual bool update() { return STATUS_FAILED; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 5f8a2114c1..44d2fc00ba 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -309,7 +309,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { } ////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::initLoad(const char *filename) { +bool BasePersistenceManager::initLoad(const Common::String &filename) { if (DID_FAIL(readHeader(filename))) { cleanup(); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 78d3230c47..cdb29fde6b 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -62,7 +62,7 @@ public: void deleteSaveSlot(int slot); uint32 getMaxUsedSlot(); bool getSaveExists(int slot); - bool initLoad(const char *filename); + bool initLoad(const Common::String &filename); bool initSave(const char *desc); bool getBytes(byte *buffer, uint32 size); bool putBytes(byte *buffer, uint32 size); diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index ef2615a668..d0d0757fbf 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -42,6 +42,7 @@ public: bool storeThumbnail(bool doFlip = false); BaseImage *_thumbnail; +private: BaseImage *_richThumbnail; }; diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 7ac79d4745..e528244438 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -102,9 +102,7 @@ char *BaseStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return; - +void BaseStringTable::expand(char **str) { if (str == NULL || *str == NULL || *str[0] != '/') return; char *value = strchr(*str + 1, '/'); @@ -132,14 +130,12 @@ void BaseStringTable::expand(char **str, bool forceExpand) { delete [] *str; *str = new_str; - if (strlen(*str) > 0 && *str[0] == '/') expand(str, forceExpand); + if (strlen(*str) > 0 && *str[0] == '/') expand(str); } ////////////////////////////////////////////////////////////////////////// -const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) { - if (_gameRef->_doNotExpandStrings && !forceExpand) return string; - +const char *BaseStringTable::expandStatic(const char *string) { if (string == NULL || string[0] == '\0' || string[0] != '/') return string; const char *value = strchr(string + 1, '/'); @@ -163,7 +159,7 @@ const char *BaseStringTable::expandStatic(const char *string, bool forceExpand) delete [] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str, forceExpand); + if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str); else return new_str; } diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index ac46aaee43..e8dee0c42d 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -37,9 +37,9 @@ namespace WinterMute { class BaseStringTable : public BaseClass { public: - const char *expandStatic(const char *string, bool forceExpand = false); + const char *expandStatic(const char *string); bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str, bool forceExpand = false); + void expand(char **str); bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); virtual ~BaseStringTable(); diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a6d56f281e..899265a2fb 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -68,18 +68,14 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename); delete [] tempFilename; - char slotFilename[MAX_PATH_LENGTH + 1]; - _gameRef->getSaveSlotFilename(slot, slotFilename); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + Common::String slotFilename = pm->getFilenameForSlot(slot); if (!pm) return STATUS_FAILED; - _gameRef->_debugAbsolutePathWarning = false; if (DID_FAIL(pm->initLoad(slotFilename))) { - _gameRef->_debugAbsolutePathWarning = true; delete pm; return STATUS_FAILED; } - _gameRef->_debugAbsolutePathWarning = true; bool res; diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 8a4f5af570..79806be95f 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -47,7 +47,7 @@ public: BaseFontBitmap(BaseGame *inGame); virtual ~BaseFontBitmap(); - +private: bool getWidths(); BaseSprite *_sprite; int _widthsFrame; @@ -59,7 +59,6 @@ public: BaseSubFrame *_subframe; bool _wholeCell; -private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 32dced0878..84da8bd7f8 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -104,21 +104,23 @@ public: return STATUS_OK; }; bool pointInViewport(Point32 *P); - uint32 _forceAlphaColor; - uint32 _window; - uint32 _clipperWindow; bool _active; bool _ready; bool _windowed; - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; int _bPP; int _height; int _width; - + uint32 _window; + uint32 _forceAlphaColor; + void addRectToList(BaseActiveRect *rect); +protected: + uint32 _clipperWindow; + + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; private: Common::Array _rectList; }; diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 9a72cbb236..cb98bde722 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -39,15 +39,9 @@ class BaseSurface: public BaseClass { public: virtual bool invalidate(); virtual bool prepareToDraw(); - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - uint32 _lastUsedTime; bool _valid; int _lifeTime; - bool _keepLoaded; bool _pixelOpReady; BaseSurface(BaseGame *inGame); @@ -88,6 +82,12 @@ public: //void SetWidth(int Width){ _width = Width; } //void SetHeight(int Height){ _height = Height; } protected: + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + bool _keepLoaded; Common::String _filename; int _height; int _width; diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 6575544db0..198e415cc4 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -43,88 +43,89 @@ public: PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); virtual ~PartEmitter(void); + int _fadeOutTime; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(BaseRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const char *name); + + BaseArray _forces; + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: int _width; int _height; - + int _angle1; int _angle2; - + float _rotation1; float _rotation2; - + float _angVelocity1; float _angVelocity2; - + float _growthRate1; float _growthRate2; bool _exponentialGrowth; - + float _velocity1; float _velocity2; bool _velocityZBased; - + float _scale1; float _scale2; bool _scaleZBased; - + int _maxParticles; - + int _lifeTime1; int _lifeTime2; bool _lifeTimeZBased; - + int _genInterval; int _genAmount; - + bool _running; int _overheadTime; - + int _maxBatches; int _batchesGenerated; - + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; int _borderThicknessBottom; - + int _fadeInTime; - int _fadeOutTime; - + int _alpha1; int _alpha2; bool _alphaTimeBased; - + bool _useRegion; - + char *_emitEvent; BaseScriptHolder *_owner; - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(BaseRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); - - BaseArray _forces; - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: PartForce *addForceByName(const char *name); int static compareZ(const void *obj1, const void *obj2); bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 3bb4bc48a7..ba73e1015f 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -55,9 +55,10 @@ public: bool copyParameters(ScStack *stack); void afterLoad(); - +private: ScValue *_operand; ScValue *_reg1; +public: bool _freezable; bool resume(); bool pause(); @@ -145,6 +146,13 @@ public: ScScript(BaseGame *inGame, ScEngine *Engine); virtual ~ScScript(); char *_filename; + bool _thread; + bool _methodThread; + char *_threadEvent; + BaseScriptHolder *_owner; + ScScript::TExternalFunction *getExternal(char *name); + bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); +private: char **_symbols; uint32 _numSymbols; TFunctionPos *_functions; @@ -155,13 +163,7 @@ public: uint32 _numFunctions; uint32 _numMethods; uint32 _numEvents; - bool _thread; - bool _methodThread; - char *_threadEvent; - BaseScriptHolder *_owner; - ScScript::TExternalFunction *getExternal(char *name); - bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); -private: + bool initScript(); bool initTables(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 3f8d703f85..8eb86c4e69 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -45,6 +45,7 @@ public: bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); +private: int _length; ScValue *_values; }; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index b2df4abe94..69fe1f1ae5 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -44,9 +44,9 @@ public: bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); +private: char *_string; TimeDate _tm; -private: Common::String _strRep; }; diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index c325181e3f..b5428b4bd9 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -46,8 +46,9 @@ public: SXMemBuffer(BaseGame *inGame, void *buffer); virtual ~SXMemBuffer(); virtual void *scToMemBuffer(); - int _size; private: + int _size; + bool resize(int newSize); void *_buffer; void cleanup(); diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index d744c58042..f7d3a7bc0f 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -39,7 +39,6 @@ public: DECLARE_PERSISTENT(SXObject, BaseObject) SXObject(BaseGame *inGame, ScStack *Stack); virtual ~SXObject(); - }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 7a684d2334..069c36bd47 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -88,7 +88,7 @@ public: ScValue *getProp(const char *name); BaseScriptable *_valNative; ScValue *_valRef; -protected: +private: bool _valBool; int _valInt; double _valFloat; diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 9c85a02b39..c32f83eb1e 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -48,7 +48,6 @@ public: BaseSoundBuffer(BaseGame *inGame); virtual ~BaseSoundBuffer(); - bool pause(); bool play(bool looping = false, uint32 startSample = 0); bool resume(); @@ -86,12 +85,12 @@ public: uint32 _loopStart; Audio::Mixer::SoundType _type; bool _looping; - Common::SeekableReadStream *_file; - char *_filename; - bool _streamed; int _privateVolume; private: + char *_filename; + bool _streamed; + Common::SeekableReadStream *_file; int _volume; }; -- cgit v1.2.3 From 46968e20f944810cb3b9bce1fdf5f61a7f1de0bb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 18:38:13 +0200 Subject: WINTERMUTE: Cleanup in BasePackage. --- engines/wintermute/base/file/base_package.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 6987cad3e6..90bb027042 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -138,8 +138,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk _packages.push_back(pkg); - - + // read file entries uint32 numFiles = stream->readUint32LE(); @@ -158,10 +157,6 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - warning( "Package contains %s", name); - // some old version of ProjectMan writes invalid directory entries - // so at least prevent strupr from corrupting memory - name[nameLength - 1] = '\0'; Common::String upcName = name; upcName.toUppercase(); @@ -178,7 +173,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool timeDate1 = stream->readUint32LE(); timeDate2 = stream->readUint32LE(); } - _filesIter = _files.find(upcName.c_str()); + _filesIter = _files.find(upcName); if (_filesIter == _files.end()) { BaseFileEntry *fileEntry = new BaseFileEntry(); fileEntry->_package = pkg; @@ -187,7 +182,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool fileEntry->_compressedLength = compLength; fileEntry->_flags = flags; - _files[upcName.c_str()] = Common::ArchiveMemberPtr(fileEntry); + _files[upcName] = Common::ArchiveMemberPtr(fileEntry); } else { // current package has higher priority than the registered // TODO: This cast might be a bit ugly. -- cgit v1.2.3 From 6331bea4231b5db86d01a8f21b5ff84e4b96d8f6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 18:59:26 +0200 Subject: WINTERMUTE: Remove in-engine fullscreen-switching, let ScummVM handle that. --- engines/wintermute/base/base_game.cpp | 7 ------- engines/wintermute/base/gfx/base_renderer.cpp | 7 ------- engines/wintermute/base/gfx/base_renderer.h | 1 - engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 12 ------------ engines/wintermute/base/gfx/osystem/base_render_osystem.h | 2 -- 5 files changed, 29 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index fcf45f18f2..622c23595b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3701,13 +3701,6 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { return true; } - if (event->type == Common::EVENT_KEYDOWN && event->kbd.keycode == Common::KEYCODE_RETURN && (event->kbd.flags == Common::KBD_ALT)) { - // TODO: Handle alt-enter as well as alt-return. - _renderer->switchFullscreen(); - return true; - } - - _keyboardState->handleKeyPress(event); _keyboardState->readKey(event); // TODO diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index a40b3204a5..ac475b3c5e 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,13 +111,6 @@ void BaseRenderer::deleteRectList() { _rectList.clear(); } - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::switchFullscreen() { - return STATUS_FAILED; -} - ////////////////////////////////////////////////////////////////////// bool BaseRenderer::flip() { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 84da8bd7f8..b67f221e83 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -68,7 +68,6 @@ public: virtual bool initRenderer(int width, int height, bool windowed); virtual bool flip(); virtual void initLoop(); - virtual bool switchFullscreen(); virtual bool setup2D(bool force = false); virtual bool setupLines(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 70d1268e5a..2d2e62076c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -588,18 +588,6 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { return NULL; } -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::switchFullscreen() { - /*if (_windowed) SDL_SetWindowFullscreen(_win, SDL_TRUE); - else SDL_SetWindowFullscreen(_win, SDL_FALSE); - - _windowed = !_windowed; - */ - _gameRef->_registry->writeBool("Video", "Windowed", _windowed); - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// const char *BaseRenderOSystem::getName() { if (_name.empty()) { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 75c745ecf7..3f4185dce2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -71,8 +71,6 @@ public: bool fade(uint16 alpha); bool fadeToColor(uint32 color, Common::Rect *rect = NULL); - bool switchFullscreen(); - bool drawLine(int x1, int y1, int x2, int y2, uint32 color); BaseImage *takeScreenshot(); -- cgit v1.2.3 From 6e55e32a381d1219dfbe8d3c1532d55b28291192 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 20:00:58 +0200 Subject: WINTERMUTE: Cleanup and comment BaseRenderer a bit --- engines/wintermute/base/base_fader.cpp | 5 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/gfx/base_image.cpp | 9 +-- engines/wintermute/base/gfx/base_image.h | 8 +-- engines/wintermute/base/gfx/base_renderer.cpp | 30 ---------- engines/wintermute/base/gfx/base_renderer.h | 70 +++++++++++++++++++--- .../base/gfx/osystem/base_render_osystem.cpp | 34 +++-------- .../base/gfx/osystem/base_render_osystem.h | 9 ++- 8 files changed, 87 insertions(+), 80 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4e7c608482..10818abfb9 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -85,8 +85,9 @@ bool BaseFader::update() { bool BaseFader::display() { if (!_active) return STATUS_OK; - if (_currentAlpha > 0x00) return _gameRef->_renderer->fadeToColor(BYTETORGBA(_red, _green, _blue, _currentAlpha)); - else return STATUS_OK; + if (_currentAlpha > 0x00) + _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 622c23595b..756a28ad7b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4318,7 +4318,7 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); strcat(str, " ("); - strcat(str, _renderer->getName()); + strcat(str, _renderer->getName().c_str()); strcat(str, ")"); _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 2c18b64110..09a78a748b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -92,7 +92,7 @@ bool BaseImage::loadFile(const Common::String &filename) { return true; } -byte BaseImage::getAlphaAt(int x, int y) { +byte BaseImage::getAlphaAt(int x, int y) const { if (!_surface) return 0xFF; uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; @@ -100,19 +100,20 @@ byte BaseImage::getAlphaAt(int x, int y) { return a; } -void BaseImage::copyFrom(Graphics::Surface *surface) { +void BaseImage::copyFrom(const Graphics::Surface *surface) { _surface = _deletableSurface = new Graphics::Surface(); _deletableSurface->copyFrom(*surface); } ////////////////////////////////////////////////////////////////////////// -bool BaseImage::saveBMPFile(const char *filename) { +bool BaseImage::saveBMPFile(const char *filename) const { #if 0 if (!_bitmap) return STATUS_FAILED; if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; else return STATUS_FAILED; #endif + warning("BaseImage::saveBMPFile - stubbed"); // TODO return false; } @@ -138,7 +139,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// -bool BaseImage::writeBMPToStream(Common::WriteStream *stream) { +bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { if (!_surface) return false; /* The following is just copied over and inverted to write-ops from the BMP-decoder */ diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 7f344b5c1c..ed0142ea95 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -52,12 +52,12 @@ public: const byte *getPalette() const { return _palette; } - byte getAlphaAt(int x, int y); - bool writeBMPToStream(Common::WriteStream *stream); + byte getAlphaAt(int x, int y) const; + bool writeBMPToStream(Common::WriteStream *stream) const; bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename); + bool saveBMPFile(const char *filename) const; bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(Graphics::Surface *surface); + void copyFrom(const Graphics::Surface *surface); private: Common::String _filename; Graphics::ImageDecoder *_decoder; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index ac475b3c5e..66b7f513bf 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,12 +111,6 @@ void BaseRenderer::deleteRectList() { _rectList.clear(); } -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::flip() { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////// bool BaseRenderer::initRenderer(int width, int height, bool windowed) { return STATUS_FAILED; @@ -128,12 +122,6 @@ void BaseRenderer::onWindowChange() { } -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fill(byte r, byte g, byte b, Common::Rect *rect) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::windowedBlt() { return STATUS_FAILED; @@ -170,18 +158,6 @@ bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int wi } -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fade(uint16 alpha) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::fadeToColor(uint32 color, Common::Rect *rect) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { return STATUS_FAILED; @@ -203,12 +179,6 @@ bool BaseRenderer::setViewport(Rect32 *rect) { } -////////////////////////////////////////////////////////////////////////// -BaseImage *BaseRenderer::takeScreenshot() { - return NULL; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::clipCursor() { /* diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index b67f221e83..90a1e378ca 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -40,6 +40,12 @@ class BaseImage; class BaseActiveRect; class BaseObject; class BaseSurface; + +/** + * @class BaseRenderer a common interface for the rendering portion of WME + * this interface is mainly intended to wrap away any differencies between + * software-rendering/hardware-rendering. + */ class BaseRenderer: public BaseClass { public: int _realWidth; @@ -48,12 +54,34 @@ public: int _drawOffsetY; virtual void dumpData(const char *filename) {}; - virtual BaseImage *takeScreenshot(); + /** + * Take a screenshot of the current screenstate + * + * @return a BaseImage containing the current screen-buffer. + */ + virtual BaseImage *takeScreenshot() = 0; virtual bool setViewport(int left, int top, int right, int bottom); - virtual bool setViewport(Rect32 *Rect); + virtual bool setViewport(Rect32 *rect); virtual bool setScreenViewport(); - virtual bool fade(uint16 Alpha); - virtual bool fadeToColor(uint32 Color, Common::Rect *rect = NULL); + + virtual Graphics::PixelFormat getPixelFormat() const = 0; + /** + * Fade the screen to black + * + * @param alpha amount to fade by (alpha value of black) + * @return + */ + virtual void fade(uint16 alpha) = 0; + /** + * Fade a portion of the screen to a specific color + * + * @param r the red component to fade too. + * @param g the green component to fade too. + * @param b the blue component to fade too. + * @param a the alpha component to fade too. + * @param rect the portion of the screen to fade (if NULL, the entire screen will be faded). + */ + virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL) = 0; virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); BaseRenderer(BaseGame *inGame = NULL); @@ -63,17 +91,33 @@ public: }; virtual bool windowedBlt(); - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + /** + * Fill a portion of the screen with a specified color + * + * @param r the red component to fill with. + * @param g the green component to fill with. + * @param b the blue component to fill with. + */ + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL) = 0; virtual void onWindowChange(); virtual bool initRenderer(int width, int height, bool windowed); - virtual bool flip(); + /** + * Flip the backbuffer onto the screen-buffer + * The screen will NOT be updated before calling this function. + * + * @return true if successfull, false on error. + */ + virtual bool flip() = 0; virtual void initLoop(); virtual bool setup2D(bool force = false); virtual bool setupLines(); - virtual const char *getName() { - return ""; - }; + /** + * Get the name of the current renderer + * + * @return the name of the renderer. + */ + virtual Common::String getName() const = 0; virtual bool displayDebugInfo() { return STATUS_FAILED; }; @@ -88,6 +132,14 @@ public: return 1.0f; } + /** + * Create a Surface fit for use with the renderer. + * As diverse implementations of BaseRenderer might have different solutions for storing surfaces + * this allows for a common interface for creating surface-handles. (Mostly usefull to ease future + * implementation of hw-accelerated rendering, or readding 3D-support at some point). + * + * @return a surface that can be used with this renderer + */ virtual BaseSurface *createSurface() = 0; bool clipCursor(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 2d2e62076c..09ee62c3b8 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -284,14 +284,14 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { } ////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::fade(uint16 Alpha) { - uint32 dwAlpha = 255 - Alpha; - return fadeToColor(dwAlpha << 24); +void BaseRenderOSystem::fade(uint16 alpha) { + byte dwAlpha = (byte)(255 - alpha); + return fadeToColor(0, 0, 0, dwAlpha); } ////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { +void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. static bool hasWarned = false; @@ -318,11 +318,6 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { } modTargetRect(&fillRect); - byte r = RGBCOLGetR(Color); - byte g = RGBCOLGetG(Color); - byte b = RGBCOLGetB(Color); - byte a = RGBCOLGetA(Color); - //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); if (_disableDirtyRects) @@ -342,8 +337,10 @@ bool BaseRenderOSystem::fadeToColor(uint32 Color, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); +} - return STATUS_OK; +Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { + return _renderSurface->format; } void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { @@ -589,17 +586,8 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { } ////////////////////////////////////////////////////////////////////////// -const char *BaseRenderOSystem::getName() { - if (_name.empty()) { -#if 0 - if (_renderer) { - SDL_RendererInfo info; - SDL_GetRendererInfo(_renderer, &info); - _name = AnsiString(info.name); - } -#endif - } - return _name.c_str(); +Common::String BaseRenderOSystem::getName() const { + return "ScummVM-OSystem-renderer"; } ////////////////////////////////////////////////////////////////////////// @@ -611,10 +599,6 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { rect.right = (int16)((right - left) * _ratioX); rect.bottom = (int16)((bottom - top) * _ratioY); - // TODO fix this once viewports work correctly in SDL/landscape -#ifndef __IPHONEOS__ - //SDL_RenderSetViewport(GetSdlRenderer(), &rect); -#endif return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 3f4185dce2..b7507098da 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -62,14 +62,14 @@ public: BaseRenderOSystem(BaseGame *inGame); ~BaseRenderOSystem(); - const char *getName(); + Common::String getName() const; bool initRenderer(int width, int height, bool windowed); bool flip(); bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - - bool fade(uint16 alpha); - bool fadeToColor(uint32 color, Common::Rect *rect = NULL); + Graphics::PixelFormat getPixelFormat() const; + void fade(uint16 alpha); + void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL); bool drawLine(int x1, int y1, int x2, int y2, uint32 color); @@ -109,7 +109,6 @@ private: uint32 _drawNum; Common::Rect _renderRect; Graphics::Surface *_renderSurface; - AnsiString _name; int _borderLeft; int _borderTop; -- cgit v1.2.3 From f2379252f46187cfc4030765282374e5f086675f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:00:57 +0200 Subject: WINTERMUTE: Reformat and constify BaseStringTable --- engines/wintermute/base/base_string_table.cpp | 128 ++++++++++++++------------ engines/wintermute/base/base_string_table.h | 10 +- 2 files changed, 76 insertions(+), 62 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index e528244438..58cf046436 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -51,7 +51,8 @@ BaseStringTable::~BaseStringTable() { ////////////////////////////////////////////////////////////////////////// bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) return STATUS_FAILED; + if (key == NULL || val == NULL) + return STATUS_FAILED; if (scumm_stricmp(key, "@right-to-left") == 0) { _gameRef->_textRTL = true; @@ -61,8 +62,9 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup Common::String finalKey = key; finalKey.toLowercase(); - _stringsIter = _strings.find(finalKey); - if (_stringsIter != _strings.end() && reportDuplicities) _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + StringsIter it = _strings.find(finalKey); + if (it != _strings.end() && reportDuplicities) + _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); _strings[finalKey] = val; @@ -70,30 +72,32 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup } ////////////////////////////////////////////////////////////////////////// -char *BaseStringTable::getKey(const char *str) { - if (str == NULL || str[0] != '/') return NULL; +char *BaseStringTable::getKey(const char *str) const { + if (str == NULL || str[0] != '/') + return NULL; const char *value = strchr(str + 1, '/'); - if (value == NULL) return NULL; + if (value == NULL) + return NULL; char *key = new char[value - str]; - strncpy(key, str + 1, value - str - 1); - key[value - str - 1] = '\0'; + Common::strlcpy(key, str + 1, (size_t)(value - str)); + BasePlatform::strlwr(key); - char *new_str; - - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); - if (strlen(new_str) > 0 && new_str[0] == '/' && strchr(new_str + 1, '/')) { - delete [] key; - char *Ret = getKey(new_str); - delete [] new_str; - return Ret; + char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); + if (strlen(newStr) > 0 && newStr[0] == '/' && strchr(newStr + 1, '/')) { + delete[] key; + char *ret = getKey(newStr); + delete[] newStr; + return ret; } else { - delete [] new_str; + delete[] newStr; return key; } } else { @@ -102,65 +106,71 @@ char *BaseStringTable::getKey(const char *str) { } ////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str) { - if (str == NULL || *str == NULL || *str[0] != '/') return; +void BaseStringTable::expand(char **str) const { + if (str == NULL || *str == NULL || *str[0] != '/') + return; char *value = strchr(*str + 1, '/'); - if (value == NULL) return; + if (value == NULL) + return; char *key = new char[value - *str]; - strncpy(key, *str + 1, value - *str - 1); - key[value - *str - 1] = '\0'; + Common::strlcpy(key, *str + 1, (size_t)(value - *str)); + BasePlatform::strlwr(key); value++; - char *new_str; + char *newStr; - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = new char[_stringsIter->_value.size() + 1]; - strcpy(new_str, _stringsIter->_value.c_str()); + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); } else { - new_str = new char[strlen(value) + 1]; - strcpy(new_str, value); + newStr = new char[strlen(value) + 1]; + strcpy(newStr, value); } - delete [] key; - delete [] *str; - *str = new_str; + delete[] key; + delete[] *str; + *str = newStr; - if (strlen(*str) > 0 && *str[0] == '/') expand(str); + if (strlen(*str) > 0 && *str[0] == '/') + expand(str); } ////////////////////////////////////////////////////////////////////////// -const char *BaseStringTable::expandStatic(const char *string) { - if (string == NULL || string[0] == '\0' || string[0] != '/') return string; +const char *BaseStringTable::expandStatic(const char *string) const { + if (string == NULL || string[0] == '\0' || string[0] != '/') + return string; const char *value = strchr(string + 1, '/'); - if (value == NULL) return string; + if (value == NULL) + return string; char *key = new char[value - string]; - strncpy(key, string + 1, value - string - 1); - key[value - string - 1] = '\0'; + Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); BasePlatform::strlwr(key); value++; - const char *new_str; + const char *newStr; - _stringsIter = _strings.find(key); - if (_stringsIter != _strings.end()) { - new_str = _stringsIter->_value.c_str(); + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = it->_value.c_str(); } else { - new_str = value; + newStr = value; } - delete [] key; + delete[] key; - if (strlen(new_str) > 0 && new_str[0] == '/') return expandStatic(new_str); - else return new_str; + if (strlen(newStr) > 0 && newStr[0] == '/') + return expandStatic(newStr); + else + return newStr; } @@ -168,7 +178,8 @@ const char *BaseStringTable::expandStatic(const char *string) { bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); - if (clearOld) _strings.clear(); + if (clearOld) + _strings.clear(); uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); @@ -191,12 +202,12 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { uint32 lineLength = 0; while (pos < size) { lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') lineLength++; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') + lineLength++; uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); char *line = new char[realLength + 1]; - strncpy(line, (char *)&buffer[pos], realLength); - line[realLength] = '\0'; + Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); char *value = strchr(line, '\t'); if (value == NULL) value = strchr(line, ' '); @@ -205,17 +216,20 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { value[0] = '\0'; value++; for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') value[i] = '\n'; + if (value[i] == '|') + value[i] = '\n'; } addString(line, value, clearOld); - } else if (line[0] != '\0') addString(line, "", clearOld); + } else if (line[0] != '\0') { + addString(line, "", clearOld); + } } - delete [] line; + delete[] line; pos += lineLength + 1; } - delete [] buffer; + delete[] buffer; _gameRef->LOG(0, " %d strings loaded", _strings.size()); diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index e8dee0c42d..1bc9047f7f 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -37,16 +37,16 @@ namespace WinterMute { class BaseStringTable : public BaseClass { public: - const char *expandStatic(const char *string); bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str); + void expand(char **str) const; + const char *expandStatic(const char *string) const; bool addString(const char *key, const char *val, bool reportDuplicities = true); BaseStringTable(BaseGame *inGame); virtual ~BaseStringTable(); - Common::HashMap _strings; - char *getKey(const char *str); + char *getKey(const char *str) const; private: - Common::HashMap::iterator _stringsIter; + Common::HashMap _strings; + typedef Common::HashMap::const_iterator StringsIter; }; -- cgit v1.2.3 From fa96c9ea187cdb26e9f1ce048c9132f723e25df1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:05:03 +0200 Subject: WINTERMUTE: "delete []" -> "delete[]" --- engines/wintermute/base/base_file_manager.cpp | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 10 +++++----- engines/wintermute/base/base_parser.cpp | 2 +- .../wintermute/base/base_persistence_manager.cpp | 4 ++-- engines/wintermute/base/base_quick_msg.cpp | 2 +- engines/wintermute/base/base_region.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 6 +++--- .../wintermute/base/file/base_save_thumb_file.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/scriptables/script.cpp | 22 +++++++++++----------- .../wintermute/base/scriptables/script_engine.cpp | 6 +++--- .../wintermute/base/scriptables/script_engine.h | 2 +- .../base/scriptables/script_ext_file.cpp | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 2 +- .../base/scriptables/script_ext_string.cpp | 2 +- .../wintermute/base/scriptables/script_value.cpp | 6 +++--- 22 files changed, 45 insertions(+), 45 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 156aff61fe..b25bbf024d 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -101,7 +101,7 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); - delete [] buffer; + delete[] buffer; return NULL; }; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 8278c48299..77e959f11b 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -552,7 +552,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac const char *event = stack->pop()->getString(); for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete [] _applyEvent[i]; + delete[] _applyEvent[i]; _applyEvent.removeAt(i); break; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 756a28ad7b..b11915afc7 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -682,7 +682,7 @@ bool BaseGame::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } @@ -1088,7 +1088,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack strcpy(str, val->getString()); _stringTable->expand(&str); stack->pushString(str); - delete [] str; + delete[] str; return STATUS_OK; } @@ -1518,7 +1518,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pop(); stack->pushBool(false); } - delete [] desc; + delete[] desc; return STATUS_OK; } @@ -3098,7 +3098,7 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack char *str2 = new char[strlen(str) + 1]; strcpy(str2, str); stack->pushString(str2); - delete [] str2; + delete[] str2; } ////////////////////////////////////////////////////////////////////////// @@ -3536,7 +3536,7 @@ bool BaseGame::loadSettings(const char *filename) { _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; - delete [] origBuffer; + delete[] origBuffer; return ret; } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index b7a221daf5..588d210134 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -50,7 +50,7 @@ BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseParser::~BaseParser() { - if (_whiteSpace != NULL) delete [] _whiteSpace; + if (_whiteSpace != NULL) delete[] _whiteSpace; } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 44d2fc00ba..3f9e8de855 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -91,7 +91,7 @@ BasePersistenceManager::~BasePersistenceManager() { void BasePersistenceManager::cleanup() { /* if (_buffer) { if (_saving) free(_buffer); - else delete [] _buffer; // allocated by file manager + else delete[] _buffer; // allocated by file manager } _buffer = NULL; @@ -110,7 +110,7 @@ void BasePersistenceManager::cleanup() { _thumbnailDataSize = 0; if (_thumbnailData) { - delete [] _thumbnailData; + delete[] _thumbnailData; _thumbnailData = NULL; } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index 6e435b3ee0..d672e39c6b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -41,7 +41,7 @@ BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::~BaseQuickMsg() { - if (_text) delete [] _text; + if (_text) delete[] _text; } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 22b5a99937..f88de2ab91 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -108,7 +108,7 @@ bool BaseRegion::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 62ed4f67f2..d274f9df73 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -72,7 +72,7 @@ bool BaseScriptHolder::cleanup() { ////////////////////////////////////////////////////////////////////// void BaseScriptHolder::setFilename(const char *filename) { if (_filename != NULL) { - delete [] _filename; + delete[] _filename; _filename = NULL; } if (filename == NULL) diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 86dbefdd70..3514504824 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -155,7 +155,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); - delete [] buffer; + delete[] buffer; } } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 35546b0001..1598101036 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -150,7 +150,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { byte *data = new byte[uncompSize]; if (!data) { error("Error allocating buffer for file '%s'", filename.c_str()); - delete [] compBuffer; + delete[] compBuffer; delete file; return NULL; } @@ -159,12 +159,12 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { error("Error uncompressing file '%s'", filename.c_str()); - delete [] compBuffer; + delete[] compBuffer; delete file; return NULL; } - delete [] compBuffer; + delete[] compBuffer; return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); delete file; diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 899265a2fb..0a0d0cac09 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -66,7 +66,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { // get slot number from name int slot = atoi(tempFilename); - delete [] tempFilename; + delete[] tempFilename; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String slotFilename = pm->getFilenameForSlot(slot); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index e9d245782a..7bffbc35c8 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -85,7 +85,7 @@ bool BaseFont::loadFile(const char * Filename) if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - delete [] Buffer; + delete[] Buffer; return ret; } @@ -198,7 +198,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) ret = true; - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 2e752d4f2e..dd6c6da327 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -255,7 +255,7 @@ bool BaseFontBitmap::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index c371177bac..dd5d006556 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -419,7 +419,7 @@ bool BaseFontTT::loadFile(const char *filename) { if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 6bfff0799e..1ddefec610 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -106,7 +106,7 @@ PartEmitter::~PartEmitter(void) { for (int i = 0; i < _sprites.getSize(); i++) { - delete [] _sprites[i]; + delete[] _sprites[i]; } _sprites.removeAll(); @@ -141,7 +141,7 @@ bool PartEmitter::addSprite(const char *filename) { bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete [] _sprites[i]; + delete[] _sprites[i]; _sprites.removeAt(i); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 52490c0710..57e08135ed 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -360,13 +360,13 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { ////////////////////////////////////////////////////////////////////////// void ScScript::cleanup() { - if (_buffer) delete [] _buffer; + if (_buffer) delete[] _buffer; _buffer = NULL; - if (_filename) delete [] _filename; + if (_filename) delete[] _filename; _filename = NULL; - if (_symbols) delete [] _symbols; + if (_symbols) delete[] _symbols; _symbols = NULL; _numSymbols = 0; @@ -385,24 +385,24 @@ void ScScript::cleanup() { delete _stack; _stack = NULL; - if (_functions) delete [] _functions; + if (_functions) delete[] _functions; _functions = NULL; _numFunctions = 0; - if (_methods) delete [] _methods; + if (_methods) delete[] _methods; _methods = NULL; _numMethods = 0; - if (_events) delete [] _events; + if (_events) delete[] _events; _events = NULL; _numEvents = 0; if (_externals) { for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete [] _externals[i].params; + if (_externals[i].nu_params > 0) delete[] _externals[i].params; } - delete [] _externals; + delete[] _externals; } _externals = NULL; _numExternals = 0; @@ -586,7 +586,7 @@ bool ScScript::executeInstruction() { runtimeError("Cannot call method '%s'. Ignored.", MethodName); _stack->pushNULL(); } - delete [] MethodName; + delete[] MethodName; break; } /* @@ -621,7 +621,7 @@ bool ScScript::executeInstruction() { } } } - delete [] MethodName; + delete[] MethodName; } break; @@ -797,7 +797,7 @@ bool ScScript::executeInstruction() { strcpy(tempStr, op1->getString()); strcat(tempStr, op2->getString()); _operand->setString(tempStr); - delete [] tempStr; + delete[] tempStr; } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) _operand->setInt(op1->getInt() + op2->getInt()); else _operand->setFloat(op1->getFloat() + op2->getFloat()); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 59ec113d1f..c33d844aa1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -127,7 +127,7 @@ byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { ////////////////////////////////////////////////////////////////////////// void ScEngine::closeFile(void *data, byte *buffer) { - delete [] buffer; + delete[] buffer; } @@ -201,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig } else { if (!_compilerAvailable) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete [] buffer; + delete[] buffer; return NULL; } // This code will never be called, since _compilerAvailable is const false. @@ -235,7 +235,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig // cleanup - delete [] buffer; + delete[] buffer; return ret; } diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 3d85192aa6..e443ec5832 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -54,7 +54,7 @@ public: }; ~CScCachedScript() { - if (_buffer) delete [] _buffer; + if (_buffer) delete[] _buffer; }; uint32 _timestamp; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 92943f7485..01179bb3ad 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -457,7 +457,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, str[size] = '\0'; stack->pushString((char *)str); } - delete [] str; + delete[] str; } else stack->pushNULL(); } else stack->pushNULL(); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index b625fad400..6b791871ad 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -249,7 +249,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt strncpy(str, (const char *)_buffer + start, length); str[length] = '\0'; stack->pushString(str); - delete [] str; + delete[] str; } return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 5e01e5e29c..385d7ca746 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -67,7 +67,7 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { ////////////////////////////////////////////////////////////////////////// SXString::~SXString() { - if (_string) delete [] _string; + if (_string) delete[] _string; } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 6d12c34914..59e0965f5e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -122,7 +122,7 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { void ScValue::cleanup(bool ignoreNatives) { deleteProps(); - if (_valString) delete [] _valString; + if (_valString) delete[] _valString; if (!ignoreNatives) { if (_valNative && !_persistent) { @@ -425,7 +425,7 @@ void ScValue::setString(const Common::String &val) { ////////////////////////////////////////////////////////////////////////// void ScValue::setStringVal(const char *val) { if (_valString) { - delete [] _valString; + delete[] _valString; _valString = NULL; } @@ -767,7 +767,7 @@ bool ScValue::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer("", &val); _valObject[str] = val; - delete [] str; + delete[] str; } } -- cgit v1.2.3 From 1ad859a468415cc7fd93adaa84beba02aae29ad8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 25 Jul 2012 21:21:55 +0200 Subject: WINTERMUTE: "if(" -> "if (" --- engines/wintermute/base/base_game.cpp | 4 +-- engines/wintermute/base/base_keyboard_state.cpp | 2 +- engines/wintermute/base/base_scriptable.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 4 +-- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 6 ++-- engines/wintermute/base/scriptables/script.cpp | 36 +++++++++++----------- .../wintermute/base/scriptables/script_engine.cpp | 6 ++-- .../base/scriptables/script_ext_date.cpp | 2 +- .../base/scriptables/script_ext_file.cpp | 4 +-- .../base/scriptables/script_ext_mem_buffer.cpp | 4 +-- .../wintermute/base/scriptables/script_value.cpp | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 16 +++++----- 14 files changed, 46 insertions(+), 46 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b11915afc7..63040f2db2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3242,7 +3242,7 @@ bool BaseGame::loadGame(const char *filename) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; - //if(DID_FAIL(ret = cleanup())) goto load_finish; + //if (DID_FAIL(ret = cleanup())) goto load_finish; if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; @@ -3873,7 +3873,7 @@ bool BaseGame::setActiveObject(BaseObject *obj) { if (obj == _activeObject) return STATUS_OK; if (_activeObject) _activeObject->applyEvent("MouseLeave"); - //if(ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); _activeObject = obj; if (_activeObject) { _activeObject->applyEvent("MouseEntry"); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index db0f1db94d..a85ec3e972 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -215,7 +215,7 @@ bool BaseKeyboardState::readKey(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if(!persistMgr->getIsSaving()) cleanup(); + //if (!persistMgr->getIsSaving()) cleanup(); BaseScriptable::persist(persistMgr); persistMgr->transfer(TMEMBER(_currentAlt)); diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 40aa2871b5..4059abde3d 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -49,7 +49,7 @@ BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) ////////////////////////////////////////////////////////////////////////// BaseScriptable::~BaseScriptable() { - //if(_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + //if (_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); delete _scValue; delete _scProp; _scValue = NULL; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 3514504824..03b0ef3615 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -329,7 +329,7 @@ void BaseSprite::reset() { ////////////////////////////////////////////////////////////////////// bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { - //if(_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) return false; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 2ac011917c..0b87dd2b7a 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -189,7 +189,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); /* - if(_surface == NULL) + if (_surface == NULL) { _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); return STATUS_FAILED; @@ -217,7 +217,7 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl bool res; - //if(Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) if (_alpha != 0xFFFFFFFF) alpha = _alpha; if (rotate != 0.0f) { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0dd10f6bdc..d8ba0cbbce 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -147,7 +147,7 @@ bool BaseSurfaceStorage::restoreAll() { bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) { - if(!persistMgr->getIsSaving()) cleanup(false); + if (!persistMgr->getIsSaving()) cleanup(false); persistMgr->transfer(TMEMBER(_gameRef)); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 7bffbc35c8..d576b834a2 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -73,7 +73,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { bool BaseFont::loadFile(const char * Filename) { BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); - if(Buffer==NULL){ + if (Buffer==NULL){ _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; } @@ -83,7 +83,7 @@ bool BaseFont::loadFile(const char * Filename) _filename = new char [strlen(filename)+1]; strcpy(_filename, filename); - if(DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); delete[] Buffer; @@ -105,7 +105,7 @@ bool BaseFont::loadBuffer(byte * Buffer) int cmd; BaseParser parser(_gameRef); - if(parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ + if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); return STATUS_FAILED; } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 57e08135ed..a519da5832 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -591,11 +591,11 @@ bool ScScript::executeInstruction() { } /* ScValue* val = var->getProp(MethodName); - if(val){ + if (val){ dw = GetFuncPos(val->getString()); - if(dw==0){ + if (dw==0){ TExternalFunction* f = GetExternal(val->getString()); - if(f){ + if (f){ ExternalCall(_stack, _thisStack, f); } else{ @@ -776,7 +776,7 @@ bool ScScript::executeInstruction() { case II_JMP_FALSE: { dw = getDWORD(); - //if(!_stack->pop()->getBool()) _iP = dw; + //if (!_stack->pop()->getBool()) _iP = dw; ScValue *val = _stack->pop(); if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); @@ -864,7 +864,7 @@ bool ScScript::executeInstruction() { case II_NOT: op1 = _stack->pop(); - //if(op1->isNULL()) _operand->setNULL(); + //if (op1->isNULL()) _operand->setNULL(); if (op1->isNULL()) _operand->setBool(true); else _operand->setBool(!op1->getBool()); _stack->push(_operand); @@ -900,14 +900,14 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if(op1->isNative() && op2->isNative()){ + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if (op1->isNative() && op2->isNative()){ _operand->setBool(op1->getNative() == op2->getNative()); } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() == op2->getFloat()); } else{ @@ -924,14 +924,14 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if(op1->isNative() && op2->isNative()){ + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if (op1->isNative() && op2->isNative()){ _operand->setBool(op1->getNative() != op2->getNative()); } - else if(op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); } - else if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() != op2->getFloat()); } else{ @@ -948,7 +948,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() < op2->getFloat()); } else _operand->setBool(op1->getInt() < op2->getInt()); @@ -963,7 +963,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() > op2->getFloat()); } else _operand->setBool(op1->getInt() > op2->getInt()); @@ -978,7 +978,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() <= op2->getFloat()); } else _operand->setBool(op1->getInt() <= op2->getInt()); @@ -993,7 +993,7 @@ bool ScScript::executeInstruction() { op1 = _stack->pop(); /* - if(op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ _operand->setBool(op1->getFloat() >= op2->getFloat()); } else _operand->setBool(op1->getInt() >= op2->getInt()); @@ -1257,7 +1257,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { - //if(_state!=SCRIPT_PERSISTENT) return NULL; + //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); if (!pos) return NULL; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index c33d844aa1..792dfd4589 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -257,14 +257,14 @@ bool ScEngine::tick() { bool obj_found=false; for(int j=0; j<_gameRef->_regObjects.getSize(); j++) { - if(_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) { - if(_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + if (_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); obj_found = true; break; } } - if(!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (_gameRef->validObject(_scripts[i]->_waitObject)) { if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 322fb9bc5b..d2fd3663c7 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -228,7 +228,7 @@ bool SXDate::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Name")==0){ + if (strcmp(name, "Name")==0){ setName(value->getString()); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 01179bb3ad..7da1601bdc 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -663,12 +663,12 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ + if (strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(value->getInt(0), 0); char PropName[20]; - if(_length < OrigLength){ + if (_length < OrigLength){ for(int i=_length; iDeleteProp(PropName); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 6b791871ad..3d3f0b218b 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -462,12 +462,12 @@ bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - if(strcmp(name, "Length")==0){ + if (strcmp(name, "Length")==0){ int OrigLength = _length; _length = max(value->getInt(0), 0); char PropName[20]; - if(_length < OrigLength){ + if (_length < OrigLength){ for(int i=_length; iDeleteProp(PropName); diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 59e0965f5e..5e824cd10c 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -240,7 +240,7 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs val->_isConstVar = SetAsConst; _valObject[Name] = val; - if(_type!=VAL_NATIVE) _type = VAL_OBJECT; + if (_type!=VAL_NATIVE) _type = VAL_OBJECT; */ } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 0b7fc840bf..27276f4fa7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -148,22 +148,22 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { bool res; bool NewlyCreated = false; - if(!_soundBuffer || ForceReload || _streamed){ - if(!_file) _file = _gameRef->_fileManager->openFile(filename); - if(!_file){ + if (!_soundBuffer || ForceReload || _streamed){ + if (!_file) _file = _gameRef->_fileManager->openFile(filename); + if (!_file){ _gameRef->LOG(0, "Error opening sound file '%s'", filename); return STATUS_FAILED; } // switch to streamed for big files - if(!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); + if (!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); } // create buffer - if(!_soundBuffer){ + if (!_soundBuffer){ NewlyCreated = true; res = InitializeBuffer(_file); - if(DID_FAIL(res)){ + if (DID_FAIL(res)){ _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); return res; } @@ -172,13 +172,13 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { // store filename - if(!_filename){ + if (!_filename){ _filename = new char[strlen(filename)+1]; strcpy(_filename, filename); } // close file (if not streaming) - if(!_streamed && _file){ + if (!_streamed && _file){ _gameRef->_fileManager->closeFile(_file); _file = NULL; } -- cgit v1.2.3 From 38507fa9895620639d8733dbb4e085dfb2282a33 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 04:12:58 +0200 Subject: WINTERMUTE: AStyle-formatting. --- engines/wintermute/base/base_file_manager.cpp | 10 +-- engines/wintermute/base/base_file_manager.h | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 28 ++++---- engines/wintermute/base/base_game.h | 14 ++-- engines/wintermute/base/base_keyboard_state.cpp | 48 +++++++------- engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/base_parser.h | 2 +- .../wintermute/base/base_persistence_manager.cpp | 4 +- engines/wintermute/base/base_registry.cpp | 4 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 8 +-- .../wintermute/base/base_transition_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 8 +-- engines/wintermute/base/file/base_disk_file.h | 2 +- engines/wintermute/base/file/base_file_entry.cpp | 10 +-- engines/wintermute/base/file/base_package.cpp | 40 ++++++------ engines/wintermute/base/file/base_package.h | 6 +- engines/wintermute/base/file/base_resources.cpp | 2 +- engines/wintermute/base/file/base_resources.h | 2 +- engines/wintermute/base/file/dcpackage.h | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 4 +- engines/wintermute/base/gfx/base_renderer.h | 4 +- engines/wintermute/base/gfx/base_surface.h | 2 +- .../base/gfx/osystem/base_render_osystem.cpp | 74 +++++++++++----------- .../base/gfx/osystem/base_render_osystem.h | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- engines/wintermute/base/particles/part_emitter.h | 32 +++++----- engines/wintermute/base/sound/base_sound.cpp | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 4 +- .../wintermute/base/sound/base_sound_manager.cpp | 2 +- 31 files changed, 167 insertions(+), 167 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index b25bbf024d..c296f88699 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -119,7 +119,7 @@ bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { switch (type) { case PATH_SINGLE: - // _singlePaths.push_back(path); + // _singlePaths.push_back(path); error("TODO: Allow adding single-paths"); break; case PATH_PACKAGE: @@ -154,7 +154,7 @@ bool BaseFileManager::initPaths() { Common::String path = entries->nextToken(); if (path.size() > 0) { error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); + // addPath(PATH_SINGLE, path); } } delete entries; @@ -170,7 +170,7 @@ bool BaseFileManager::initPaths() { Common::String path = entries->nextToken(); if (path.size() > 0) { error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); + // addPath(PATH_SINGLE, path); } } delete entries; @@ -244,7 +244,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f Common::SeekableReadStream *file = NULL; char fileName[MAX_PATH_LENGTH]; strcpy(fileName, upcName.c_str()); - + // correct slashes for (int32 i = 0; i < upcName.size(); i++) { if (upcName[i] == '/') @@ -300,7 +300,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); - } + } delete SaveThumbFile; return ret; } diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index e3c20378bb..c49bbe3815 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -52,7 +52,7 @@ public: private: typedef enum { PATH_PACKAGE, - PATH_SINGLE + PATH_SINGLE } TPathType; bool reloadPaths(); bool initPaths(); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 77e959f11b..67edccd041 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,7 +61,7 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) + for (int i = 0; i < _subframes.getSize(); i++) delete _subframes[i]; _subframes.removeAll(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 63040f2db2..b2b92d6de4 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -259,10 +259,10 @@ BaseGame::BaseGame(): BaseObject(this) { _autoSaveSlot = 999; _cursorHidden = false; -/*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices -#else*/ + /*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices + #else*/ _touchInterface = false; _constrainedMemory = false; //#endif @@ -460,7 +460,7 @@ bool BaseGame::initialize1() { if (_fader == NULL) break; registerObject(_fader); - + loaded = true; } if (loaded == true) { @@ -2120,9 +2120,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); -#endif*/ + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); + #endif*/ stack->pushNULL(); return STATUS_OK; @@ -2133,9 +2133,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { stack->correctParams(0); -/*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); -#endif*/ + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); + #endif*/ stack->pushNULL(); return STATUS_OK; @@ -3919,9 +3919,9 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { if (custom) *custom = true; } else { BasePlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); if (custom) *custom = false; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 34dec89d20..8da62af40a 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -212,7 +212,7 @@ public: virtual bool loadGame(const char *filename); virtual bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); - + BaseObject *_activeObject; bool _interactive; @@ -296,21 +296,21 @@ private: int _indicatorY; int _indicatorWidth; int _indicatorHeight; - + char *_localSaveDir; bool _saveDirChecked; bool _richSavedGames; char *_savedGameExt; - + char *_loadImageName; char *_saveImageName; int _saveImageX; int _saveImageY; int _loadImageX; int _loadImageY; - + BaseSurface *_saveLoadImage; - + bool _reportTextureFormat; // FPS stuff @@ -328,7 +328,7 @@ private: bool _compressedSavegames; bool _personalizedSave; - + bool emptySaveSlot(int slot); bool isSaveSlotUsed(int slot); bool getSaveSlotDescription(int slot, char *buffer); @@ -353,7 +353,7 @@ private: uint32 _fps; bool updateMusicCrossfade(); - + bool isVideoPlaying(); bool stopVideo(); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index a85ec3e972..03f9929eee 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -266,36 +266,36 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { } enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 + VK_SPACE = 32, + VK_LEFT = 37, + VK_UP = 38, + VK_RIGHT = 39, + VK_DOWN = 40 }; ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { - case VK_SPACE: - return Common::KEYCODE_SPACE; - break; - case VK_LEFT: - return Common::KEYCODE_LEFT; - break; - case VK_RIGHT: - return Common::KEYCODE_RIGHT; - break; - case VK_UP: - return Common::KEYCODE_UP; - break; - case VK_DOWN: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; + case VK_SPACE: + return Common::KEYCODE_SPACE; + break; + case VK_LEFT: + return Common::KEYCODE_LEFT; + break; + case VK_RIGHT: + return Common::KEYCODE_RIGHT; + break; + case VK_UP: + return Common::KEYCODE_UP; + break; + case VK_DOWN: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; } } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 588d210134..12ed67ba2a 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -180,7 +180,7 @@ char *BaseParser::getAssignmentText(char **buf) { break; ++*buf; } - **buf = 0; // null terminate it + **buf = 0; // null terminate it if (theChar) // skip the terminator ++*buf; } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index a5c55ceb41..03ca71b48d 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -60,7 +60,7 @@ namespace WinterMute { class BaseParser : public BaseClass { public: struct TokenDesc { - int32 id; + int32 id; const char *token; }; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 3f9e8de855..cf7deb2970 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -420,12 +420,12 @@ Common::String BasePersistenceManager::getStringObj() { _loadStream->read(ret, len); ret[len] = '\0'; - Common::String retString = ret; + Common::String retString = ret; delete[] ret; if (retString == "(null)") { retString = ""; - } + } return retString; } diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index dfab1b5076..7eb2685746 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -103,7 +103,7 @@ int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int i return init; } } - } + } AnsiString val = readString(subKey, key, ""); if (val.empty()) return init; else return atoi(val.c_str()); @@ -126,7 +126,7 @@ bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int error("This key shouldn't be read by the scripts"); return true; } - } + } writeString(subKey, key, StringUtil::toString(value)); return true; } diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 03b0ef3615..c2e57f9fd6 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -583,7 +583,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) + if (index < 0) index = 0; ScValue *val = stack->pop(); diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 0b87dd2b7a..523bbed866 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -239,10 +239,10 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo float ratioY = scaleY / 100.0f; BasePlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), + (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); return true; } diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 53dd99aac2..eeaacd2063 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -69,7 +69,7 @@ bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { _origInteractive = _gameRef->_interactive; _gameRef->_interactive = false; } /*else _preserveInteractive */; - + _type = type; _state = TRANS_MGR_RUNNING; diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 1598101036..bb8504d2f4 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -46,7 +46,7 @@ void correctSlashes(char *fileName) { } // Parse a relative path in the game-folder, and if it exists, return a FSNode to it. -static Common::FSNode getNodeForRelativePath(const Common::String& filename) { +static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) @@ -88,11 +88,11 @@ static Common::FSNode getNodeForRelativePath(const Common::String& filename) { return Common::FSNode(); } -bool diskFileExists(const Common::String& filename) { +bool diskFileExists(const Common::String &filename) { // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { return true; @@ -112,7 +112,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { // Try directly from SearchMan first Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { file = (*it)->createReadStream(); diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 0653b2e854..99a9e8b9a3 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -34,7 +34,7 @@ namespace WinterMute { Common::SeekableReadStream *openDiskFile(const Common::String &filename); -bool diskFileExists(const Common::String& filename); +bool diskFileExists(const Common::String &filename); } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 5032650704..8282079c86 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -62,11 +62,11 @@ public: Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); if (!file) return NULL; - + // TODO: Cleanup bool compressed = (_compressedLength != 0); /* _size = fileEntry->_length; */ - + if (compressed) { // TODO: Really, most of this logic might be doable directly in the fileEntry? // But for now, this should get us rolling atleast. @@ -77,14 +77,14 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { if (file->size() == 0) { file = new CBPkgFile(file, _length); } - + file->seek(0); - + return file; } ////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry(){ +BaseFileEntry::BaseFileEntry() { _package = NULL; _length = _compressedLength = _offset = _flags = 0; _filename = ""; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 90bb027042..f2d2378c6a 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -51,33 +51,33 @@ Common::SeekableReadStream *BasePackage::getFilePointer() { static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { byte buf[32768]; - + byte signature[8]; ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - + uint32 fileSize = (uint32)f->size(); uint32 startPos = 1024 * 1024; uint32 bytesRead = startPos; - + while (bytesRead < fileSize - 16) { uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); f->seek((int32)startPos, SEEK_SET); uint32 actuallyRead = f->read(buf, toRead); if (actuallyRead != toRead) return false; - + for (uint32 i = 0; i < toRead - 8; i++) if (!memcmp(buf + i, signature, 8)) { *offset = startPos + i; return true; } - + bytesRead = bytesRead + toRead - 16; startPos = startPos + toRead - 16; - + } return false; - + } PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { @@ -98,7 +98,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool boundToExe = true; } } - + TPackageHeader hdr; hdr.readFromStream(stream); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { @@ -106,7 +106,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool delete stream; return; } - + if (hdr._packageVersion != PACKAGE_VERSION) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } @@ -125,7 +125,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool pkg->_fsnode = file; pkg->_boundToExe = boundToExe; - + // read package info byte nameLength = stream->readByte(); char *pkgName = new char[nameLength]; @@ -141,15 +141,15 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool // read file entries uint32 numFiles = stream->readUint32LE(); - + for (uint32 j = 0; j < numFiles; j++) { char *name; uint32 offset, length, compLength, flags, timeDate1, timeDate2; - + nameLength = stream->readByte(); name = new char[nameLength]; stream->read(name, nameLength); - + // v2 - xor name if (hdr._packageVersion == PACKAGE_VERSION) { for (int k = 0; k < nameLength; k++) { @@ -157,18 +157,18 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); - + Common::String upcName = name; upcName.toUppercase(); delete[] name; name = NULL; - + offset = stream->readUint32LE(); offset += absoluteOffset; length = stream->readUint32LE(); compLength = stream->readUint32LE(); flags = stream->readUint32LE(); - + if (hdr._packageVersion == PACKAGE_VERSION) { timeDate1 = stream->readUint32LE(); timeDate2 = stream->readUint32LE(); @@ -181,12 +181,12 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool fileEntry->_length = length; fileEntry->_compressedLength = compLength; fileEntry->_flags = flags; - + _files[upcName] = Common::ArchiveMemberPtr(fileEntry); } else { // current package has higher priority than the registered // TODO: This cast might be a bit ugly. - BaseFileEntry *filePtr = (BaseFileEntry*) &*(_filesIter->_value); + BaseFileEntry *filePtr = (BaseFileEntry *) &*(_filesIter->_value); if (pkg->_priority > filePtr->_package->_priority) { filePtr->_package = pkg; filePtr->_offset = offset; @@ -198,12 +198,12 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - + delete stream; } PackageSet::~PackageSet() { - for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { delete *it; } _packages.clear(); diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index b9a7bc5934..a562229f65 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -48,7 +48,7 @@ public: class PackageSet : public Common::Archive { public: virtual ~PackageSet(); - + PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); /** * Check if a member with the given name is present in the Archive. @@ -64,12 +64,12 @@ public: * @return the number of names added to list */ virtual int listMembers(Common::ArchiveMemberList &list) const; - + /** * Returns a ArchiveMember representation of the given file. */ virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - + /** * Create a stream bound to a member with the specified name in the * archive. If no member with this name exists, 0 is returned. diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index 73c06271d7..aac5436071 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -2816,7 +2816,7 @@ Common::SeekableReadStream *BaseResources::getFile(const Common::String &filenam return NULL; } -bool BaseResources::hasFile(const Common::String& filename) { +bool BaseResources::hasFile(const Common::String &filename) { if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { return true; } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 2959f9882f..2ccab6996f 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -37,7 +37,7 @@ namespace WinterMute { class BaseResources { public: static Common::SeekableReadStream *getFile(const Common::String &filename); - static bool hasFile(const Common::String& filename); + static bool hasFile(const Common::String &filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 5e47edba56..4a51683260 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index dd5d006556..0a97370cb7 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -646,8 +646,8 @@ bool BaseFontTT::initFont() { AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; }*/ } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 90a1e378ca..83b5ad0e16 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -74,7 +74,7 @@ public: virtual void fade(uint16 alpha) = 0; /** * Fade a portion of the screen to a specific color - * + * * @param r the red component to fade too. * @param g the green component to fade too. * @param b the blue component to fade too. @@ -93,7 +93,7 @@ public: virtual bool windowedBlt(); /** * Fill a portion of the screen with a specified color - * + * * @param r the red component to fill with. * @param g the green component to fill with. * @param b the blue component to fill with. diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index cb98bde722..66a3460d48 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -86,7 +86,7 @@ protected: byte _ckRed; byte _ckGreen; byte _ckBlue; - + bool _keepLoaded; Common::String _filename; int _height; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 09ee62c3b8..43cf66d053 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -43,11 +43,11 @@ namespace WinterMute { RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; - _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) - _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) - _mirror |= TransparentSurface::FLIP_H; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) + _mirror |= TransparentSurface::FLIP_V; + if (mirrorY) + _mirror |= TransparentSurface::FLIP_H; if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -78,13 +78,13 @@ RenderTicket::~RenderTicket() { bool RenderTicket::operator==(RenderTicket &t) { if ((t._srcRect != _srcRect) || - (t._dstRect != _dstRect) || - (t._mirror != _mirror) || - (t._owner != _owner) || - (t._hasAlpha != _hasAlpha) || - (t._colorMod != _colorMod)) { - return false; - } + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } return true; } @@ -137,22 +137,22 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { // find suitable resolution -/*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } -#else*/ + /*#ifdef __IPHONEOS__ + _realWidth = 480; + _realHeight = 320; + + int numModes = SDL_GetNumDisplayModes(0); + for (int i = 0; i < numModes; i++) { + SDL_DisplayMode mode; + SDL_GetDisplayMode(0, i, &mode); + + if (mode.w > mode.h) { + _realWidth = mode.w; + _realHeight = mode.h; + break; + } + } + #else*/ _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); //#endif @@ -257,7 +257,7 @@ bool BaseRenderOSystem::flip() { if (_disableDirtyRects) { g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); } - // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); delete _dirtyRect; _dirtyRect = NULL; g_system->updateScreen(); @@ -347,7 +347,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if (_disableDirtyRects) { RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); + // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); return; } @@ -355,8 +355,8 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; } - - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); compare._colorMod = _colorMod; RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { @@ -397,14 +397,14 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { addDirtyRect(renderTicket->_dstRect); } else { // Before something - Common::List::iterator pos; + Common::List::iterator pos; for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { if ((*pos)->_drawNum >= _drawNum) { break; } } _renderQueue.insert(pos, renderTicket); - Common::List::iterator it; + Common::List::iterator it; renderTicket->_drawNum = _drawNum++; // Increment the following tickets, so they still are in line for (it = pos; it != _renderQueue.end(); it++) { @@ -432,7 +432,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { // Decreement the following tickets. for (; it != _renderQueue.end(); it++) { (*it)->_drawNum--; - } + } } // Is not in order, so readd it as if it was a new ticket renderTicket->_drawNum = 0; @@ -457,7 +457,7 @@ void BaseRenderOSystem::drawTickets() { int decrement = 0; while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { - RenderTicket* ticket = *it; + RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); @@ -474,7 +474,7 @@ void BaseRenderOSystem::drawTickets() { // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; // warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); - + // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); _drawNum = 1; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index b7507098da..0d00b1b427 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -102,9 +102,9 @@ private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); - typedef Common::List::iterator RenderQueueIterator; + typedef Common::List::iterator RenderQueueIterator; Common::Rect *_dirtyRect; - Common::List _renderQueue; + Common::List _renderQueue; bool _needsFlip; uint32 _drawNum; Common::Rect _renderRect; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index c8cbe99f73..36213dfde1 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -190,7 +190,7 @@ bool BaseSurfaceOSystem::finishLoad() { delete image; _loaded = true; - + return true; } @@ -529,7 +529,7 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl _hasAlpha = hasAlpha; BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); renderer->invalidateTicketsFromSurface(this); - + return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 198e415cc4..fc557a9512 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -72,57 +72,57 @@ public: private: int _width; int _height; - + int _angle1; int _angle2; - + float _rotation1; float _rotation2; - + float _angVelocity1; float _angVelocity2; - + float _growthRate1; float _growthRate2; bool _exponentialGrowth; - + float _velocity1; float _velocity2; bool _velocityZBased; - + float _scale1; float _scale2; bool _scaleZBased; - + int _maxParticles; - + int _lifeTime1; int _lifeTime2; bool _lifeTimeZBased; - + int _genInterval; int _genAmount; - + bool _running; int _overheadTime; - + int _maxBatches; int _batchesGenerated; - + Rect32 _border; int _borderThicknessLeft; int _borderThicknessRight; int _borderThicknessTop; int _borderThicknessBottom; - + int _fadeInTime; - + int _alpha1; int _alpha2; bool _alphaTimeBased; - + bool _useRegion; - + char *_emitEvent; BaseScriptHolder *_owner; diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 1853d7abfd..8cc8c21948 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -229,7 +229,7 @@ bool BaseSound::setVolume(int volume) { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) + if (!_sound) return STATUS_FAILED; else return _sound->_privateVolume = volume; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 27276f4fa7..f2db0a18fb 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -110,7 +110,7 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { int waveSize, waveRate; byte waveFlags; uint16 waveType; - + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { if (waveType == 1) { // We need to wrap the file in a substream to make sure the size is right. @@ -208,7 +208,7 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { } else { g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); } - } + } return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index a73b20e404..cebc3a3765 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -80,7 +80,7 @@ void BaseSoundMgr::saveSettings() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::initialize() { _soundAvailable = false; - + if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } -- cgit v1.2.3 From ef11f9d0c53cbdd9d88a99143de6f43f34d7e24d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 15:59:26 +0200 Subject: WINTERMUTE: Run Astyle with add-braces to break one-line statements into easier-to-read-code. --- engines/wintermute/base/base.cpp | 28 +- engines/wintermute/base/base_active_rect.cpp | 8 +- engines/wintermute/base/base_dynamic_buffer.cpp | 28 +- engines/wintermute/base/base_fader.cpp | 45 +- engines/wintermute/base/base_file_manager.cpp | 52 +- engines/wintermute/base/base_frame.cpp | 124 ++- engines/wintermute/base/base_game.cpp | 859 ++++++++++++++------- engines/wintermute/base/base_keyboard_state.cpp | 24 +- engines/wintermute/base/base_named_object.cpp | 7 +- engines/wintermute/base/base_object.cpp | 291 ++++--- engines/wintermute/base/base_parser.cpp | 76 +- .../wintermute/base/base_persistence_manager.cpp | 97 ++- engines/wintermute/base/base_quick_msg.cpp | 8 +- engines/wintermute/base/base_region.cpp | 87 ++- engines/wintermute/base/base_registry.cpp | 43 +- engines/wintermute/base/base_save_thumb_helper.cpp | 4 +- engines/wintermute/base/base_script_holder.cpp | 55 +- engines/wintermute/base/base_scriptable.cpp | 39 +- engines/wintermute/base/base_sprite.cpp | 162 ++-- engines/wintermute/base/base_string_table.cpp | 49 +- engines/wintermute/base/base_sub_frame.cpp | 137 ++-- engines/wintermute/base/base_surface_storage.cpp | 45 +- .../wintermute/base/base_transition_manager.cpp | 17 +- engines/wintermute/base/file/base_disk_file.cpp | 11 +- engines/wintermute/base/file/base_file_entry.cpp | 4 +- engines/wintermute/base/file/base_package.cpp | 18 +- .../wintermute/base/file/base_save_thumb_file.cpp | 27 +- engines/wintermute/base/font/base_font.cpp | 7 +- engines/wintermute/base/font/base_font_bitmap.cpp | 115 ++- engines/wintermute/base/font/base_font_storage.cpp | 16 +- .../wintermute/base/font/base_font_truetype.cpp | 119 ++- engines/wintermute/base/font/base_font_truetype.h | 4 +- engines/wintermute/base/gfx/base_image.cpp | 76 +- engines/wintermute/base/gfx/base_renderer.cpp | 28 +- engines/wintermute/base/gfx/base_surface.cpp | 8 +- .../base/gfx/osystem/base_render_osystem.cpp | 55 +- .../base/gfx/osystem/base_surface_osystem.cpp | 41 +- engines/wintermute/base/particles/part_emitter.cpp | 140 +++- .../wintermute/base/particles/part_particle.cpp | 36 +- engines/wintermute/base/scriptables/script.cpp | 292 +++++-- .../wintermute/base/scriptables/script_engine.cpp | 167 ++-- .../wintermute/base/scriptables/script_engine.h | 8 +- .../base/scriptables/script_ext_array.cpp | 35 +- .../wintermute/base/scriptables/script_ext_array.h | 2 +- .../base/scriptables/script_ext_date.cpp | 9 +- .../base/scriptables/script_ext_file.cpp | 166 ++-- .../base/scriptables/script_ext_math.cpp | 8 +- .../base/scriptables/script_ext_mem_buffer.cpp | 118 +-- .../base/scriptables/script_ext_string.cpp | 120 +-- .../wintermute/base/scriptables/script_stack.cpp | 14 +- .../wintermute/base/scriptables/script_value.cpp | 197 +++-- engines/wintermute/base/sound/base_sound.cpp | 113 ++- .../wintermute/base/sound/base_sound_manager.cpp | 19 +- 53 files changed, 2941 insertions(+), 1317 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index b81261cdaf..687d2d52e6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -56,16 +56,19 @@ BaseClass::~BaseClass() { ////////////////////////////////////////////////////////////////////////// const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) + if (_editorPropsIter != _editorProps.end()) { return _editorPropsIter->_value.c_str(); - //return _editorPropsIter->second.c_str(); // <- TODO Clean - else return initVal; + } else { + return initVal; + } } ////////////////////////////////////////////////////////////////////////// bool BaseClass::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) return STATUS_FAILED; + if (propName == NULL) { + return STATUS_FAILED; + } if (propValue == NULL) { _editorProps.erase(propName); @@ -91,8 +94,9 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { TOKEN_TABLE_END - if (!_gameRef->_editorMode) + if (!_gameRef->_editorMode) { return STATUS_OK; + } byte *params; @@ -115,15 +119,21 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { case TOKEN_NAME: delete[] propName; propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; case TOKEN_VALUE: delete[] propValue; propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; } diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 0283ee274e..0756d10698 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -97,8 +97,12 @@ void BaseActiveRect::clipRect() { rc.bottom -= Rend->_drawOffsetY; } - if (rc.left > _rect.left) _offsetX = rc.left - _rect.left; - if (rc.top > _rect.top) _offsetY = rc.top - _rect.top; + if (rc.left > _rect.left) { + _offsetX = rc.left - _rect.left; + } + if (rc.top > _rect.top) { + _offsetY = rc.top - _rect.top; + } BasePlatform::intersectRect(&_rect, &_rect, &rc); } diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 8d6f88c9fe..a61227b0dc 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -53,7 +53,9 @@ BaseDynamicBuffer::~BaseDynamicBuffer() { ////////////////////////////////////////////////////////////////////////// void BaseDynamicBuffer::cleanup() { - if (_buffer) free(_buffer); + if (_buffer) { + free(_buffer); + } _buffer = NULL; _size = 0; _realSize = 0; @@ -72,7 +74,9 @@ uint32 BaseDynamicBuffer::getSize() { bool BaseDynamicBuffer::init(uint32 initSize) { cleanup(); - if (initSize == 0) initSize = _initSize; + if (initSize == 0) { + initSize = _initSize; + } _buffer = (byte *)malloc(initSize); if (!_buffer) { @@ -89,7 +93,9 @@ bool BaseDynamicBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); + if (!_initialized) { + init(); + } while (_offset + size > _realSize) { _realSize += _growBy; @@ -110,7 +116,9 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) init(); + if (!_initialized) { + init(); + } if (_offset + size > _size) { _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); @@ -140,8 +148,9 @@ uint32 BaseDynamicBuffer::getDWORD() { ////////////////////////////////////////////////////////////////////////// void BaseDynamicBuffer::putString(const char *val) { - if (!val) putString("(null)"); - else { + if (!val) { + putString("(null)"); + } else { putDWORD(strlen(val) + 1); putBytes((byte *)val, strlen(val) + 1); } @@ -154,8 +163,11 @@ char *BaseDynamicBuffer::getString() { char *ret = (char *)(_buffer + _offset); _offset += len; - if (!strcmp(ret, "(null)")) return NULL; - else return ret; + if (!strcmp(ret, "(null)")) { + return NULL; + } else { + return ret; + } } diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 10818abfb9..04fde5457c 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -59,23 +59,31 @@ BaseFader::~BaseFader() { ////////////////////////////////////////////////////////////////////////// bool BaseFader::update() { - if (!_active) return STATUS_OK; + if (!_active) { + return STATUS_OK; + } int alphaDelta = _targetAlpha - _sourceAlpha; uint32 time; - if (_system) time = g_system->getMillis() - _startTime; - else time = _gameRef->_timer - _startTime; + if (_system) { + time = g_system->getMillis() - _startTime; + } else { + time = _gameRef->_timer - _startTime; + } - if (time >= _duration) _currentAlpha = _targetAlpha; - else { + if (time >= _duration) { + _currentAlpha = _targetAlpha; + } else { _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); } _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) _active = false; + if (_ready && _currentAlpha == 0x00) { + _active = false; + } return STATUS_OK; } @@ -83,10 +91,13 @@ bool BaseFader::update() { ////////////////////////////////////////////////////////////////////////// bool BaseFader::display() { - if (!_active) return STATUS_OK; + if (!_active) { + return STATUS_OK; + } - if (_currentAlpha > 0x00) + if (_currentAlpha > 0x00) { _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + } return STATUS_OK; } @@ -114,8 +125,11 @@ bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = g_system->getMillis(); - else _startTime = _gameRef->_timer; + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } return STATUS_OK; } @@ -137,8 +151,11 @@ bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { _duration = duration; _system = system; - if (_system) _startTime = g_system->getMillis(); - else _startTime = _gameRef->_timer; + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } return STATUS_OK; @@ -167,7 +184,9 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_targetAlpha)); persistMgr->transfer(TMEMBER(_system)); - if (_system && !persistMgr->getIsSaving()) _startTime = 0; + if (_system && !persistMgr->getIsSaving()) { + _startTime = 0; + } return STATUS_OK; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index c296f88699..ff693e055c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -86,8 +86,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { - if (mustExist) + if (mustExist) { debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); + } return NULL; } @@ -106,7 +107,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz }; buffer[file->size()] = '\0'; - if (size != NULL) *size = file->size(); + if (size != NULL) { + *size = file->size(); + } closeFile(file); return buffer; @@ -114,8 +117,9 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (!path.exists()) + if (!path.exists()) { return STATUS_FAILED; + } switch (type) { case PATH_SINGLE: @@ -141,8 +145,9 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!_gameRef) // This function only works when the game-registry is loaded + if (!_gameRef) { // This function only works when the game-registry is loaded return STATUS_FAILED; + } AnsiString pathList; @@ -210,15 +215,17 @@ bool BaseFileManager::registerPackages() { warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { - if (!fileIt->getName().hasSuffix(".dcp")) + if (!fileIt->getName().hasSuffix(".dcp")) { continue; + } // Avoid registering all the language files // TODO: Select based on the gameDesc. if (fileIt->getParent().getName() == "language") { Common::String parentName = fileIt->getParent().getName(); Common::String dcpName = fileIt->getName(); - if (fileIt->getName() != "english.dcp") + if (fileIt->getName() != "english.dcp") { continue; + } } warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); @@ -247,8 +254,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f // correct slashes for (int32 i = 0; i < upcName.size(); i++) { - if (upcName[i] == '/') + if (upcName[i] == '/') { upcName.setChar('\\', (uint32)i); + } } Common::ArchiveMemberPtr entry = _packages.getMember(upcName); file = entry->createReadStream(); @@ -256,23 +264,29 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } bool BaseFileManager::hasFile(const Common::String &filename) { - if (diskFileExists(filename)) + if (diskFileExists(filename)) { return true; - if (_packages.hasFile(filename)) - return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. - if (BaseResources::hasFile(filename)) + } + if (_packages.hasFile(filename)) { + return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. + } + if (BaseResources::hasFile(filename)) { return true; + } return false; } ////////////////////////////////////////////////////////////////////////// Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) + if (strcmp(filename.c_str(), "") == 0) { return NULL; + } debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) _openFiles.push_back(file); + if (file && keepTrackOf) { + _openFiles.push_back(file); + } return file; } @@ -295,8 +309,9 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!_gameRef) + if (!_gameRef) { error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); + } BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); if (DID_SUCCEED(SaveThumbFile->open(filename))) { ret = SaveThumbFile->getMemStream(); @@ -306,16 +321,19 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f } ret = openDiskFile(filename); - if (ret) + if (ret) { return ret; + } ret = openPkgFile(filename); - if (ret) + if (ret) { return ret; + } ret = BaseResources::getFile(filename); - if (ret) + if (ret) { return ret; + } warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 67edccd041..68b866bbf5 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,8 +61,9 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) + for (int i = 0; i < _subframes.getSize(); i++) { delete _subframes[i]; + } _subframes.removeAll(); for (int i = 0; i < _applyEvent.getSize(); i++) { @@ -79,7 +80,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float for (int i = 0; i < _subframes.getSize(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } } return STATUS_OK; } @@ -88,7 +91,9 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float ////////////////////////////////////////////////////////////////////////// bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { if (_sound && !muted) { - if (owner) owner->updateOneSound(_sound); + if (owner) { + owner->updateOneSound(_sound); + } _sound->play(); /* if (_gameRef->_state == GAME_FROZEN) { @@ -240,7 +245,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { delete subframe; cmd = PARSERR_GENERIC; - } else _subframes.add(subframe); + } else { + _subframes.add(subframe); + } } break; @@ -251,7 +258,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } _sound = new BaseSound(_gameRef); if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) _gameRef->LOG(0, "Error loading sound '%s'.", params); + if (_gameRef->_soundMgr->_soundAvailable) { + _gameRef->LOG(0, "Error loading sound '%s'.", params); + } delete _sound; _sound = NULL; } @@ -291,8 +300,11 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (surface_file != NULL) { - if (custoTrans) sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - else sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + if (custoTrans) { + sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + } else { + sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + } if (!sub->_surface) { delete sub; @@ -301,11 +313,16 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + if (custoTrans) { + sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } } - if (BasePlatform::isRectEmpty(&rect)) sub->setDefaultRect(); - else sub->_rect = rect; + if (BasePlatform::isRectEmpty(&rect)) { + sub->setDefaultRect(); + } else { + sub->_rect = rect; + } sub->_hotspotX = hotspotX; sub->_hotspotY = hotspotY; @@ -325,7 +342,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////////// bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } BasePlatform::setRectEmpty(rect); Rect32 subRect; @@ -344,21 +363,27 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "FRAME {\n"); buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - if (_moveX != 0 || _moveY != 0) + if (_moveX != 0 || _moveY != 0) { buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + } - if (_sound && _sound->_soundFilename) + if (_sound && _sound->_soundFilename) { buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + } buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - if (_killSound) + if (_killSound) { buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + } - if (_editorExpanded) + if (_editorExpanded) { buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + } - if (_subframes.getSize() > 0) _subframes[0]->saveAsText(buffer, indent, false); + if (_subframes.getSize() > 0) { + _subframes[0]->saveAsText(buffer, indent, false); + } for (int i = 1; i < _subframes.getSize(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); @@ -406,8 +431,11 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSound") == 0) { stack->correctParams(0); - if (_sound && _sound->_soundFilename) stack->pushString(_sound->_soundFilename); - else stack->pushNULL(); + if (_sound && _sound->_soundFilename) { + stack->pushString(_sound->_soundFilename); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -426,8 +454,12 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac stack->pushBool(false); delete _sound; _sound = NULL; - } else stack->pushBool(true); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -440,7 +472,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index < 0 || index >= _subframes.getSize()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); - } else stack->pushNative(_subframes[index], true); + } else { + stack->pushNative(_subframes[index], true); + } return STATUS_OK; } @@ -477,7 +511,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac stack->correctParams(1); ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { @@ -496,19 +532,26 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "InsertSubframe") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) index = 0; + if (index < 0) { + index = 0; + } ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseSubFrame *sub = new BaseSubFrame(_gameRef); if (filename != NULL) { sub->setSurface(filename); } - if (index >= _subframes.getSize()) _subframes.add(sub); - else _subframes.insertAt(index, sub); + if (index >= _subframes.getSize()) { + _subframes.add(sub); + } else { + _subframes.insertAt(index, sub); + } stack->pushNative(sub, true); return STATUS_OK; @@ -523,7 +566,9 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index < 0 || index >= _applyEvent.getSize()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); - } else stack->pushString(_applyEvent[index]); + } else { + stack->pushString(_applyEvent[index]); + } return STATUS_OK; } @@ -563,15 +608,20 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scCallMethod(script, stack, thisStack, name); - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); + if (_subframes.getSize() == 1) { + return _subframes[0]->scCallMethod(script, stack, thisStack, name); + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } } } ////////////////////////////////////////////////////////////////////////// ScValue *BaseFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new ScValue(_gameRef); + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -640,8 +690,11 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scGetProperty(name); - else return BaseScriptable::scGetProperty(name); + if (_subframes.getSize() == 1) { + return _subframes[0]->scGetProperty(name); + } else { + return BaseScriptable::scGetProperty(name); + } } } @@ -690,8 +743,11 @@ bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) return _subframes[0]->scSetProperty(name, value); - else return BaseScriptable::scSetProperty(name, value); + if (_subframes.getSize() == 1) { + return _subframes[0]->scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } } } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b2b92d6de4..9de183660e 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -390,7 +390,9 @@ bool BaseGame::cleanup() { _fontStorage->removeFont(_videoFont); _videoFont = NULL; - for (int i = 0; i < _quickMessages.getSize(); i++) delete _quickMessages[i]; + for (int i = 0; i < _quickMessages.getSize(); i++) { + delete _quickMessages[i]; + } _quickMessages.removeAll(); _viewportStack.removeAll(); @@ -417,48 +419,59 @@ bool BaseGame::initialize1() { bool loaded = false; // Not really a loop, but a goto-replacement. while (!loaded) { _surfaceStorage = new BaseSurfaceStorage(this); - if (_surfaceStorage == NULL) + if (_surfaceStorage == NULL) { break; + } _fontStorage = new BaseFontStorage(this); - if (_fontStorage == NULL) + if (_fontStorage == NULL) { break; + } _fileManager = new BaseFileManager(this); - if (_fileManager == NULL) + if (_fileManager == NULL) { break; + } _soundMgr = new BaseSoundMgr(this); - if (_soundMgr == NULL) + if (_soundMgr == NULL) { break; + } _debugMgr = new BaseDebugger(this); - if (_debugMgr == NULL) + if (_debugMgr == NULL) { break; + } _mathClass = new SXMath(this); - if (_mathClass == NULL) + if (_mathClass == NULL) { break; + } _scEngine = new ScEngine(this); - if (_scEngine == NULL) + if (_scEngine == NULL) { break; + } _videoPlayer = new VideoPlayer(this); - if (_videoPlayer == NULL) + if (_videoPlayer == NULL) { break; + } _transMgr = new BaseTransitionMgr(this); - if (_transMgr == NULL) + if (_transMgr == NULL) { break; + } _keyboardState = new BaseKeyboardState(this); - if (_keyboardState == NULL) + if (_keyboardState == NULL) { break; + } _fader = new BaseFader(this); - if (_fader == NULL) + if (_fader == NULL) { break; + } registerObject(_fader); loaded = true; @@ -484,7 +497,9 @@ bool BaseGame::initialize1() { ////////////////////////////////////////////////////////////////////// bool BaseGame::initialize2() { // we know whether we are going to be accelerated _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) return STATUS_FAILED; + if (_renderer == NULL) { + return STATUS_FAILED; + } return STATUS_OK; } @@ -495,9 +510,15 @@ bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; - if (_indicatorY == -1) _indicatorY = _renderer->_height - _indicatorHeight; - if (_indicatorX == -1) _indicatorX = 0; - if (_indicatorWidth == -1) _indicatorWidth = _renderer->_width; + if (_indicatorY == -1) { + _indicatorY = _renderer->_height - _indicatorHeight; + } + if (_indicatorX == -1) { + _indicatorX = 0; + } + if (_indicatorWidth == -1) { + _indicatorWidth = _renderer->_width; + } return STATUS_OK; } @@ -567,7 +588,9 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } - if (_debugMgr) _debugMgr->onLog(res, buff); + if (_debugMgr) { + _debugMgr->onLog(res, buff); + } debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); @@ -615,7 +638,9 @@ bool BaseGame::initLoop() { _timerDelta = _timer - _timerLast; _timerLast = _timer; _timer += MIN((uint32)1000, _deltaTime); - } else _timerDelta = 0; + } else { + _timerDelta = 0; + } _framesRendered++; if (_fpsTime > 1000) { @@ -637,7 +662,9 @@ bool BaseGame::initLoop() { updateSounds(); - if (_fader) _fader->update(); + if (_fader) { + _fader->update(); + } return STATUS_OK; } @@ -663,8 +690,12 @@ void BaseGame::setOffset(int offsetX, int offsetY) { ////////////////////////////////////////////////////////////////////////// void BaseGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) *offsetX = _offsetX; - if (offsetY != NULL) *offsetY = _offsetY; + if (offsetX != NULL) { + *offsetX = _offsetX; + } + if (offsetY != NULL) { + *offsetY = _offsetY; + } } @@ -680,7 +711,9 @@ bool BaseGame::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + } delete[] buffer; @@ -789,7 +822,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -801,14 +836,18 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_SYSTEM_FONT: - if (_systemFont) _fontStorage->removeFont(_systemFont); + if (_systemFont) { + _fontStorage->removeFont(_systemFont); + } _systemFont = NULL; _systemFont = _gameRef->_fontStorage->addFont((char *)params); break; case TOKEN_VIDEO_FONT: - if (_videoFont) _fontStorage->removeFont(_videoFont); + if (_videoFont) { + _fontStorage->removeFont(_videoFont); + } _videoFont = NULL; _videoFont = _gameRef->_fontStorage->addFont((char *)params); @@ -939,7 +978,9 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } } - if (!_systemFont) _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + if (!_systemFont) { + _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + } if (cmd == PARSERR_TOKENNOTFOUND) { @@ -994,10 +1035,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "RunScript") == 0) { _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) + if (DID_FAIL(addScript(stack->pop()->getString()))) { stack->pushBool(false); - else + } else { stack->pushBool(true); + } return STATUS_OK; } @@ -1008,16 +1050,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "LoadStringTable") == 0) { stack->correctParams(2); const char *filename = stack->pop()->getString(); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); bool ClearOld; - if (Val->isNULL()) ClearOld = true; - else ClearOld = Val->getBool(); + if (val->isNULL()) { + ClearOld = true; + } else { + ClearOld = val->getBool(); + } - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) + if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) { stack->pushBool(false); - else + } else { stack->pushBool(true); + } return STATUS_OK; } @@ -1028,8 +1074,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "ValidObject") == 0) { stack->correctParams(1); BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *) obj)) stack->pushBool(true); - else stack->pushBool(false); + if (validObject((BaseObject *) obj)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1054,7 +1103,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *val = stack->pop(); BaseObject *obj = (BaseObject *)val->getNative(); unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) val->setNULL(); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } stack->pushNULL(); return STATUS_OK; @@ -1097,8 +1148,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PlayMusic") == 0) stack->correctParams(3); - else { + if (strcmp(name, "PlayMusic") == 0) { + stack->correctParams(3); + } else { stack->correctParams(4); channel = stack->pop()->getInt(); } @@ -1111,8 +1163,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1122,14 +1177,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "StopMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "StopMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(stopMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(stopMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1139,14 +1198,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "PauseMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "PauseMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(pauseMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(pauseMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1155,14 +1218,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "ResumeMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (DID_FAIL(resumeMusic(channel))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(resumeMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1171,15 +1238,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { int channel = 0; - if (strcmp(name, "GetMusic") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusic") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) stack->pushNULL(); - else { - if (!_music[channel] || !_music[channel]->_soundFilename) stack->pushNULL(); - else stack->pushString(_music[channel]->_soundFilename); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { + stack->pushNULL(); + } else { + if (!_music[channel] || !_music[channel]->_soundFilename) { + stack->pushNULL(); + } else { + stack->pushString(_music[channel]->_soundFilename); + } } return STATUS_OK; } @@ -1189,16 +1261,20 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) stack->correctParams(1); - else { + if (strcmp(name, "SetMusicPosition") == 0) { + stack->correctParams(1); + } else { stack->correctParams(2); channel = stack->pop()->getInt(); } uint32 time = stack->pop()->getInt(); - if (DID_FAIL(setMusicStartTime(channel, time))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setMusicStartTime(channel, time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -1208,14 +1284,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusicPosition") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getPositionTime()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getPositionTime()); + } return STATUS_OK; } @@ -1224,14 +1304,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) stack->correctParams(0); - else { + if (strcmp(name, "IsMusicPlaying") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else stack->pushBool(_music[channel]->isPlaying()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + stack->pushBool(_music[channel]->isPlaying()); + } return STATUS_OK; } @@ -1240,17 +1324,22 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) stack->correctParams(1); - else { + if (strcmp(name, "SetMusicVolume") == 0) { + stack->correctParams(1); + } else { stack->correctParams(2); channel = stack->pop()->getInt(); } int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushBool(false); - else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) stack->pushBool(false); - else stack->pushBool(true); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } } return STATUS_OK; } @@ -1260,14 +1349,18 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) stack->correctParams(0); - else { + if (strcmp(name, "GetMusicVolume") == 0) { + stack->correctParams(0); + } else { stack->correctParams(1); channel = stack->pop()->getInt(); } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) stack->pushInt(0); - else stack->pushInt(_music[channel]->getVolumePercent()); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getVolumePercent()); + } return STATUS_OK; } @@ -1350,8 +1443,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int right = stack->pop()->getInt(); int bottom = stack->pop()->getInt(); - if (right < left) BaseUtils::swap(&left, &right); - if (bottom < top) BaseUtils::swap(&top, &bottom); + if (right < left) { + BaseUtils::swap(&left, &right); + } + if (bottom < top) { + BaseUtils::swap(&top, &bottom); + } BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); @@ -1376,26 +1473,34 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); warning("PlayVideo: %s - not implemented yet", filename); ScValue *valType = stack->pop(); - int Type; - if (valType->isNULL()) Type = (int)VID_PLAY_STRETCH; - else Type = valType->getInt(); + int type; + if (valType->isNULL()) { + type = (int)VID_PLAY_STRETCH; + } else { + type = valType->getInt(); + } int xVal = stack->pop()->getInt(); int yVal = stack->pop()->getInt(); - bool FreezeMusic = stack->pop()->getBool(true); + bool freezeMusic = stack->pop()->getBool(true); ScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - if (Type < (int)VID_PLAY_POS || Type > (int)VID_PLAY_CENTER) - Type = (int)VID_PLAY_STRETCH; + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, SubtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)Type, xVal, yVal, FreezeMusic))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, subtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)type, xVal, yVal, freezeMusic))) { stack->pushBool(true); script->sleep(0); - } else stack->pushBool(false); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1414,9 +1519,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); ScValue *valType = stack->pop(); int type; - if (valType->isNULL()) + if (valType->isNULL()) { type = (int)VID_PLAY_STRETCH; - else type = valType->getInt(); + } else { + type = valType->getInt(); + } int xVal = stack->pop()->getInt(); int yVal = stack->pop()->getInt(); @@ -1426,7 +1533,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ScValue *valSub = stack->pop(); const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) type = (int)VID_PLAY_STRETCH; + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } delete _theoraPlayer; _theoraPlayer = new VideoTheoraPlayer(this); @@ -1435,7 +1544,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); script->sleep(0); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } } else { stack->pushBool(false); delete _theoraPlayer; @@ -1649,8 +1760,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetActiveCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1660,8 +1774,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursor") == 0) { stack->correctParams(0); - if (!_activeCursor || !_activeCursor->getFilename()) stack->pushNULL(); - else stack->pushString(_activeCursor->getFilename()); + if (!_activeCursor || !_activeCursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_activeCursor->getFilename()); + } return STATUS_OK; } @@ -1671,8 +1788,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetActiveCursorObject") == 0) { stack->correctParams(0); - if (!_activeCursor) stack->pushNULL(); - else stack->pushNative(_activeCursor, true); + if (!_activeCursor) { + stack->pushNULL(); + } else { + stack->pushNative(_activeCursor, true); + } return STATUS_OK; } @@ -1695,8 +1815,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "HasActiveCursor") == 0) { stack->correctParams(0); - if (_activeCursor) stack->pushBool(true); - else stack->pushBool(false); + if (_activeCursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1710,8 +1833,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // TODO: Replace with fileExists Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) stack->pushBool(false); - else { + if (!file) { + stack->pushBool(false); + } else { _fileManager->closeFile(file); stack->pushBool(true); } @@ -1732,7 +1856,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1752,7 +1878,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) script->waitFor(_fader); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) { + script->waitFor(_fader); + } stack->pushNULL(); return STATUS_OK; @@ -1774,15 +1902,16 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); char filename[MAX_PATH_LENGTH]; - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO int fileNum = 0; while (true) { - sprintf(filename, "%s%03d.bmp", Val->isNULL() ? getName() : Val->getString(), fileNum); - if (!Common::File::exists(filename)) + sprintf(filename, "%s%03d.bmp", val->isNULL() ? getName() : val->getString(), fileNum); + if (!Common::File::exists(filename)) { break; + } fileNum++; } @@ -1791,7 +1920,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (image) { ret = DID_SUCCEED(image->saveBMPFile(filename)); delete image; - } else ret = false; + } else { + ret = false; + } stack->pushBool(ret); return STATUS_OK; @@ -1810,9 +1941,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack BaseImage *image = _gameRef->_renderer->takeScreenshot(); if (image) { ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) ret = DID_SUCCEED(image->saveBMPFile(filename)); + if (ret) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + } delete image; - } else ret = false; + } else { + ret = false; + } stack->pushBool(ret); return STATUS_OK; @@ -1828,7 +1963,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack UIWindow *win = new UIWindow(_gameRef); _windows.add(win); registerObject(win); - if (!val->isNULL()) win->setName(val->getString()); + if (!val->isNULL()) { + win->setName(val->getString()); + } stack->pushNative(win, true); return STATUS_OK; } @@ -1912,8 +2049,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetWaitCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -1936,8 +2076,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursor") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) stack->pushNULL(); - else stack->pushString(_cursorNoninteractive->getFilename()); + if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNoninteractive->getFilename()); + } return STATUS_OK; } @@ -1947,8 +2090,11 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWaitCursorObject") == 0) { stack->correctParams(0); - if (!_cursorNoninteractive) stack->pushNULL(); - else stack->pushNative(_cursorNoninteractive, true); + if (!_cursorNoninteractive) { + stack->pushNULL(); + } else { + stack->pushNative(_cursorNoninteractive, true); + } return STATUS_OK; } @@ -2017,10 +2163,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccOutputText") == 0) { stack->correctParams(2); - /* const char *Str = */ - stack->pop()->getString(); - /* int Type = */ - stack->pop()->getInt(); + /* const char *Str = */ stack->pop()->getString(); + /* int type = */ stack->pop()->getInt(); // do nothing stack->pushNULL(); @@ -2038,7 +2182,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _cachedThumbnail; _cachedThumbnail = NULL; stack->pushBool(false); - } else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -2083,12 +2229,15 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack char Hex[100]; sprintf(Hex, "%x", checksum); stack->pushString(Hex); - } else + } else { stack->pushInt(checksum); + } _fileManager->closeFile(file); file = NULL; - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -2139,9 +2288,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushNULL(); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -2307,8 +2456,11 @@ ScValue *BaseGame::scGetProperty(const char *name) { // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) _scValue->setNative(_keyboardState, true); - else _scValue->setNULL(); + if (_keyboardState) { + _scValue->setNative(_keyboardState, true); + } else { + _scValue->setNULL(); + } return _scValue; } @@ -2530,9 +2682,9 @@ ScValue *BaseGame::scGetProperty(const char *name) { error("Request for a SXStore-object, which is not supported by ScummVM"); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -2579,7 +2731,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MainObject") == 0) { BaseScriptable *obj = value->getNative(); - if (obj == NULL || validObject((BaseObject *)obj)) _mainObject = (BaseObject *)obj; + if (obj == NULL || validObject((BaseObject *)obj)) { + _mainObject = (BaseObject *)obj; + } return STATUS_OK; } @@ -2655,10 +2809,14 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { // TextEncoding ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "TextEncoding") == 0) { - int Enc = value->getInt(); - if (Enc < 0) Enc = 0; - if (Enc >= NUM_TEXT_ENCODINGS) Enc = NUM_TEXT_ENCODINGS - 1; - _textEncoding = (TTextEncoding)Enc; + int enc = value->getInt(); + if (enc < 0) { + enc = 0; + } + if (enc >= NUM_TEXT_ENCODINGS) { + enc = NUM_TEXT_ENCODINGS - 1; + } + _textEncoding = (TTextEncoding)enc; return STATUS_OK; } @@ -2725,9 +2883,9 @@ bool BaseGame::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "CursorHidden") == 0) { _cursorHidden = value->getBool(); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -2741,7 +2899,9 @@ const char *BaseGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) return STATUS_OK; + if (_quickMessages.getSize() == 0 || !_systemFont) { + return STATUS_OK; + } // update for (int i = 0; i < _quickMessages.getSize(); i++) { @@ -2796,7 +2956,9 @@ bool BaseGame::registerObject(BaseObject *object) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::unregisterObject(BaseObject *object) { - if (!object) return STATUS_OK; + if (!object) { + return STATUS_OK; + } // is it a window? for (int i = 0; i < _windows.getSize(); i++) { @@ -2804,23 +2966,31 @@ bool BaseGame::unregisterObject(BaseObject *object) { _windows.removeAt(i); // get new focused window - if (_focusedWindow == object) _focusedWindow = NULL; + if (_focusedWindow == object) { + _focusedWindow = NULL; + } break; } } // is it active object? - if (_activeObject == object) _activeObject = NULL; + if (_activeObject == object) { + _activeObject = NULL; + } // is it main object? - if (_mainObject == object) _mainObject = NULL; + if (_mainObject == object) { + _mainObject = NULL; + } // destroy object for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { _regObjects.removeAt(i); - if (!_loadInProgress) SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + if (!_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + } delete object; return STATUS_OK; } @@ -2846,11 +3016,17 @@ void BaseGame::invalidateValues(void *value, void *data) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::validObject(BaseObject *object) { - if (!object) return false; - if (object == this) return true; + if (!object) { + return false; + } + if (object == this) { + return true; + } for (int i = 0; i < _regObjects.getSize(); i++) { - if (_regObjects[i] == object) return true; + if (_regObjects[i] == object) { + return true; + } } return false; } @@ -2946,7 +3122,9 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *)obj)) script->waitForExclusive((BaseObject *)obj); + if (validObject((BaseObject *)obj)) { + script->waitForExclusive((BaseObject *)obj); + } stack->pushNULL(); } @@ -2982,8 +3160,11 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack int b = stack->pop()->getInt(); int a; ScValue *val = stack->pop(); - if (val->isNULL()) a = 255; - else a = val->getInt(); + if (val->isNULL()) { + a = 255; + } else { + a = val->getInt(); + } stack->pushInt(BYTETORGBA(r, g, b, a)); } @@ -3142,15 +3323,23 @@ bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// bool BaseGame::showCursor() { - if (_cursorHidden) return STATUS_OK; + if (_cursorHidden) { + return STATUS_OK; + } if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) return drawCursor(_cursorNoninteractive); + if (_cursorNoninteractive) { + return drawCursor(_cursorNoninteractive); + } } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) return STATUS_OK; - else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) return drawCursor(_activeCursor); - else if (_cursor) return drawCursor(_cursor); + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) { + return STATUS_OK; + } else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) { + return drawCursor(_activeCursor); + } else if (_cursor) { + return drawCursor(_cursor); + } } } return STATUS_FAILED; @@ -3171,7 +3360,9 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) goto save_finish; + if (DID_FAIL(ret = pm->initSave(desc))) { + goto save_finish; + } if (!quickSave) { delete _saveLoadImage; @@ -3186,9 +3377,15 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { } } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) goto save_finish; - if (DID_FAIL(ret = pm->saveFile(filename))) goto save_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { + goto save_finish; + } + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { + goto save_finish; + } + if (DID_FAIL(ret = pm->saveFile(filename))) { + goto save_finish; + } _registry->writeInt("System", "MostRecentSaveSlot", slot); @@ -3240,11 +3437,17 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initLoad(filename))) goto load_finish; + if (DID_FAIL(ret = pm->initLoad(filename))) { + goto load_finish; + } //if (DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) goto load_finish; + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { + goto load_finish; + } + if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { + goto load_finish; + } // data initialization after load initAfterLoad(); @@ -3332,7 +3535,9 @@ bool BaseGame::displayWindows(bool inGame) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } } } @@ -3356,7 +3561,9 @@ bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 _music[channel]->setPositionTime(_musicStartTime[channel]); _musicStartTime[channel] = 0; } - if (loopStart) _music[channel]->setLoopStart(loopStart); + if (loopStart) { + _music[channel]->setLoopStart(loopStart); + } return _music[channel]->play(looping); } else { delete _music[channel]; @@ -3378,7 +3585,9 @@ bool BaseGame::stopMusic(int channel) { delete _music[channel]; _music[channel] = NULL; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -3389,8 +3598,11 @@ bool BaseGame::pauseMusic(int channel) { return STATUS_FAILED; } - if (_music[channel]) return _music[channel]->pause(); - else return STATUS_FAILED; + if (_music[channel]) { + return _music[channel]->pause(); + } else { + return STATUS_FAILED; + } } @@ -3401,8 +3613,11 @@ bool BaseGame::resumeMusic(int channel) { return STATUS_FAILED; } - if (_music[channel]) return _music[channel]->resume(); - else return STATUS_FAILED; + if (_music[channel]) { + return _music[channel]->resume(); + } else { + return STATUS_FAILED; + } } @@ -3414,8 +3629,11 @@ bool BaseGame::setMusicStartTime(int channel, uint32 time) { } _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) return _music[channel]->setPositionTime(time); - else return STATUS_OK; + if (_music[channel] && _music[channel]->isPlaying()) { + return _music[channel]->setPositionTime(time); + } else { + return STATUS_OK; + } } @@ -3464,11 +3682,15 @@ bool BaseGame::loadSettings(const char *filename) { case TOKEN_GAME: delete[] _settingsGameFile; _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) strcpy(_settingsGameFile, (char *)params); + if (_settingsGameFile) { + strcpy(_settingsGameFile, (char *)params); + } break; case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(_stringTable->loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_RESOLUTION: @@ -3544,8 +3766,9 @@ bool BaseGame::loadSettings(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) + if (!persistMgr->getIsSaving()) { cleanup(); + } BaseObject::persist(persistMgr); @@ -3627,29 +3850,32 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_autoSaveSlot)); persistMgr->transfer(TMEMBER(_cursorHidden)); - if (!persistMgr->getIsSaving()) + if (!persistMgr->getIsSaving()) { _quitting = false; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// -bool BaseGame::focusWindow(UIWindow *Window) { - UIWindow *Prev = _focusedWindow; +bool BaseGame::focusWindow(UIWindow *window) { + UIWindow *prev = _focusedWindow; for (int i = 0; i < _windows.getSize(); i++) { - if (_windows[i] == Window) { + if (_windows[i] == window) { if (i < _windows.getSize() - 1) { _windows.removeAt(i); - _windows.add(Window); + _windows.add(window); - _gameRef->_focusedWindow = Window; + _gameRef->_focusedWindow = window; } - if (Window->_mode == WINDOW_NORMAL && Prev != Window && _gameRef->validObject(Prev) && (Prev->_mode == WINDOW_EXCLUSIVE || Prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) - return focusWindow(Prev); - else return STATUS_OK; + if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) { + return focusWindow(prev); + } else { + return STATUS_OK; + } } } return STATUS_FAILED; @@ -3674,7 +3900,9 @@ bool BaseGame::freeze(bool includingMusic) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::unfreeze() { - if (_freezeLevel == 0) return STATUS_OK; + if (_freezeLevel == 0) { + return STATUS_OK; + } _freezeLevel--; if (_freezeLevel == 0) { @@ -3691,8 +3919,9 @@ bool BaseGame::unfreeze() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) { stopVideo(); + } return true; } @@ -3708,10 +3937,11 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { if (_focusedWindow) { if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) { _gameRef->_focusedWindow->applyEvent("Keypress"); - else + } else { applyEvent("Keypress"); + } /*}*/ } return true; @@ -3760,11 +3990,19 @@ bool BaseGame::handleMouseWheel(int Delta) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) *verMajor = DCGF_VER_MAJOR; - if (verMinor) *verMinor = DCGF_VER_MINOR; + if (verMajor) { + *verMajor = DCGF_VER_MAJOR; + } + if (verMinor) { + *verMinor = DCGF_VER_MINOR; + } - if (extMajor) *extMajor = 0; - if (extMinor) *extMinor = 0; + if (extMajor) { + *extMajor = 0; + } + if (extMinor) { + *extMinor = 0; + } return STATUS_OK; } @@ -3775,7 +4013,9 @@ void BaseGame::setWindowTitle() { if (_renderer) { char title[512]; strcpy(title, _caption[0]); - if (title[0] != '\0') strcat(title, " - "); + if (title[0] != '\0') { + strcat(title, " - "); + } strcat(title, "WME Lite"); @@ -3825,7 +4065,9 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (!pm) return STATUS_FAILED; + if (!pm) { + return STATUS_FAILED; + } if (DID_FAIL(pm->initLoad(filename))) { delete pm; @@ -3845,9 +4087,11 @@ bool BaseGame::isSaveSlotUsed(int slot) { getSaveSlotFilename(slot, filename); warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *File = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!File) return false; - delete File; + Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename); + if (!file) { + return false; + } + delete file; return true; } @@ -3870,9 +4114,13 @@ bool BaseGame::setActiveObject(BaseObject *obj) { obj = NULL; } - if (obj == _activeObject) return STATUS_OK; + if (obj == _activeObject) { + return STATUS_OK; + } - if (_activeObject) _activeObject->applyEvent("MouseLeave"); + if (_activeObject) { + _activeObject->applyEvent("MouseLeave"); + } //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); _activeObject = obj; if (_activeObject) { @@ -3886,8 +4134,11 @@ bool BaseGame::setActiveObject(BaseObject *obj) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) _viewportStack.add(viewport); - else _viewportStack[_viewportSP] = viewport; + if (_viewportSP >= _viewportStack.getSize()) { + _viewportStack.add(viewport); + } else { + _viewportStack[_viewportSP] = viewport; + } _renderer->setViewport(viewport->getRect()); @@ -3898,13 +4149,16 @@ bool BaseGame::pushViewport(BaseViewport *viewport) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::popViewport() { _viewportSP--; - if (_viewportSP < -1) _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + if (_viewportSP < -1) { + _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + } - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); + if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) { + _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + } else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); return STATUS_OK; } @@ -3912,17 +4166,22 @@ bool BaseGame::popViewport() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) return STATUS_FAILED; - else { + if (rect == NULL) { + return STATUS_FAILED; + } else { if (_viewportSP >= 0) { BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) *custom = true; + if (custom) { + *custom = true; + } } else { BasePlatform::setRect(rect, _renderer->_drawOffsetX, _renderer->_drawOffsetY, _renderer->_width + _renderer->_drawOffsetX, _renderer->_height + _renderer->_drawOffsetY); - if (custom) *custom = false; + if (custom) { + *custom = false; + } } return STATUS_OK; @@ -3933,11 +4192,19 @@ bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { if (_viewportSP >= 0) { - if (offsetX) *offsetX = _viewportStack[_viewportSP]->_offsetX; - if (offsetY) *offsetY = _viewportStack[_viewportSP]->_offsetY; + if (offsetX) { + *offsetX = _viewportStack[_viewportSP]->_offsetX; + } + if (offsetY) { + *offsetY = _viewportStack[_viewportSP]->_offsetY; + } } else { - if (offsetX) *offsetX = 0; - if (offsetY) *offsetY = 0; + if (offsetX) { + *offsetX = 0; + } + if (offsetY) { + *offsetY = 0; + } } return STATUS_OK; @@ -3959,7 +4226,9 @@ bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack * ////////////////////////////////////////////////////////////////////////// void BaseGame::setInteractive(bool state) { _interactive = state; - if (_transMgr) _transMgr->_origInteractive = state; + if (_transMgr) { + _transMgr->_origInteractive = state; + } } @@ -3983,7 +4252,9 @@ bool BaseGame::displayContent(bool doUpdate, bool displayAll) { bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); - if (_indicatorDisplay) displayIndicator(); + if (_indicatorDisplay) { + displayIndicator(); + } return STATUS_OK; } @@ -3994,14 +4265,20 @@ bool BaseGame::displayIndicator() { if (_saveLoadImage) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - else _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } } - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) return STATUS_OK; + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + return STATUS_OK; + } _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) + for (int i = 0; i < _indicatorHeight; i++) { _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + } _renderer->setup2D(); return STATUS_OK; @@ -4011,8 +4288,12 @@ bool BaseGame::displayIndicator() { bool BaseGame::updateMusicCrossfade() { /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - if (!_musicCrossfadeRunning) return STATUS_OK; - if (_state == GAME_FROZEN) return STATUS_OK; + if (!_musicCrossfadeRunning) { + return STATUS_OK; + } + if (_state == GAME_FROZEN) { + return STATUS_OK; + } if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { _musicCrossfadeRunning = false; @@ -4023,8 +4304,12 @@ bool BaseGame::updateMusicCrossfade() { return STATUS_OK; } - if (!_music[_musicCrossfadeChannel1]->isPlaying()) _music[_musicCrossfadeChannel1]->play(); - if (!_music[_musicCrossfadeChannel2]->isPlaying()) _music[_musicCrossfadeChannel2]->play(); + if (!_music[_musicCrossfadeChannel1]->isPlaying()) { + _music[_musicCrossfadeChannel1]->play(); + } + if (!_music[_musicCrossfadeChannel2]->isPlaying()) { + _music[_musicCrossfadeChannel2]->play(); + } uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; @@ -4112,19 +4397,27 @@ bool BaseGame::setWaitCursor(const char *filename) { delete _cursorNoninteractive; _cursorNoninteractive = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool BaseGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) return true; - if (_theoraPlayer && _theoraPlayer->isPlaying()) return true; + if (_videoPlayer->isPlaying()) { + return true; + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + return true; + } return false; } ////////////////////////////////////////////////////////////////////////// bool BaseGame::stopVideo() { - if (_videoPlayer->isPlaying()) _videoPlayer->stop(); + if (_videoPlayer->isPlaying()) { + _videoPlayer->stop(); + } if (_theoraPlayer && _theoraPlayer->isPlaying()) { _theoraPlayer->stop(); delete _theoraPlayer; @@ -4136,7 +4429,9 @@ bool BaseGame::stopVideo() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::drawCursor(BaseSprite *cursor) { - if (!cursor) return STATUS_FAILED; + if (!cursor) { + return STATUS_FAILED; + } if (cursor != _lastCursor) { cursor->reset(); _lastCursor = cursor; @@ -4148,7 +4443,9 @@ bool BaseGame::drawCursor(BaseSprite *cursor) { ////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////// bool BaseGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) return STATUS_OK; + if (_shuttingDown || !_renderer) { + return STATUS_OK; + } _renderer->_active = activate; @@ -4158,15 +4455,20 @@ bool BaseGame::onActivate(bool activate, bool refreshMouse) { setActiveObject(_renderer->getObjectAt(p.x, p.y)); } - if (activate) _soundMgr->resumeAll(); - else _soundMgr->pauseAll(); + if (activate) { + _soundMgr->resumeAll(); + } else { + _soundMgr->pauseAll(); + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); if (!handled) { @@ -4175,7 +4477,9 @@ bool BaseGame::onMouseLeftDown() { } } - if (_activeObject != NULL) _capturedObject = _activeObject; + if (_activeObject != NULL) { + _capturedObject = _activeObject; + } _mouseLeftDown = true; BasePlatform::setCapture(/*_renderer->_window*/); @@ -4184,7 +4488,9 @@ bool BaseGame::onMouseLeftDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } BasePlatform::releaseCapture(); _capturedObject = NULL; @@ -4201,9 +4507,13 @@ bool BaseGame::onMouseLeftUp() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); if (!handled) { @@ -4216,9 +4526,13 @@ bool BaseGame::onMouseLeftDblClick() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); if (!handled) { @@ -4231,7 +4545,9 @@ bool BaseGame::onMouseRightDblClick() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightDown() { - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); if (!handled) { @@ -4244,7 +4560,9 @@ bool BaseGame::onMouseRightDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseRightUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); if (!handled) { @@ -4257,9 +4575,13 @@ bool BaseGame::onMouseRightUp() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) return STATUS_OK; + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } - if (_activeObject) _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); if (!handled) { @@ -4272,7 +4594,9 @@ bool BaseGame::onMouseMiddleDown() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onMouseMiddleUp() { - if (_activeObject) _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + } bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); if (!handled) { @@ -4297,9 +4621,13 @@ bool BaseGame::onPaint() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::onWindowClose() { if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) _gameRef->applyEvent("QuitGame"); + if (_state != GAME_FROZEN) { + _gameRef->applyEvent("QuitGame"); + } return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// @@ -4312,10 +4640,11 @@ bool BaseGame::displayDebugInfo() { } if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) + if (!_gameRef->_renderer->_windowed) { sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - else + } else { sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + } strcat(str, " ("); strcat(str, _renderer->getName().c_str()); @@ -4333,7 +4662,9 @@ bool BaseGame::displayDebugInfo() { sprintf(str, "Timer: %d", _timer); _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - if (_activeObject != NULL) _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + if (_activeObject != NULL) { + _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + } sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); @@ -4345,7 +4676,9 @@ bool BaseGame::displayDebugInfo() { ////////////////////////////////////////////////////////////////////////// BaseDebugger *BaseGame::getDebugMgr() { - if (!_debugMgr) _debugMgr = new BaseDebugger(this); + if (!_debugMgr) { + _debugMgr = new BaseDebugger(this); + } return _debugMgr; } @@ -4390,10 +4723,14 @@ void BaseGame::getMousePos(Point32 *pos) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::miniUpdate() { - if (!_miniUpdateEnabled) return STATUS_OK; + if (!_miniUpdateEnabled) { + return STATUS_OK; + } if (g_system->getMillis() - _lastMiniUpdate > 200) { - if (_soundMgr) _soundMgr->initLoop(); + if (_soundMgr) { + _soundMgr->initLoop(); + } _lastMiniUpdate = g_system->getMillis(); } return STATUS_OK; @@ -4443,8 +4780,12 @@ void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); _registry->saveValues(); - if (!_autoSaveOnExit) return; - if (_state == GAME_FROZEN) return; + if (!_autoSaveOnExit) { + return; + } + if (_state == GAME_FROZEN) { + return; + } saveGame(_autoSaveSlot, "autosave", true); } diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 03f9929eee..3bad8f6012 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -84,9 +84,13 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { const char *str = val->getString(); char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') temp += ('a' - 'A'); + if (temp >= 'A' && temp <= 'Z') { + temp += ('a' - 'A'); + } vKey = (int)temp; - } else vKey = val->getInt(); + } else { + vKey = val->getInt(); + } warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; // Uint8 *state = SDL_GetKeyboardState(NULL); @@ -95,9 +99,9 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * stack->pushBool(isDown); return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } @@ -122,7 +126,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { key[0] = (char)_currentCharCode; key[1] = '\0'; _scValue->setString(key); - } else _scValue->setString(""); + } else { + _scValue->setString(""); + } return _scValue; } @@ -165,9 +171,9 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { else if (strcmp(name, "IsControl") == 0) { _scValue->setBool(_currentControl); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -255,7 +261,9 @@ bool BaseKeyboardState::isAltDown() { ////////////////////////////////////////////////////////////////////////// uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) return 0; + if (event->type != Common::EVENT_KEYDOWN) { + return 0; + } switch (event->kbd.keycode) { case Common::KEYCODE_KP_ENTER: diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 0821c9325b..0873f090d0 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -58,11 +58,14 @@ void BaseNamedObject::setName(const char *name) { delete[] _name; _name = NULL; - if (name == NULL) + if (name == NULL) { return; + } _name = new char [strlen(name) + 1]; - if (_name != NULL) strcpy(_name, name); + if (_name != NULL) { + strcpy(_name, name); + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 44823acf1a..18619616fe 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -85,8 +85,9 @@ BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { _rotateValid = false; _relativeRotate = 0.0f; - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { _caption[i] = NULL; + } _saveState = true; _nonIntMouseEvents = false; @@ -107,8 +108,9 @@ BaseObject::~BaseObject() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) + if (_gameRef && _gameRef->_activeObject == this) { _gameRef->_activeObject = NULL; + } BaseScriptHolder::cleanup(); delete[] _soundEvent; @@ -137,9 +139,12 @@ bool BaseObject::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7) + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7) { return; + } delete[] _caption[caseVal - 1]; _caption[caseVal - 1] = new char[strlen(caption) + 1]; @@ -152,10 +157,14 @@ void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename ////////////////////////////////////////////////////////////////////////// const char *BaseObject::getCaption(int caseVal) { - if (caseVal == 0) caseVal = 1; - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { return ""; - else return _caption[caseVal - 1]; + } else { + return _caption[caseVal - 1]; + } } @@ -198,8 +207,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetCursor") == 0) { stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -226,8 +238,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursor") == 0) { stack->correctParams(0); - if (!_cursor || !_cursor->getFilename()) stack->pushNULL(); - else stack->pushString(_cursor->getFilename()); + if (!_cursor || !_cursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursor->getFilename()); + } return STATUS_OK; } @@ -237,8 +252,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetCursorObject") == 0) { stack->correctParams(0); - if (!_cursor) stack->pushNULL(); - else stack->pushNative(_cursor, true); + if (!_cursor) { + stack->pushNULL(); + } else { + stack->pushNative(_cursor, true); + } return STATUS_OK; } @@ -249,8 +267,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "HasCursor") == 0) { stack->correctParams(0); - if (_cursor) stack->pushBool(true); - else stack->pushBool(false); + if (_cursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -272,10 +293,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "LoadSound") == 0) { stack->correctParams(1); const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) + if (DID_SUCCEED(playSFX(filename, false, false))) { stack->pushBool(true); - else + } else { stack->pushBool(false); + } return STATUS_OK; } @@ -299,15 +321,20 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta looping = val1->getBool(); loopStart = val2->getInt(); } else { - if (val1->isNULL()) filename = NULL; - else filename = val1->getString(); + if (val1->isNULL()) { + filename = NULL; + } else { + filename = val1->getString(); + } looping = val2->isNULL() ? false : val2->getBool(); loopStart = val3->getInt(); } - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) { stack->pushBool(false); - else stack->pushBool(true); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -331,8 +358,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta eventName = val2->getString(); } - if (DID_FAIL(playSFX(filename, false, true, eventName))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(playSFX(filename, false, true, eventName))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -342,8 +372,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "StopSound") == 0) { stack->correctParams(0); - if (DID_FAIL(stopSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(stopSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -353,8 +386,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "PauseSound") == 0) { stack->correctParams(0); - if (DID_FAIL(pauseSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(pauseSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -364,8 +400,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "ResumeSound") == 0) { stack->correctParams(0); - if (DID_FAIL(resumeSFX())) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(resumeSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -375,8 +414,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "IsSoundPlaying") == 0) { stack->correctParams(0); - if (_sFX && _sFX->isPlaying()) stack->pushBool(true); - else stack->pushBool(false); + if (_sFX && _sFX->isPlaying()) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -387,8 +429,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setSFXTime(Time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -398,8 +443,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "GetSoundPosition") == 0) { stack->correctParams(0); - if (!_sFX) stack->pushInt(0); - else stack->pushInt(_sFX->getPositionTime()); + if (!_sFX) { + stack->pushInt(0); + } else { + stack->pushInt(_sFX->getPositionTime()); + } return STATUS_OK; } @@ -410,8 +458,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) stack->pushBool(false); - else stack->pushBool(true); + if (DID_FAIL(setSFXVolume(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } return STATUS_OK; } @@ -421,8 +472,11 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "GetSoundVolume") == 0) { stack->correctParams(0); - if (!_sFX) stack->pushInt(_sFXVolume); - else stack->pushInt(_sFX->getVolumePercent()); + if (!_sFX) { + stack->pushInt(_sFXVolume); + } else { + stack->pushInt(_sFX->getVolumePercent()); + } return STATUS_OK; } @@ -470,9 +524,9 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->pushNULL(); return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } @@ -578,8 +632,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scale); + if (_scale < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scale); + } return _scValue; } @@ -587,8 +644,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleX); + if (_scaleX < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleX); + } return _scValue; } @@ -596,8 +656,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) _scValue->setNULL(); - else _scValue->setFloat((double)_scaleY); + if (_scaleY < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleY); + } return _scValue; } @@ -613,8 +676,11 @@ ScValue *BaseObject::scGetProperty(const char *name) { // Rotate ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) _scValue->setNULL(); - else _scValue->setFloat((double)_rotate); + if (!_rotateValid) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_rotate); + } return _scValue; } @@ -663,9 +729,9 @@ ScValue *BaseObject::scGetProperty(const char *name) { else if (strcmp(name, "AccCaption") == 0) { _scValue->setNULL(); return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); } - - else return BaseScriptHolder::scGetProperty(name); } @@ -742,7 +808,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "BlendMode") == 0) { int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) i = BLEND_NORMAL; + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) { + i = BLEND_NORMAL; + } _blendMode = (TSpriteBlendMode)i; return STATUS_OK; } @@ -751,8 +819,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // Scale ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) _scale = -1; - else _scale = (float)value->getFloat(); + if (value->isNULL()) { + _scale = -1; + } else { + _scale = (float)value->getFloat(); + } return STATUS_OK; } @@ -760,8 +831,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // ScaleX ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) _scaleX = -1; - else _scaleX = (float)value->getFloat(); + if (value->isNULL()) { + _scaleX = -1; + } else { + _scaleX = (float)value->getFloat(); + } return STATUS_OK; } @@ -769,8 +843,11 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { // ScaleY ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) _scaleY = -1; - else _scaleY = (float)value->getFloat(); + if (value->isNULL()) { + _scaleY = -1; + } else { + _scaleY = (float)value->getFloat(); + } return STATUS_OK; } @@ -817,7 +894,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SoundPanning") == 0) { _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) resetSoundPan(); + if (!_autoSoundPanning) { + resetSoundPan(); + } return STATUS_OK; } @@ -842,9 +921,9 @@ bool BaseObject::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccCaption") == 0) { return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); } - - else return BaseScriptHolder::scSetProperty(name, value); } @@ -856,8 +935,11 @@ const char *BaseObject::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::showCursor() { - if (_cursor) return _gameRef->drawCursor(_cursor); - else return STATUS_FAILED; + if (_cursor) { + return _gameRef->drawCursor(_cursor); + } else { + return STATUS_FAILED; + } } @@ -871,8 +953,9 @@ bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { bool BaseObject::persist(BasePersistenceManager *persistMgr) { BaseScriptHolder::persist(persistMgr); - for (int i = 0; i < 7; i++) + for (int i = 0; i < 7; i++) { persistMgr->transfer(TMEMBER(_caption[i])); + } persistMgr->transfer(TMEMBER(_activeCursor)); persistMgr->transfer(TMEMBER(_alphaColor)); persistMgr->transfer(TMEMBER(_autoSoundPanning)); @@ -936,7 +1019,9 @@ bool BaseObject::setCursor(const char *filename) { delete _cursor; _cursor = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } @@ -948,7 +1033,9 @@ bool BaseObject::setActiveCursor(const char *filename) { delete _activeCursor; _activeCursor = NULL; return STATUS_FAILED; - } else return STATUS_OK; + } else { + return STATUS_OK; + } } @@ -983,16 +1070,24 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const if (_gameRef->_editorMode || _sFXStart) { _sFX->setVolumePercent(_sFXVolume); _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) _sFXStart = 0; + if (!_gameRef->_editorMode) { + _sFXStart = 0; + } } if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } return _sFX->play(looping); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } - if (filename == NULL) return STATUS_FAILED; + if (filename == NULL) { + return STATUS_FAILED; + } // create new sound delete _sFX; @@ -1007,9 +1102,13 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (playNow) { setSoundEvent(eventName); - if (loopStart) _sFX->setLoopStart(loopStart); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } return _sFX->play(looping); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } else { delete _sFX; _sFX = NULL; @@ -1027,37 +1126,51 @@ bool BaseObject::stopSFX(bool deleteSound) { _sFX = NULL; } return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::pauseSFX() { - if (_sFX) return _sFX->pause(); - else return STATUS_FAILED; + if (_sFX) { + return _sFX->pause(); + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::resumeSFX() { - if (_sFX) return _sFX->resume(); - else return STATUS_FAILED; + if (_sFX) { + return _sFX->resume(); + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::setSFXTime(uint32 time) { _sFXStart = time; - if (_sFX && _sFX->isPlaying()) return _sFX->setPositionTime(time); - else return STATUS_OK; + if (_sFX && _sFX->isPlaying()) { + return _sFX->setPositionTime(time); + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool BaseObject::setSFXVolume(int volume) { _sFXVolume = volume; - if (_sFX) return _sFX->setVolumePercent(volume); - else return STATUS_OK; + if (_sFX) { + return _sFX->setVolumePercent(volume); + } else { + return STATUS_OK; + } } @@ -1070,7 +1183,9 @@ bool BaseObject::updateSounds() { } } - if (_sFX) updateOneSound(_sFX); + if (_sFX) { + updateOneSound(_sFX); + } return STATUS_OK; } @@ -1080,8 +1195,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) { bool Ret = STATUS_OK; if (sound) { - if (_autoSoundPanning) + if (_autoSoundPanning) { Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + } Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } @@ -1090,8 +1206,9 @@ bool BaseObject::updateOneSound(BaseSound *sound) { ////////////////////////////////////////////////////////////////////////// bool BaseObject::resetSoundPan() { - if (!_sFX) return STATUS_OK; - else { + if (!_sFX) { + return STATUS_OK; + } else { return _sFX->setPan(0.0f); } } @@ -1115,7 +1232,9 @@ void BaseObject::setSoundEvent(const char *eventName) { _soundEvent = NULL; if (eventName) { _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) strcpy(_soundEvent, eventName); + if (_soundEvent) { + strcpy(_soundEvent, eventName); + } } } diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 12ed67ba2a..98d77f4ed5 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -50,7 +50,9 @@ BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseParser::~BaseParser() { - if (_whiteSpace != NULL) delete[] _whiteSpace; + if (_whiteSpace != NULL) { + delete[] _whiteSpace; + } } @@ -71,8 +73,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d skipCharacters(buf, _whiteSpace); } - if (! **buf) // at end of file + if (! **buf) { // at end of file return PARSERR_EOF; + } // find the token. // for now just use brute force. Improve later. @@ -89,7 +92,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d char *p = strchr(*buf, '\n'); if (p && p > *buf) { strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else strcpy(_lastOffender, ""); + } else { + strcpy(_lastOffender, ""); + } return PARSERR_TOKENNOTFOUND; } @@ -102,10 +107,11 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d skipCharacters(buf, _whiteSpace); // get optional data - if (**buf == '=') // An assignment rather than a command/object. + if (**buf == '=') { // An assignment rather than a command/object. *data = getAssignmentText(buf); - else + } else { *data = getSubText(buf, '{', '}'); + } return tokens->id; } @@ -113,7 +119,9 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d ////////////////////////////////////////////////////////////////////// int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { - if (!*buf) return PARSERR_TOKENNOTFOUND; + if (!*buf) { + return PARSERR_TOKENNOTFOUND; + } _gameRef->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); @@ -124,9 +132,12 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { void BaseParser::skipCharacters(char **buf, const char *toSkip) { char ch; while ((ch = **buf) != 0) { - if (ch == '\n') _parserLine++; - if (strchr(toSkip, ch) == NULL) + if (ch == '\n') { + _parserLine++; + } + if (strchr(toSkip, ch) == NULL) { return; + } ++*buf; // skip this character } // we must be at the end of the buffer if we get here @@ -135,8 +146,9 @@ void BaseParser::skipCharacters(char **buf, const char *toSkip) { ////////////////////////////////////////////////////////////////////// char *BaseParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) + if (**buf == 0 || **buf != open) { return 0; + } ++*buf; // skip opening delimiter char *result = *buf; @@ -144,11 +156,13 @@ char *BaseParser::getSubText(char **buf, char open, char close) { char theChar; long skip = 1; - if (open == close) // we cant nest identical delimiters + if (open == close) { // we cant nest identical delimiters open = 0; + } while ((theChar = **buf) != 0) { - if (theChar == open) + if (theChar == open) { ++skip; + } if (theChar == close) { if (--skip == 0) { **buf = 0; // null terminate the result string @@ -176,13 +190,15 @@ char *BaseParser::getAssignmentText(char **buf) { char theChar; while ((theChar = **buf) != 0) { - if (theChar <= 0x20) // space and control chars + if (theChar <= 0x20) { // space and control chars break; + } ++*buf; } - **buf = 0; // null terminate it - if (theChar) // skip the terminator + **buf = 0; // null terminate it + if (theChar) { // skip the terminator ++*buf; + } } return result; @@ -195,10 +211,16 @@ char *BaseParser::getToken(char **buf) { static char token[100]; char *b = *buf, * t = token; while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) b++; + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { + b++; + } if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) b++; - else break; + while (*b && *b != '\n' && *b != 13 && *b != 10) { + b++; + } + else { + break; + } } if (*b == '\'') { @@ -207,7 +229,9 @@ char *BaseParser::getToken(char **buf) { *t++ = *b++; } *t++ = 0; - if (*b == '\'') b++; + if (*b == '\'') { + b++; + } } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || *b == '%' || *b == ':' || *b == '{' || *b == '}') { *t++ = *b++; @@ -265,7 +289,9 @@ int BaseParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { char *t = getToken(buf); - if (strcmp(t, tok)) return; // Error + if (strcmp(t, tok)) { + return; // Error + } } @@ -299,7 +325,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { list[i++] = atoi(in); in += strspn(in, "0123456789+-"); in += strspn(in, " \t\n\f"); - if (*in != ',') break; + if (*in != ',') { + break; + } in++; in += strspn(in, " \t\n\f"); } @@ -339,7 +367,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { list[i++] = (float)atof(in); in += strspn(in, "0123456789.eE+-"); in += strspn(in, " \t\n\f"); - if (*in != ',') break; + if (*in != ',') { + break; + } in++; in += strspn(in, " \t\n\f"); } @@ -414,7 +444,9 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { break; } } - if (*format) format++; + if (*format) { + format++; + } } else if (*format == ' ') { format++; in += strspn(in, " \t\n\f"); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index cf7deb2970..d8f928b683 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -181,7 +181,9 @@ bool BasePersistenceManager::getSaveExists(int slot) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::initSave(const char *desc) { - if (!desc) return STATUS_FAILED; + if (!desc) { + return STATUS_FAILED; + } cleanup(); _saving = true; @@ -232,7 +234,9 @@ bool BasePersistenceManager::initSave(const char *desc) { thumbnailOK = true; } } - if (!thumbnailOK) putDWORD(0); + if (!thumbnailOK) { + putDWORD(0); + } // in any case, destroy the cached thumbnail once used delete _gameRef->_cachedThumbnail; @@ -288,9 +292,13 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { _thumbnailData = new byte[_thumbnailDataSize]; if (_thumbnailData) { getBytes(_thumbnailData, _thumbnailDataSize); - } else _thumbnailDataSize = 0; + } else { + _thumbnailDataSize = 0; + } } - } else _savedVerBuild = 35; // last build with ver1 savegames + } else { + _savedVerBuild = 35; // last build with ver1 savegames + } uint32 dataOffset = getDWORD(); @@ -379,16 +387,18 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { _saveStream->write(buffer, size); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { _loadStream->read(buffer, size); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } @@ -407,8 +417,9 @@ uint32 BasePersistenceManager::getDWORD() { ////////////////////////////////////////////////////////////////////////// void BasePersistenceManager::putString(const Common::String &val) { - if (!val.size()) putString("(null)"); - else { + if (!val.size()) { + putString("(null)"); + } else { _saveStream->writeUint32LE(val.size()); _saveStream->writeString(val); } @@ -440,7 +451,9 @@ char *BasePersistenceManager::getString() { if (!strcmp(ret, "(null)")) { delete[] ret; return NULL; - } else return ret; + } else { + return ret; + } } bool BasePersistenceManager::putTimeDate(const TimeDate &t) { @@ -510,13 +523,15 @@ double BasePersistenceManager::getDouble() { bool BasePersistenceManager::transfer(const char *name, bool *val) { if (_saving) { _saveStream->writeByte(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readByte(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -527,13 +542,15 @@ bool BasePersistenceManager::transfer(const char *name, bool *val) { bool BasePersistenceManager::transfer(const char *name, int *val) { if (_saving) { _saveStream->writeSint32LE(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -544,13 +561,15 @@ bool BasePersistenceManager::transfer(const char *name, int *val) { bool BasePersistenceManager::transfer(const char *name, uint32 *val) { if (_saving) { _saveStream->writeUint32LE(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readUint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -561,13 +580,15 @@ bool BasePersistenceManager::transfer(const char *name, uint32 *val) { bool BasePersistenceManager::transfer(const char *name, float *val) { if (_saving) { putFloat(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = getFloat(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -578,13 +599,15 @@ bool BasePersistenceManager::transfer(const char *name, float *val) { bool BasePersistenceManager::transfer(const char *name, double *val) { if (_saving) { putDouble(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = getDouble(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -667,7 +690,9 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { delete[] str; return STATUS_FAILED; } - if (str) val.push_back(str); + if (str) { + val.push_back(str); + } delete[] str; } } @@ -680,13 +705,15 @@ bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { bool BasePersistenceManager::transfer(const char *name, byte *val) { if (_saving) { _saveStream->writeByte(*val); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { *val = _loadStream->readByte(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -700,16 +727,18 @@ bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { _saveStream->writeSint32LE(val->top); _saveStream->writeSint32LE(val->right); _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->left = _loadStream->readSint32LE(); val->top = _loadStream->readSint32LE(); val->right = _loadStream->readSint32LE(); val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -721,14 +750,16 @@ bool BasePersistenceManager::transfer(const char *name, Point32 *val) { if (_saving) { _saveStream->writeSint32LE(val->x); _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->x = _loadStream->readSint32LE(); val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -740,14 +771,16 @@ bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { if (_saving) { putFloat(val->x); putFloat(val->y); - if (_saveStream->err()) + if (_saveStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } else { val->x = getFloat(); val->y = getFloat(); - if (_loadStream->err()) + if (_loadStream->err()) { return STATUS_FAILED; + } return STATUS_OK; } } @@ -779,13 +812,17 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { ////////////////////////////////////////////////////////////////////////// bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) return true; + if (_saving) { + return true; + } // it's ok if we are same or newer than the saved game if (verMajor > _savedVerMajor || (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) return false; + ) { + return false; + } return true; } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index d672e39c6b..bf38adb578 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -34,14 +34,18 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { _text = new char [strlen(text) + 1]; - if (_text) strcpy(_text, text); + if (_text) { + strcpy(_text, text); + } _startTime = _gameRef->_currentTime; } ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::~BaseQuickMsg() { - if (_text) delete[] _text; + if (_text) { + delete[] _text; + } } diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index f88de2ab91..67cda44ece 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -60,7 +60,9 @@ BaseRegion::~BaseRegion() { ////////////////////////////////////////////////////////////////////////// void BaseRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) delete _points[i]; + for (int i = 0; i < _points.getSize(); i++) { + delete _points[i]; + } _points.removeAll(); BasePlatform::setRectEmpty(&_rect); @@ -76,7 +78,9 @@ bool BaseRegion::createRegion() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) return false; + if (_points.getSize() < 3) { + return false; + } Point32 pt; pt.x = x; @@ -88,8 +92,11 @@ bool BaseRegion::pointInRegion(int x, int y) { rect.top = y - 1; rect.bottom = y + 2; - if (BasePlatform::ptInRect(&_rect, pt)) return ptInPolygon(x, y); - else return false; + if (BasePlatform::ptInRect(&_rect, pt)) { + return ptInPolygon(x, y); + } else { + return false; + } } @@ -105,7 +112,9 @@ bool BaseRegion::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer, true))) _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + } delete[] buffer; @@ -153,13 +162,17 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { int i; - for (i = 0; i < _points.getSize(); i++) delete _points[i]; + for (i = 0; i < _points.getSize(); i++) { + delete _points[i]; + } _points.removeAll(); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) cmd = PARSERR_GENERIC; + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } break; case TOKEN_NAME: @@ -240,7 +253,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -260,7 +275,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -280,7 +297,9 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta createRegion(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -298,12 +317,14 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta val->setProperty("X", _points[index]->x); val->setProperty("Y", _points[index]->y); } - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } @@ -341,9 +362,9 @@ ScValue *BaseRegion::scGetProperty(const char *name) { else if (strcmp(name, "NumPoints") == 0) { _scValue->setInt(_points.getSize()); return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -363,9 +384,9 @@ bool BaseRegion::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "Active") == 0) { _active = value->getBool(); return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } @@ -377,8 +398,11 @@ const char *BaseRegion::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) buffer->putTextIndent(indent, "REGION {\n"); - else buffer->putTextIndent(indent, "%s {\n", nameOverride); + if (!nameOverride) { + buffer->putTextIndent(indent, "REGION {\n"); + } else { + buffer->putTextIndent(indent, "%s {\n", nameOverride); + } buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); @@ -395,7 +419,9 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } - if (_scProp) _scProp->saveAsText(buffer, indent + 2); + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } buffer->putTextIndent(indent, "}\n\n"); @@ -425,7 +451,9 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) return false; + if (_points.getSize() < 3) { + return false; + } int counter = 0; double xinters; @@ -446,8 +474,9 @@ bool BaseRegion::ptInPolygon(int x, int y) { if (p.x <= MAX(p1.x, p2.x)) { if (p1.y != p2.y) { xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) + if (p1.x == p2.x || p.x <= xinters) { counter++; + } } } } @@ -455,17 +484,19 @@ bool BaseRegion::ptInPolygon(int x, int y) { p1 = p2; } - if (counter % 2 == 0) + if (counter % 2 == 0) { return false; - else + } else { return true; + } } ////////////////////////////////////////////////////////////////////////// bool BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) BasePlatform::setRectEmpty(rect); - else { + if (_points.getSize() == 0) { + BasePlatform::setRectEmpty(rect); + } else { int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; for (int i = 0; i < _points.getSize(); i++) { @@ -483,7 +514,9 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) return STATUS_OK; + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { + return STATUS_OK; + } cleanup(); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 7eb2685746..441d00c05b 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -61,8 +61,12 @@ AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString & bool found = false; ret = getValue(_localValues, subKey, key, found); - if (!found) ret = getValue(_values, subKey, key, found); - if (!found) ret = init; + if (!found) { + ret = getValue(_values, subKey, key, found); + } + if (!found) { + ret = init; + } return ret; } @@ -105,8 +109,11 @@ int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int i } } AnsiString val = readString(subKey, key, ""); - if (val.empty()) return init; - else return atoi(val.c_str()); + if (val.empty()) { + return init; + } else { + return atoi(val.c_str()); + } } @@ -166,8 +173,11 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - if (local) loadXml("settings.xml", _localValues); - else loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + if (local) { + loadXml("settings.xml", _localValues); + } else { + loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + } } ////////////////////////////////////////////////////////////////////////// @@ -186,12 +196,15 @@ void BaseRegistry::setBasePath(const char *basePath) { AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { found = false; PathValueMap::iterator it = values.find(path); - if (it == values.end()) return ""; + if (it == values.end()) { + return ""; + } KeyValuePair pairs = (*it)._value; KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) return ""; - else { + if (keyIt == pairs.end()) { + return ""; + } else { found = true; return (*keyIt)._value; } @@ -200,11 +213,14 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) return; + if (!doc.LoadFile()) { + return; + } TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) + if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) return; + } for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { @@ -247,8 +263,9 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { Common::DumpFile stream; stream.open(fileName.c_str()); - if (!stream.isOpen()) return; - else { + if (!stream.isOpen()) { + return; + } else { stream.write(printer.CStr(), printer.Size()); stream.close(); } diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index b63f280f05..5007b65422 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -60,7 +60,9 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { } BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) return STATUS_FAILED; + if (!screenshot) { + return STATUS_FAILED; + } // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d274f9df73..b90b4dc60a 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -75,10 +75,13 @@ void BaseScriptHolder::setFilename(const char *filename) { delete[] _filename; _filename = NULL; } - if (filename == NULL) + if (filename == NULL) { return; + } _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) strcpy(_filename, filename); + if (_filename != NULL) { + strcpy(_filename, filename); + } } @@ -97,7 +100,9 @@ bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { } } } - if (numHandlers > 0 && unbreakable) _gameRef->_scEngine->tickUnbreakable(); + if (numHandlers > 0 && unbreakable) { + _gameRef->_scEngine->tickUnbreakable(); + } return ret; } @@ -134,8 +139,11 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t bool ret; ret = applyEvent(val->getString()); - if (DID_SUCCEED(ret)) stack->pushBool(true); - else stack->pushBool(false); + if (DID_SUCCEED(ret)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -206,7 +214,9 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t stack->pushBool(ret); return STATUS_OK; - } else return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } } @@ -236,9 +246,9 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { else if (strcmp(name, "Filename") == 0) { _scValue->setString(_filename); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -250,7 +260,9 @@ bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { if (strcmp(name, "Name") == 0) { setName(value->getString()); return STATUS_OK; - } else return BaseScriptable::scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } } @@ -334,7 +346,9 @@ bool BaseScriptHolder::removeScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleEvent(const char *EventName) { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { + return true; + } } return false; } @@ -343,7 +357,9 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleMethod(const char *MethodName) { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) return true; + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { + return true; + } } return false; } @@ -382,15 +398,21 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { case TOKEN_NAME: delete[] propName; propName = new char[strlen((char *)params) + 1]; - if (propName) strcpy(propName, (char *)params); - else cmd = PARSERR_GENERIC; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; case TOKEN_VALUE: delete[] propValue; propValue = new char[strlen((char *)params) + 1]; - if (propValue) strcpy(propValue, (char *)params); - else cmd = PARSERR_GENERIC; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } break; } @@ -430,8 +452,9 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) { _scripts[i]->_freezable = freezable; + } } diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 4059abde3d..ad89b63d65 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -38,8 +38,11 @@ IMPLEMENT_PERSISTENT(BaseScriptable, false) BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { _refCount = 0; - if (noValue) _scValue = NULL; - else _scValue = new ScValue(_gameRef); + if (noValue) { + _scValue = NULL; + } else { + _scValue = new ScValue(_gameRef); + } _persistable = persistable; @@ -74,17 +77,27 @@ bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi ////////////////////////////////////////////////////////////////////////// ScValue *BaseScriptable::scGetProperty(const char *name) { - if (!_scProp) _scProp = new ScValue(_gameRef); - if (_scProp) return _scProp->getProp(name); - else return NULL; + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->getProp(name); + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { - if (!_scProp) _scProp = new ScValue(_gameRef); - if (_scProp) return _scProp->setProp(name, value); - else return STATUS_FAILED; + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->setProp(name, value); + } else { + return STATUS_FAILED; + } } @@ -150,9 +163,13 @@ bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int BaseScriptable::scCompare(BaseScriptable *val) { - if (this < val) return -1; - else if (this > val) return 1; - else return 0; + if (this < val) { + return -1; + } else if (this > val) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index c2e57f9fd6..2fda638665 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -89,8 +89,9 @@ void BaseSprite::setDefaults() { void BaseSprite::cleanup() { BaseScriptHolder::cleanup(); - for (int i = 0; i < _frames.getSize(); i++) + for (int i = 0; i < _frames.getSize(); i++) { delete _frames[i]; + } _frames.removeAll(); delete[] _editorBgFile; @@ -103,7 +104,9 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { GetCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return STATUS_OK; + } // move owner if allowed to if (_changed && _owner && _owner->_movable) { @@ -125,8 +128,11 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); - if (_gameRef->_debugDebugMode) return loadFile("invalid_debug.bmp", lifeTime, cacheType); - else return loadFile("invalid.bmp", lifeTime, cacheType); + if (_gameRef->_debugDebugMode) { + return loadFile("invalid_debug.bmp", lifeTime, cacheType); + } else { + return loadFile("invalid.bmp", lifeTime, cacheType); + } } else { _gameRef->_fileManager->closeFile(file); file = NULL; @@ -154,7 +160,9 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c } else { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { + _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + } delete[] buffer; } } @@ -262,7 +270,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa if (_gameRef->_editorMode) { delete[] _editorBgFile; _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) strcpy(_editorBgFile, (char *)params); + if (_editorBgFile) { + strcpy(_editorBgFile, (char *)params); + } } break; @@ -282,7 +292,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa case TOKEN_FRAME: { int FrameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) FrameLifeTime = -1; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) { + FrameLifeTime = -1; + } frame = new BaseFrame(_gameRef); @@ -294,7 +306,9 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa _frames.add(frame); frameCount++; - if (_currentFrame == -1) _currentFrame = 0; + if (_currentFrame == -1) { + _currentFrame = 0; + } } break; @@ -316,8 +330,11 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa ////////////////////////////////////////////////////////////////////// void BaseSprite::reset() { - if (_frames.getSize() > 0) _currentFrame = 0; - else _currentFrame = -1; + if (_frames.getSize() > 0) { + _currentFrame = 0; + } else { + _currentFrame = -1; + } killAllSounds(); @@ -331,11 +348,16 @@ void BaseSprite::reset() { bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - if (_currentFrame == -1) return false; + if (_currentFrame == -1) { + return false; + } uint32 timer; - if (_owner && _owner->_freezable) timer = _gameRef->_timer; - else timer = _gameRef->_liveTimer; + if (_owner && _owner->_freezable) { + timer = _gameRef->_timer; + } else { + timer = _gameRef->_liveTimer; + } int lastFrame = _currentFrame; @@ -343,7 +365,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { if (_currentFrame < _frames.getSize() - 1) { _currentFrame++; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + if (_continuous) { + _canBreak = (_currentFrame == _frames.getSize() - 1); + } } else { if (_looping) { _currentFrame = 0; @@ -362,7 +386,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { if (_lastFrameTime == 0) { _lastFrameTime = timer; _changed = true; - if (_continuous) _canBreak = (_currentFrame == _frames.getSize() - 1); + if (_continuous) { + _canBreak = (_currentFrame == _frames.getSize() - 1); + } } if (_changed) { @@ -381,7 +407,9 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return STATUS_OK; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return STATUS_OK; + } // on change... if (_changed) { @@ -400,18 +428,27 @@ bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) return NULL; - BaseFrame *Frame = _frames[_currentFrame]; - if (Frame && Frame->_subframes.getSize() > 0) { - BaseSubFrame *Subframe = Frame->_subframes[0]; - if (Subframe) return Subframe->_surface; - else return NULL; - } else return NULL; + if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + return NULL; + } + BaseFrame *frame = _frames[_currentFrame]; + if (frame && frame->_subframes.getSize() > 0) { + BaseSubFrame *subframe = frame->_subframes[0]; + if (subframe) { + return subframe->_surface; + } else { + return NULL; + } + } else { + return NULL; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } BasePlatform::setRectEmpty(rect); for (int i = 0; i < _frames.getSize(); i++) { @@ -434,12 +471,14 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { if (_streamed) { buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - if (_streamedKeepLoaded) + if (_streamedKeepLoaded) { buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } } - if (_editorMuted) + if (_editorMuted) { buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + } if (_editorBgFile) { buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); @@ -514,7 +553,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (Index < 0 || Index >= _frames.getSize()) { script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); stack->pushNULL(); - } else stack->pushNative(_frames[Index], true); + } else { + stack->pushNative(_frames[Index], true); + } return STATUS_OK; } @@ -523,17 +564,19 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "DeleteFrame") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); - if (Val->isInt()) { - int Index = Val->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", Index); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= _frames.getSize()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); } } else { - BaseFrame *Frame = (BaseFrame *)Val->getNative(); + BaseFrame *frame = (BaseFrame *)val->getNative(); for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i] == Frame) { - if (i == _currentFrame) _lastFrameTime = 0; + if (_frames[i] == frame) { + if (i == _currentFrame) { + _lastFrameTime = 0; + } delete _frames[i]; _frames.removeAt(i); break; @@ -561,7 +604,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) filename = val->getString(); + if (!val->isNULL()) { + filename = val->getString(); + } BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { @@ -569,7 +614,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (DID_SUCCEED(sub->setSurface(filename))) { sub->setDefaultRect(); frame->_subframes.add(sub); - } else delete sub; + } else { + delete sub; + } } _frames.add(frame); @@ -583,24 +630,31 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "InsertFrame") == 0) { stack->correctParams(2); int index = stack->pop()->getInt(); - if (index < 0) + if (index < 0) { index = 0; + } ScValue *val = stack->pop(); const char *filename = NULL; - if (!val->isNULL()) + if (!val->isNULL()) { filename = val->getString(); + } BaseFrame *frame = new BaseFrame(_gameRef); if (filename != NULL) { BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) frame->_subframes.add(sub); - else delete sub; + if (DID_SUCCEED(sub->setSurface(filename))) { + frame->_subframes.add(sub); + } else { + delete sub; + } } - if (index >= _frames.getSize()) + if (index >= _frames.getSize()) { _frames.add(frame); - else _frames.insertAt(index, frame); + } else { + _frames.insertAt(index, frame); + } stack->pushNative(frame, true); return STATUS_OK; @@ -624,9 +678,9 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta _paused = false; stack->pushNULL(); return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); } @@ -678,8 +732,11 @@ ScValue *BaseSprite::scGetProperty(const char *name) { // Owner (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) _scValue->setNULL(); - else _scValue->setNative(_owner, true); + if (_owner == NULL) { + _scValue->setNULL(); + } else { + _scValue->setNative(_owner, true); + } return _scValue; } @@ -697,9 +754,9 @@ ScValue *BaseSprite::scGetProperty(const char *name) { else if (strcmp(name, "Paused") == 0) { _scValue->setBool(_paused); return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); } - - else return BaseScriptHolder::scGetProperty(name); } @@ -731,9 +788,9 @@ bool BaseSprite::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "Looping") == 0) { _looping = value->getBool(); return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); } - - else return BaseScriptHolder::scSetProperty(name, value); } @@ -746,8 +803,9 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { for (int i = 0; i < _frames.getSize(); i++) { - if (_frames[i]->_sound) + if (_frames[i]->_sound) { _frames[i]->_sound->stop(); + } } return STATUS_OK; } diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 58cf046436..18a18fe0ba 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -51,8 +51,9 @@ BaseStringTable::~BaseStringTable() { ////////////////////////////////////////////////////////////////////////// bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) + if (key == NULL || val == NULL) { return STATUS_FAILED; + } if (scumm_stricmp(key, "@right-to-left") == 0) { _gameRef->_textRTL = true; @@ -63,8 +64,9 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup finalKey.toLowercase(); StringsIter it = _strings.find(finalKey); - if (it != _strings.end() && reportDuplicities) + if (it != _strings.end() && reportDuplicities) { _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + } _strings[finalKey] = val; @@ -73,12 +75,14 @@ bool BaseStringTable::addString(const char *key, const char *val, bool reportDup ////////////////////////////////////////////////////////////////////////// char *BaseStringTable::getKey(const char *str) const { - if (str == NULL || str[0] != '/') + if (str == NULL || str[0] != '/') { return NULL; + } const char *value = strchr(str + 1, '/'); - if (value == NULL) + if (value == NULL) { return NULL; + } char *key = new char[value - str]; Common::strlcpy(key, str + 1, (size_t)(value - str)); @@ -107,12 +111,14 @@ char *BaseStringTable::getKey(const char *str) const { ////////////////////////////////////////////////////////////////////////// void BaseStringTable::expand(char **str) const { - if (str == NULL || *str == NULL || *str[0] != '/') + if (str == NULL || *str == NULL || *str[0] != '/') { return; + } char *value = strchr(*str + 1, '/'); - if (value == NULL) + if (value == NULL) { return; + } char *key = new char[value - *str]; Common::strlcpy(key, *str + 1, (size_t)(value - *str)); @@ -136,19 +142,22 @@ void BaseStringTable::expand(char **str) const { delete[] *str; *str = newStr; - if (strlen(*str) > 0 && *str[0] == '/') + if (strlen(*str) > 0 && *str[0] == '/') { expand(str); + } } ////////////////////////////////////////////////////////////////////////// const char *BaseStringTable::expandStatic(const char *string) const { - if (string == NULL || string[0] == '\0' || string[0] != '/') + if (string == NULL || string[0] == '\0' || string[0] != '/') { return string; + } const char *value = strchr(string + 1, '/'); - if (value == NULL) + if (value == NULL) { return string; + } char *key = new char[value - string]; Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); @@ -167,10 +176,11 @@ const char *BaseStringTable::expandStatic(const char *string) const { delete[] key; - if (strlen(newStr) > 0 && newStr[0] == '/') + if (strlen(newStr) > 0 && newStr[0] == '/') { return expandStatic(newStr); - else + } else { return newStr; + } } @@ -178,8 +188,9 @@ const char *BaseStringTable::expandStatic(const char *string) const { bool BaseStringTable::loadFile(const char *filename, bool clearOld) { _gameRef->LOG(0, "Loading string table..."); - if (clearOld) + if (clearOld) { _strings.clear(); + } uint32 size; byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); @@ -197,27 +208,33 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { //_gameRef->_textEncoding = TEXT_ANSI; _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); } - } else _gameRef->_textEncoding = TEXT_ANSI; + } else { + _gameRef->_textEncoding = TEXT_ANSI; + } uint32 lineLength = 0; while (pos < size) { lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') { lineLength++; + } uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); char *line = new char[realLength + 1]; Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); char *value = strchr(line, '\t'); - if (value == NULL) value = strchr(line, ' '); + if (value == NULL) { + value = strchr(line, ' '); + } if (line[0] != ';') { if (value != NULL) { value[0] = '\0'; value++; for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') + if (value[i] == '|') { value[i] = '\n'; + } } addString(line, value, clearOld); } else if (line[0] != '\0') { diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 523bbed866..e8290ee659 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -67,7 +67,9 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { ////////////////////////////////////////////////////////////////////////// BaseSubFrame::~BaseSubFrame() { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } delete[] _surfaceFilename; _surfaceFilename = NULL; } @@ -181,12 +183,17 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { } if (surfaceFile != NULL) { - if (custoTrans) setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - else setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + if (custoTrans) { + setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + } else { + setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } } _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) _transparent = BYTETORGBA(r, g, b, 0xFF); + if (custoTrans) { + _transparent = BYTETORGBA(r, g, b, 0xFF); + } /* if (_surface == NULL) @@ -195,8 +202,11 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { return STATUS_FAILED; } */ - if (BasePlatform::isRectEmpty(&rect)) setDefaultRect(); - else _rect = rect; + if (BasePlatform::isRectEmpty(&rect)) { + setDefaultRect(); + } else { + _rect = rect; + } return STATUS_OK; } @@ -204,7 +214,9 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) return STATUS_OK; + if (!_surface) { + return STATUS_OK; + } if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { @@ -213,18 +225,25 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); } } - if (_gameRef->_suspendedRendering) return STATUS_OK; + if (_gameRef->_suspendedRendering) { + return STATUS_OK; + } bool res; //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) alpha = _alpha; + if (_alpha != 0xFFFFFFFF) { + alpha = _alpha; + } if (rotate != 0.0f) { res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); } else { - if (zoomX == 100 && zoomY == 100) res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); - else res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + if (zoomX == 100 && zoomY == 100) { + res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + } else { + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } } return res; @@ -233,7 +252,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl ////////////////////////////////////////////////////////////////////////// bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) return false; + if (!rect) { + return false; + } float ratioX = scaleX / 100.0f; float ratioY = scaleY / 100.0f; @@ -249,52 +270,66 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo ////////////////////////////////////////////////////////////////////////// bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { - if (complete) + if (complete) { buffer->putTextIndent(indent, "SUBFRAME {\n"); + } - if (_surface && _surface->getFileNameStr() != "") + if (_surface && _surface->getFileNameStr() != "") { buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + } - if (_transparent != 0xFFFF00FF) + if (_transparent != 0xFFFF00FF) { buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + } Rect32 rect; BasePlatform::setRectEmpty(&rect); - if (_surface) BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - if (!(rect == _rect)) + if (_surface) { + BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } + if (!(rect == _rect)) { buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + } - if (_hotspotX != 0 || _hotspotY != 0) + if (_hotspotX != 0 || _hotspotY != 0) { buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + } if (_alpha != 0xFFFFFFFF) { buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); } - if (_mirrorX) + if (_mirrorX) { buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + } - if (_mirrorY) + if (_mirrorY) { buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + } - if (_2DOnly) + if (_2DOnly) { buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + } - if (_3DOnly) + if (_3DOnly) { buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + } - if (_decoration) + if (_decoration) { buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + } - if (_editorSelected) + if (_editorSelected) { buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + } BaseClass::saveAsText(buffer, indent + 2); - if (complete) + if (complete) { buffer->putTextIndent(indent, "}\n\n"); + } return STATUS_OK; } @@ -304,7 +339,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple void BaseSubFrame::setDefaultRect() { if (_surface) { BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } else BasePlatform::setRectEmpty(&_rect); + } else { + BasePlatform::setRectEmpty(&_rect); + } } @@ -349,8 +386,11 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS if (strcmp(name, "GetImage") == 0) { stack->correctParams(0); - if (!_surfaceFilename) stack->pushNULL(); - else stack->pushString(_surfaceFilename); + if (!_surfaceFilename) { + stack->pushNULL(); + } else { + stack->pushString(_surfaceFilename); + } return STATUS_OK; } @@ -359,31 +399,37 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetImage") == 0) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); - if (Val->isNULL()) { - if (_surface) _gameRef->_surfaceStorage->removeSurface(_surface); + if (val->isNULL()) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } delete[] _surfaceFilename; _surfaceFilename = NULL; stack->pushBool(true); } else { - const char *filename = Val->getString(); + const char *filename = val->getString(); if (DID_SUCCEED(setSurface(filename))) { setDefaultRect(); stack->pushBool(true); - } else stack->pushBool(false); + } else { + stack->pushBool(false); + } } return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// ScValue *BaseSubFrame::scGetProperty(const char *name) { - if (!_scValue) _scValue = new ScValue(_gameRef); + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// @@ -465,9 +511,9 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { else if (strcmp(name, "HotspotY") == 0) { _scValue->setInt(_hotspotY); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -535,9 +581,9 @@ bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "HotspotY") == 0) { _hotspotY = value->getInt(); return STATUS_OK; + } else { + return BaseScriptable::scSetProperty(name, value); } - - else return BaseScriptable::scSetProperty(name, value); } @@ -570,7 +616,9 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, _keepLoaded = keepLoaded; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -581,8 +629,11 @@ bool BaseSubFrame::setSurfaceSimple() { return STATUS_OK; } _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) return STATUS_OK; - else return STATUS_FAILED; + if (_surface) { + return STATUS_OK; + } else { + return STATUS_FAILED; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index d8ba0cbbce..3d878b1346 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -52,7 +52,9 @@ BaseSurfaceStorage::~BaseSurfaceStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceStorage::cleanup(bool warn) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + if (warn) { + _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + } delete _surfaces[i]; } _surfaces.clear(); @@ -67,7 +69,9 @@ bool BaseSurfaceStorage::initLoop() { _lastCleanupTime = _gameRef->_liveTimer; sortSurfaces(); for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) break; + if (_surfaces[i]->_lifeTime <= 0) { + break; + } if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); @@ -105,17 +109,22 @@ BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK } if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) _gameRef->LOG(0, "Missing image: '%s'", filename); - if (_gameRef->_debugDebugMode) + if (filename) { + _gameRef->LOG(0, "Missing image: '%s'", filename); + } + if (_gameRef->_debugDebugMode) { return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - else + } else { return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } } BaseSurface *surface; surface = _gameRef->_renderer->createSurface(); - if (!surface) return NULL; + if (!surface) { + return NULL; + } if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { delete surface; @@ -171,18 +180,28 @@ int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) return 1; - else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) return -1; + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { + return 1; + } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) { + return -1; + } // sort by validity - if (s1->_valid && !s2->_valid) return -1; - else if (!s1->_valid && s2->_valid) return 1; + if (s1->_valid && !s2->_valid) { + return -1; + } else if (!s1->_valid && s2->_valid) { + return 1; + } // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) return 1; - else if (s1->_lastUsedTime < s2->_lastUsedTime) return -1; - else return 0; + else if (s1->_lastUsedTime > s2->_lastUsedTime) { + return 1; + } else if (s1->_lastUsedTime < s2->_lastUsedTime) { + return -1; + } else { + return 0; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index eeaacd2063..7a78865552 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -57,7 +57,9 @@ bool BaseTransitionMgr::isReady() { ////////////////////////////////////////////////////////////////////////// bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) return STATUS_OK; + if (_state != TRANS_MGR_READY) { + return STATUS_OK; + } if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { _state = TRANS_MGR_READY; @@ -82,7 +84,9 @@ bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { ////////////////////////////////////////////////////////////////////////// bool BaseTransitionMgr::update() { - if (isReady()) return STATUS_OK; + if (isReady()) { + return STATUS_OK; + } if (!_started) { _started = true; @@ -100,8 +104,9 @@ bool BaseTransitionMgr::update() { alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) + if (time > FADE_DURATION) { _state = TRANS_MGR_READY; + } } break; @@ -111,8 +116,9 @@ bool BaseTransitionMgr::update() { alpha = MIN(255, MAX(alpha, 0)); _gameRef->_renderer->fade((uint16)alpha); - if (time > FADE_DURATION) + if (time > FADE_DURATION) { _state = TRANS_MGR_READY; + } } break; default: @@ -120,8 +126,9 @@ bool BaseTransitionMgr::update() { } if (isReady()) { - if (_preserveInteractive) + if (_preserveInteractive) { _gameRef->_interactive = _origInteractive; + } } return STATUS_OK; } diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index bb8504d2f4..7d805aedb5 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -41,7 +41,9 @@ namespace WinterMute { void correctSlashes(char *fileName) { for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') fileName[i] = '/'; + if (fileName[i] == '\\') { + fileName[i] = '/'; + } } } @@ -51,8 +53,9 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) // Absolute path: TODO: Add specific fallbacks here. - if (filename.contains(':')) + if (filename.contains(':')) { error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + } // Relative path: if (filename.contains('\\')) { @@ -132,7 +135,9 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { magic2 = file->readUint32LE(); bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) compressed = true; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) { + compressed = true; + } if (compressed) { uint32 dataOffset, compSize, uncompSize; diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 8282079c86..7bf635b858 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -61,7 +61,9 @@ public: Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); - if (!file) return NULL; + if (!file) { + return NULL; + } // TODO: Cleanup bool compressed = (_compressedLength != 0); diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index f2d2378c6a..b41ae3c1bd 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -64,7 +64,9 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); f->seek((int32)startPos, SEEK_SET); uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) return false; + if (actuallyRead != toRead) { + return false; + } for (uint32 i = 0; i < toRead - 8; i++) if (!memcmp(buf + i, signature, 8)) { @@ -85,8 +87,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool _priority = 0; bool boundToExe = false; Common::SeekableReadStream *stream = file.createReadStream(); - if (!stream) + if (!stream) { return; + } if (searchSignature) { uint32 offset; if (!findPackageSignature(stream, &offset)) { @@ -121,7 +124,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool assert(hdr._numDirs == 1); for (uint32 i = 0; i < hdr._numDirs; i++) { BasePackage *pkg = new BasePackage(); - if (!pkg) return; + if (!pkg) { + return; + } pkg->_fsnode = file; pkg->_boundToExe = boundToExe; @@ -136,7 +141,9 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool delete[] pkgName; pkgName = NULL; - if (!hdr._masterIndex) pkg->_cd = 0; // override CD to fixed disk + if (!hdr._masterIndex) { + pkg->_cd = 0; // override CD to fixed disk + } _packages.push_back(pkg); // read file entries @@ -242,8 +249,9 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common:: upcName.toUppercase(); Common::HashMap::const_iterator it; it = _files.find(upcName.c_str()); - if (it != _files.end()) + if (it != _files.end()) { return it->_value->createReadStream(); + } return NULL; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 0a0d0cac09..e067241589 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -53,7 +53,9 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { bool BaseSaveThumbFile::open(const Common::String &filename) { close(); - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) return STATUS_FAILED; + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { + return STATUS_FAILED; + } char *tempFilename = new char[strlen(filename.c_str()) - 8]; strcpy(tempFilename, filename.c_str() + 9); @@ -70,7 +72,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String slotFilename = pm->getFilenameForSlot(slot); - if (!pm) return STATUS_FAILED; + if (!pm) { + return STATUS_FAILED; + } if (DID_FAIL(pm->initLoad(slotFilename))) { delete pm; @@ -84,7 +88,9 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); _size = pm->_thumbnailDataSize; res = STATUS_OK; - } else res = STATUS_FAILED; + } else { + res = STATUS_FAILED; + } delete pm; return res; @@ -105,7 +111,9 @@ bool BaseSaveThumbFile::close() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) return STATUS_FAILED; + if (!_data || _pos + size > _size) { + return STATUS_FAILED; + } memcpy(buffer, (byte *)_data + _pos, size); _pos += size; @@ -116,7 +124,9 @@ bool BaseSaveThumbFile::read(void *buffer, uint32 size) { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) return STATUS_FAILED; + if (!_data) { + return STATUS_FAILED; + } uint32 newPos = 0; @@ -132,8 +142,11 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) { break; } - if (newPos > _size) return STATUS_FAILED; - else _pos = newPos; + if (newPos > _size) { + return STATUS_FAILED; + } else { + _pos = newPos; + } return STATUS_OK; } diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index d576b834a2..937557f4d7 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -187,7 +187,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { byte *buffer = gameRef->_fileManager->readWholeFile(filename); - if (buffer == NULL) return false; + if (buffer == NULL) { + return false; + } byte *WorkBuffer = buffer; @@ -195,8 +197,9 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { BaseParser parser(gameRef); bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) + if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { ret = true; + } delete[] buffer; return ret; diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index dd6c6da327..9cce8ca9ee 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -91,8 +91,9 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { str = AnsiString((char *)text); } - if (maxLength >= 0 && str.size() > (uint32)maxLength) + if (maxLength >= 0 && str.size() > (uint32)maxLength) { str = Common::String(str.c_str(), (uint32)maxLength); + } //str.substr(0, maxLength); // TODO: Remove int textWidth = 0; @@ -106,9 +107,13 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) return 0; + if (maxLength == 0) { + return 0; + } - if (text == NULL || text[0] == '\0') return _tileHeight; + if (text == NULL || text[0] == '\0') { + return _tileHeight; + } AnsiString str; @@ -118,7 +123,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } else { str = AnsiString((char *)text); } - if (str.empty()) return 0; + if (str.empty()) { + return 0; + } int LineLength = 0; int RealLength = 0; @@ -135,11 +142,15 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli bool new_line = false; bool long_line = false; - if (draw) _gameRef->_renderer->startSpriteBatch(); + if (draw) { + _gameRef->_renderer->startSpriteBatch(); + } while (!done) { if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { - if (draw) _gameRef->_renderer->endSpriteBatch(); + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } return NumLines * _tileHeight; } @@ -170,10 +181,14 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli LineLength += getCharWidth(str[index]); RealLength = LineLength; } - } else LineLength += getCharWidth(str[index]); + } else { + LineLength += getCharWidth(str[index]); + } if ((LineLength > width) || done || new_line) { - if (end < 0) done = true; + if (end < 0) { + done = true; + } int StartX; switch (align) { case TAL_CENTER: @@ -190,12 +205,16 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli break; } for (i = start; i < end + 1; i++) { - if (draw) drawChar(str[i], StartX, y); + if (draw) { + drawChar(str[i], StartX, y); + } StartX += getCharWidth(str[i]); } y += _tileHeight; last_end = end; - if (long_line) end--; + if (long_line) { + end--; + } start = end + 2; index = end + 1; LineLength = 0; @@ -205,7 +224,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } } - if (draw) _gameRef->_renderer->endSpriteBatch(); + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } return NumLines * _tileHeight; } @@ -213,7 +234,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli ////////////////////////////////////////////////////////////////////// void BaseFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) c--; + if (_fontextFix) { + c--; + } int row, col; @@ -223,8 +246,11 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { Rect32 rect; /* l t r b */ int tileWidth; - if (_wholeCell) tileWidth = _tileWidth; - else tileWidth = _widths[c]; + if (_wholeCell) { + tileWidth = _tileWidth; + } else { + tileWidth = _widths[c]; + } BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; @@ -237,7 +263,9 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { handled = true; } } - if (!handled && _subframe) _subframe->_surface->displayTrans(x, y, rect); + if (!handled && _subframe) { + _subframe->_surface->displayTrans(x, y, rect); + } } @@ -253,7 +281,9 @@ bool BaseFontBitmap::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + } delete[] buffer; @@ -408,8 +438,11 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { if (surfaceFile != NULL && !_sprite) { _subframe = new BaseSubFrame(_gameRef); - if (custoTrans) _subframe->setSurface(surfaceFile, false, r, g, b); - else _subframe->setSurface(surfaceFile); + if (custoTrans) { + _subframe->setSurface(surfaceFile, false, r, g, b); + } else { + _subframe->setSurface(surfaceFile); + } } @@ -425,25 +458,32 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { // do we need to modify widths? if (expandWidth != 0) { for (i = 0; i < NUM_CHARACTERS; i++) { - int NewWidth = (int)_widths[i] + expandWidth; - if (NewWidth < 0) NewWidth = 0; + int newWidth = (int)_widths[i] + expandWidth; + if (newWidth < 0) { + newWidth = 0; + } - _widths[i] = (byte)NewWidth; + _widths[i] = (byte)newWidth; } } // handle space character uint32 spaceChar = ' '; - if (_fontextFix) spaceChar--; + if (_fontextFix) { + spaceChar--; + } - if (spaceWidth != 0) _widths[spaceChar] = spaceWidth; - else { + if (spaceWidth != 0) { + _widths[spaceChar] = spaceWidth; + } else { if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; } } } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) _widths[i] = default_width; + for (i = lastWidth; i < NUM_CHARACTERS; i++) { + _widths[i] = default_width; + } } @@ -463,10 +503,11 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_sprite)); persistMgr->transfer(TMEMBER(_widthsFrame)); - if (persistMgr->getIsSaving()) + if (persistMgr->getIsSaving()) { persistMgr->putBytes(_widths, sizeof(_widths)); - else + } else { persistMgr->getBytes(_widths, sizeof(_widths)); + } persistMgr->transfer(TMEMBER(_fontextFix)); @@ -479,7 +520,9 @@ bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int BaseFontBitmap::getCharWidth(byte index) { - if (_fontextFix) index--; + if (_fontextFix) { + index--; + } return _widths[index]; } @@ -495,8 +538,12 @@ bool BaseFontBitmap::getWidths() { } } } - if (surf == NULL && _subframe) surf = _subframe->_surface; - if (!surf || DID_FAIL(surf->startPixelOp())) return STATUS_FAILED; + if (surf == NULL && _subframe) { + surf = _subframe->_surface; + } + if (!surf || DID_FAIL(surf->startPixelOp())) { + return STATUS_FAILED; + } for (int i = 0; i < NUM_CHARACTERS; i++) { @@ -507,14 +554,18 @@ bool BaseFontBitmap::getWidths() { int minCol = -1; for (int row = 0; row < _tileHeight; row++) { for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) continue; + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) { + continue; + } if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { //min_col = col; minCol = MAX(col, minCol); break; } } - if (minCol == _tileWidth - 1) break; + if (minCol == _tileWidth - 1) { + break; + } } _widths[i] = minCol + 1; diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 84c80c73cb..8b4fa74181 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -52,7 +52,9 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { for (int i = 0; i < _fonts.getSize(); i++) { - if (warn) _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + if (warn) { + _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + } delete _fonts[i]; } _fonts.removeAll(); @@ -70,7 +72,9 @@ bool BaseFontStorage::initLoop() { ////////////////////////////////////////////////////////////////////////// BaseFont *BaseFontStorage::addFont(const char *filename) { - if (!filename) return NULL; + if (!filename) { + return NULL; + } for (int i = 0; i < _fonts.getSize(); i++) { if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { @@ -104,7 +108,9 @@ BaseFont *BaseFontStorage::addFont(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::removeFont(BaseFont *font) { - if (!font) return STATUS_FAILED; + if (!font) { + return STATUS_FAILED; + } for (int i = 0; i < _fonts.getSize(); i++) { if (_fonts[i] == font) { @@ -123,7 +129,9 @@ bool BaseFontStorage::removeFont(BaseFont *font) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(false); + if (!persistMgr->getIsSaving()) { + cleanup(false); + } persistMgr->transfer(TMEMBER(_gameRef)); _fonts.persist(persistMgr); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 0a97370cb7..420df58b74 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -57,7 +57,9 @@ BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _fallbackFont = NULL; _deletableFont = NULL; - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } #if 0 _fTFace = NULL; @@ -98,7 +100,9 @@ BaseFontTT::~BaseFontTT(void) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::clearCache() { for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) delete _cachedTexts[i]; + if (_cachedTexts[i]) { + delete _cachedTexts[i]; + } _cachedTexts[i] = NULL; } } @@ -109,12 +113,16 @@ void BaseFontTT::initLoop() { if (_gameRef->_constrainedMemory) { // purge all cached images not used in the last frame for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) continue; + if (_cachedTexts[i] == NULL) { + continue; + } if (!_cachedTexts[i]->_marked) { delete _cachedTexts[i]; _cachedTexts[i] = NULL; - } else _cachedTexts[i]->_marked = false; + } else { + _cachedTexts[i]->_marked = false; + } } } } @@ -123,11 +131,15 @@ void BaseFontTT::initLoop() { int BaseFontTT::getTextWidth(byte *text, int maxLength) { WideString textStr; - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } //text = text.substr(0, MaxLength); // TODO: Remove int textWidth, textHeight; @@ -140,8 +152,11 @@ int BaseFontTT::getTextWidth(byte *text, int maxLength) { int BaseFontTT::getTextHeight(byte *text, int width) { WideString textStr; - if (_gameRef->_textEncoding == TEXT_UTF8) textStr = StringUtil::utf8ToWide((char *)text); - else textStr = StringUtil::ansiToWide((char *)text); + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } int textWidth, textHeight; @@ -153,7 +168,9 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) return; + if (text == NULL || strcmp((char *)text, "") == 0) { + return; + } WideString textStr = (char *)text; @@ -161,8 +178,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); else text = StringUtil::AnsiToWide((char *)Text);*/ - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } //text = text.substr(0, MaxLength); // TODO: Remove BaseRenderer *renderer = _gameRef->_renderer; @@ -199,7 +217,9 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); if (surface) { // write surface to cache - if (_cachedTexts[minIndex] != NULL) delete _cachedTexts[minIndex]; + if (_cachedTexts[minIndex] != NULL) { + delete _cachedTexts[minIndex]; + } _cachedTexts[minIndex] = new BaseCachedTTFontText; _cachedTexts[minIndex]->_surface = surface; @@ -261,10 +281,11 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) // We actually have a TTF + if (_deletableFont) { // We actually have a TTF surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); - else // We are using a fallback, they can't do 32bpp + } else { // We are using a fallback, they can't do 32bpp surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + } uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; @@ -309,7 +330,9 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; + if (!glyph) { + continue; + } textOffset = MAX(textOffset, glyph->GetBearingY()); } @@ -322,10 +345,14 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, wchar_t ch = line->GetText()[i]; GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) continue; + if (!glyph) { + continue; + } float kerning = 0; - if (prevChar != L'\0') kerning = GetKerning(prevChar, ch); + if (prevChar != L'\0') { + kerning = GetKerning(prevChar, ch); + } posX += (int)kerning; @@ -381,7 +408,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, warning("BaseFontTT::BlitSurface - not ported yet"); #if 0 for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) continue; + if (targetRect->y + y < 0 || targetRect->y + y >= target->h) { + continue; + } uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; @@ -391,7 +420,9 @@ void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, uint32 *tgtBuf32 = (uint32 *)tgtBuf; for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) continue; + if (targetRect->x + x < 0 || targetRect->x + x >= target->w) { + continue; + } tgtBuf32[x + targetRect->x] = srcBuf32[x]; } @@ -417,7 +448,9 @@ bool BaseFontTT::loadFile(const char *filename) { setFilename(filename); - if (DID_FAIL(ret = loadBuffer(buffer))) _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + } delete[] buffer; @@ -468,7 +501,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { } buffer = (byte *)params; - uint32 BaseColor = 0x00000000; + uint32 baseColor = 0x00000000; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -507,23 +540,24 @@ bool BaseFontTT::loadBuffer(byte *buffer) { case TOKEN_COLOR: { int r, g, b; parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - BaseColor = BYTETORGBA(r, g, b, RGBCOLGetA(BaseColor)); + baseColor = BYTETORGBA(r, g, b, RGBCOLGetA(baseColor)); } break; case TOKEN_ALPHA: { int a; parser.scanStr(params, "%d", &a); - BaseColor = BYTETORGBA(RGBCOLGetR(BaseColor), RGBCOLGetG(BaseColor), RGBCOLGetB(BaseColor), a); + baseColor = BYTETORGBA(RGBCOLGetR(baseColor), RGBCOLGetG(baseColor), RGBCOLGetB(baseColor), a); } break; case TOKEN_LAYER: { - BaseTTFontLayer *Layer = new BaseTTFontLayer; - if (Layer && DID_SUCCEED(parseLayer(Layer, (byte *)params))) _layers.add(Layer); - else { - delete Layer; - Layer = NULL; + BaseTTFontLayer *layer = new BaseTTFontLayer; + if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) { + _layers.add(layer); + } else { + delete layer; + layer = NULL; cmd = PARSERR_TOKENNOTFOUND; } } @@ -538,12 +572,14 @@ bool BaseFontTT::loadBuffer(byte *buffer) { // create at least one layer if (_layers.getSize() == 0) { - BaseTTFontLayer *Layer = new BaseTTFontLayer; - Layer->_color = BaseColor; - _layers.add(Layer); + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->_color = baseColor; + _layers.add(layer); } - if (!_fontFile) BaseUtils::setString(&_fontFile, "arial.ttf"); + if (!_fontFile) { + BaseUtils::setString(&_fontFile, "arial.ttf"); + } return initFont(); } @@ -587,8 +623,11 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { break; } } - if (cmd != PARSERR_EOF) return STATUS_FAILED; - else return STATUS_OK; + if (cmd != PARSERR_EOF) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } } @@ -609,7 +648,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving()) { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) _layers[i]->persist(persistMgr); + for (int i = 0; i < numLayers; i++) { + _layers[i]->persist(persistMgr); + } } else { numLayers = _layers.getSize(); persistMgr->transfer(TMEMBER(numLayers)); @@ -621,7 +662,9 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { } if (!persistMgr->getIsSaving()) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) _cachedTexts[i] = NULL; + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } _fallbackFont = _font = _deletableFont = NULL; } @@ -636,7 +679,9 @@ void BaseFontTT::afterLoad() { ////////////////////////////////////////////////////////////////////////// bool BaseFontTT::initFont() { - if (!_fontFile) return STATUS_FAILED; + if (!_fontFile) { + return STATUS_FAILED; + } Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); if (!file) { diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 8a8459b070..f8c5eee74d 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -67,7 +67,9 @@ private: } virtual ~BaseCachedTTFontText() { - if (_surface) delete _surface; + if (_surface) { + delete _surface; + } } }; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 09a78a748b..571deed793 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -53,15 +53,11 @@ BaseImage::BaseImage(BaseFileManager *fileManager) { ////////////////////////////////////////////////////////////////////// BaseImage::~BaseImage() { - /* delete _bitmap; */ delete _decoder; if (_deletableSurface) { _deletableSurface->free(); } delete _deletableSurface; -#if 0 - if (_bitmap) FreeImage_Unload(_bitmap); -#endif } bool BaseImage::loadFile(const Common::String &filename) { @@ -82,7 +78,9 @@ bool BaseImage::loadFile(const Common::String &filename) { } _filename = filename; Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) return false; + if (!file) { + return false; + } _decoder->loadStream(*file); _surface = _decoder->getSurface(); @@ -93,7 +91,9 @@ bool BaseImage::loadFile(const Common::String &filename) { } byte BaseImage::getAlphaAt(int x, int y) const { - if (!_surface) return 0xFF; + if (!_surface) { + return 0xFF; + } uint32 color = *(uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; _surface->format.colorToARGB(color, a, r, g, b); @@ -107,12 +107,6 @@ void BaseImage::copyFrom(const Graphics::Surface *surface) { ////////////////////////////////////////////////////////////////////////// bool BaseImage::saveBMPFile(const char *filename) const { -#if 0 - if (!_bitmap) return STATUS_FAILED; - - if (FreeImage_Save(FIF_BMP, _bitmap, filename)) return STATUS_OK; - else return STATUS_FAILED; -#endif warning("BaseImage::saveBMPFile - stubbed"); // TODO return false; } @@ -121,10 +115,16 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { #if 0 - if (!_bitmap) return STATUS_FAILED; + if (!_bitmap) { + return STATUS_FAILED; + } - if (newWidth == 0) NewWidth = FreeImage_GetWidth(_bitmap); - if (newHeight == 0) NewHeight = FreeImage_GetHeight(_bitmap); + if (newWidth == 0) { + NewWidth = FreeImage_GetWidth(_bitmap); + } + if (newHeight == 0) { + NewHeight = FreeImage_GetHeight(_bitmap); + } FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); @@ -132,7 +132,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { FreeImage_Unload(_bitmap); _bitmap = newImg; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } #endif return false; } @@ -140,7 +142,9 @@ bool BaseImage::resize(int newWidth, int newHeight) { ////////////////////////////////////////////////////////////////////////// bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { - if (!_surface) return false; + if (!_surface) { + return false; + } /* The following is just copied over and inverted to write-ops from the BMP-decoder */ stream->writeByte('B'); @@ -164,8 +168,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { stream->writeUint32LE(width); stream->writeUint32LE((uint32)height); - if (width == 0 || height == 0) + if (width == 0 || height == 0) { return false; + } if (height < 0) { warning("Right-side up bitmaps not supported"); @@ -194,8 +199,9 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); // BGRA for 24bpp - if (bitsPerPixel == 24) + if (bitsPerPixel == 24) { format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + } Graphics::Surface *surface = _surface->convertTo(format); @@ -219,36 +225,22 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { surface->free(); delete surface; return true; - - //*BufferSize = 0; -#if 0 - FIMEMORY *fiMem = FreeImage_OpenMemory(); - FreeImage_SaveToMemory(FIF_PNG, _bitmap, fiMem); - uint32 size; - byte *data; - FreeImage_AcquireMemory(fiMem, &data, &size); - - - byte *Buffer = new byte[size]; - memcpy(Buffer, data, size); - - FreeImage_CloseMemory(fiMem); - - if (BufferSize) *BufferSize = size; - - return Buffer; -#endif - return false; } ////////////////////////////////////////////////////////////////////////// bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { #if 0 - if (_bitmap) FreeImage_Unload(_bitmap); + if (_bitmap) { + FreeImage_Unload(_bitmap); + } - if (NewWidth == 0) NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - if (NewHeight == 0) NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + if (NewWidth == 0) { + NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); + } + if (NewHeight == 0) { + NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); + } _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); #endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 66b7f513bf..168aa75d91 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -89,13 +89,19 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { yy = height - yy; } - if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) return _rectList[i]->_owner; + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) { + return _rectList[i]->_owner; + } } // region else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) return _rectList[i]->_owner; + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) { + return _rectList[i]->_owner; + } } - } else return _rectList[i]->_owner; + } else { + return _rectList[i]->_owner; + } } } @@ -208,10 +214,18 @@ bool BaseRenderer::unclipCursor() { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::pointInViewport(Point32 *p) { - if (p->x < _drawOffsetX) return false; - if (p->y < _drawOffsetY) return false; - if (p->x > _drawOffsetX + _width) return false; - if (p->y > _drawOffsetY + _height) return false; + if (p->x < _drawOffsetX) { + return false; + } + if (p->y < _drawOffsetY) { + return false; + } + if (p->x > _drawOffsetX + _width) { + return false; + } + if (p->y > _drawOffsetY + _height) { + return false; + } return true; } diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 684236ac7f..68e3e3d26c 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -54,7 +54,9 @@ BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// BaseSurface::~BaseSurface() { - if (_pixelOpReady) endPixelOp(); + if (_pixelOpReady) { + endPixelOp(); + } } @@ -139,7 +141,9 @@ bool BaseSurface::prepareToDraw() { if (!_valid) { //_gameRef->LOG(0, "Reviving: %s", _filename); return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); - } else return STATUS_OK; + } else { + return STATUS_OK; + } } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 43cf66d053..e465194e58 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -44,10 +44,12 @@ RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *s _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) + if (mirrorX) { _mirror |= TransparentSurface::FLIP_V; - if (mirrorY) + } + if (mirrorY) { _mirror |= TransparentSurface::FLIP_H; + } if (surf) { _surface = new Graphics::Surface(); _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); @@ -113,8 +115,12 @@ BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; #if 0 - if (_renderer) SDL_DestroyRenderer(_renderer); - if (_win) SDL_DestroyWindow(_win); + if (_renderer) { + SDL_DestroyRenderer(_renderer); + } + if (_win) { + SDL_DestroyWindow(_win); + } SDL_Quit(); #endif } @@ -212,7 +218,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _realWidth, _realHeight, flags); - if (!_win) return STATUS_FAILED; + if (!_win) { + return STATUS_FAILED; + } #endif g_system->showMouse(false); @@ -226,7 +234,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { #if 0 _renderer = SDL_CreateRenderer(_win, -1, 0); - if (!_renderer) return STATUS_FAILED; + if (!_renderer) { + return STATUS_FAILED; + } #endif _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; @@ -273,8 +283,9 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) + if (!_disableDirtyRects) { return STATUS_OK; + } if (!rect) { rect = &_renderRect; } @@ -320,9 +331,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect //TODO: This is only here until I'm sure about the final pixelformat uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) + if (_disableDirtyRects) { _renderSurface->fillRect(fillRect, col); - else { + } else { setAlphaMod(a); setColorMod(r, g, b); Graphics::Surface surf; @@ -468,8 +479,9 @@ void BaseRenderOSystem::drawTickets() { it++; } } - if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { return; + } // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; @@ -518,8 +530,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R } src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) + if (doDelete) { delete clipRect; + } } ////////////////////////////////////////////////////////////////////////// @@ -566,9 +579,13 @@ BaseImage *BaseRenderOSystem::takeScreenshot() { SDL_RenderGetViewport(_renderer, &viewport); SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) return NULL; + if (!surface) { + return NULL; + } - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) return NULL; + if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { + return NULL; + } FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); @@ -643,7 +660,9 @@ void BaseRenderOSystem::dumpData(const char *filename) { warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO #if 0 FILE *f = fopen(filename, "wt"); - if (!f) return; + if (!f) { + return; + } BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; @@ -652,8 +671,12 @@ void BaseRenderOSystem::dumpData(const char *filename) { fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; - if (!Surf->_filename) continue; - if (!Surf->_valid) continue; + if (!Surf->_filename) { + continue; + } + if (!Surf->_valid) { + continue; + } fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 36213dfde1..4b680e2793 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -107,11 +107,14 @@ bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed _ckGreen = ckGreen; _ckBlue = ckBlue; - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) { _lifeTime = lifeTime; + } _keepLoaded = keepLoaded; - if (_keepLoaded) _lifeTime = -1; + if (_keepLoaded) { + _lifeTime = -1; + } return STATUS_OK; } @@ -201,7 +204,9 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { delete[] _alphaMask; _alphaMask = NULL; - if (!surface) return; + if (!surface) { + return; + } #if 0 SDL_LockSurface(surface); #endif @@ -224,11 +229,14 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { surface->format.colorToARGB(pixel, a, r, g, b); //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) { a = 0; + } _alphaMask[y * surface->w + x] = a; - if (a < 255) hasTransparency = true; + if (a < 255) { + hasTransparency = true; + } } } #if 0 @@ -331,7 +339,9 @@ bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { int width, height; //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + if (X < 0 || X >= width || Y < 0 || Y >= height) { + return true; + } StartPixelOp(); @@ -371,10 +381,15 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { //SDL_QueryTexture(_texture, &format, &access, &width, &height); //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) return true; + if (X < 0 || X >= width || Y < 0 || Y >= height) { + return true; + } - if (!_alphaMask) return false; - else return _alphaMask[Y * width + X] <= 128; + if (!_alphaMask) { + return false; + } else { + return _alphaMask[Y * width + X] <= 128; + } #endif return false; /* @@ -447,8 +462,9 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo finishLoad(); } - if (renderer->_forceAlphaColor != 0) + if (renderer->_forceAlphaColor != 0) { alpha = renderer->_forceAlphaColor; + } // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. @@ -469,10 +485,11 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo SDL_SetTextureColorMod(_texture, r, g, b); SDL_SetTextureAlphaMod(_texture, a); - if (AlphaDisable) + if (alphaDisable) { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - else + } else { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); + } #endif // TODO: This _might_ miss the intended behaviour by 1 in each direction // But I think it fits the model used in Wintermute. diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 1ddefec610..b16fb83abf 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -116,11 +116,15 @@ PartEmitter::~PartEmitter(void) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::addSprite(const char *filename) { - if (!filename) return STATUS_FAILED; + if (!filename) { + return STATUS_FAILED; + } // do we already have the file? for (int i = 0; i < _sprites.getSize(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) return STATUS_OK; + if (scumm_stricmp(filename, _sprites[i]) == 0) { + return STATUS_OK; + } } // check if file exists @@ -128,7 +132,9 @@ bool PartEmitter::addSprite(const char *filename) { if (!File) { _gameRef->LOG(0, "Sprite '%s' not found", filename); return STATUS_FAILED; - } else _gameRef->_fileManager->closeFile(File); + } else { + _gameRef->_fileManager->closeFile(File); + } char *Str = new char[strlen(filename) + 1]; strcpy(Str, filename); @@ -151,24 +157,37 @@ bool PartEmitter::removeSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) return STATUS_FAILED; - if (_sprites.getSize() == 0) return STATUS_FAILED; + if (!particle) { + return STATUS_FAILED; + } + if (_sprites.getSize() == 0) { + return STATUS_FAILED; + } int posX = BaseUtils::randomInt(_posX, _posX + _width); int posY = BaseUtils::randomInt(_posY, _posY + _height); float posZ = BaseUtils::randomFloat(0.0f, 100.0f); float velocity; - if (_velocityZBased) velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - else velocity = BaseUtils::randomFloat(_velocity1, _velocity2); + if (_velocityZBased) { + velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + } else { + velocity = BaseUtils::randomFloat(_velocity1, _velocity2); + } float scale; - if (_scaleZBased) scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - else scale = BaseUtils::randomFloat(_scale1, _scale2); + if (_scaleZBased) { + scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + } else { + scale = BaseUtils::randomFloat(_scale1, _scale2); + } int lifeTime; - if (_lifeTimeZBased) lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); - else lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); + if (_lifeTimeZBased) { + lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); + } else { + lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); + } float angle = BaseUtils::randomAngle(_angle1, _angle2); int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); @@ -220,14 +239,20 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 particle->fadeIn(currentTime, _fadeInTime); - if (particle->_isDead) return STATUS_FAILED; - else return STATUS_OK; + if (particle->_isDead) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } } ////////////////////////////////////////////////////////////////////////// bool PartEmitter::update() { - if (!_running) return STATUS_OK; - else return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + if (!_running) { + return STATUS_OK; + } else { + return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + } } ////////////////////////////////////////////////////////////////////////// @@ -237,7 +262,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { for (int i = 0; i < _particles.getSize(); i++) { _particles[i]->update(this, currentTime, timerDelta); - if (!_particles[i]->_isDead) numLive++; + if (!_particles[i]->_isDead) { + numLive++; + } } @@ -263,8 +290,9 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { } PartParticle *particle; - if (firstDeadIndex >= 0) particle = _particles[firstDeadIndex]; - else { + if (firstDeadIndex >= 0) { + particle = _particles[firstDeadIndex]; + } else { particle = new PartParticle(_gameRef); _particles.add(particle); } @@ -274,12 +302,15 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { toGen--; } } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) { sortParticlesByZ(); + } // we actually generated some particles and we're not in fast-forward mode if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) _owner->applyEvent(_emitEvent); + if (_owner && _emitEvent) { + _owner->applyEvent(_emitEvent); + } } } @@ -288,17 +319,23 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::display(BaseRegion *region) { - if (_sprites.getSize() <= 1) _gameRef->_renderer->startSpriteBatch(); + if (_sprites.getSize() <= 1) { + _gameRef->_renderer->startSpriteBatch(); + } for (int i = 0; i < _particles.getSize(); i++) { if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) continue; + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { + continue; + } } _particles[i]->display(this); } - if (_sprites.getSize() <= 1) _gameRef->_renderer->endSpriteBatch(); + if (_sprites.getSize() <= 1) { + _gameRef->_renderer->endSpriteBatch(); + } return STATUS_OK; } @@ -339,9 +376,13 @@ int PartEmitter::compareZ(const void *obj1, const void *obj2) { PartParticle *p1 = *(PartParticle **)obj1; PartParticle *p2 = *(PartParticle **)obj2; - if (p1->_posZ < p2->_posZ) return -1; - else if (p1->_posZ > p2->_posZ) return 1; - else return 0; + if (p1->_posZ < p2->_posZ) { + return -1; + } else if (p1->_posZ > p2->_posZ) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -385,7 +426,9 @@ PartForce *PartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { PartForce *force = addForceByName(name); - if (!force) return STATUS_FAILED; + if (!force) { + return STATUS_FAILED; + } force->_type = type; force->_pos = Vector2(posX, posY); @@ -554,9 +597,9 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushBool(DID_SUCCEED(removeForce(forceName))); return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); } - - else return BaseObject::scCallMethod(script, stack, thisStack, name); } ////////////////////////////////////////////////////////////////////////// @@ -745,7 +788,9 @@ ScValue *PartEmitter::scGetProperty(const char *name) { else if (strcmp(name, "NumLiveParticles") == 0) { int numAlive = 0; for (int i = 0; i < _particles.getSize(); i++) { - if (_particles[i] && !_particles[i]->_isDead) numAlive++; + if (_particles[i] && !_particles[i]->_isDead) { + numAlive++; + } } _scValue->setInt(numAlive); return _scValue; @@ -822,12 +867,15 @@ ScValue *PartEmitter::scGetProperty(const char *name) { // EmitEvent ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) _scValue->setNULL(); - else _scValue->setString(_emitEvent); + if (!_emitEvent) { + _scValue->setNULL(); + } else { + _scValue->setString(_emitEvent); + } return _scValue; + } else { + return BaseObject::scGetProperty(name); } - - else return BaseObject::scGetProperty(name); } @@ -978,8 +1026,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha1") == 0) { _alpha1 = value->getInt(); - if (_alpha1 < 0) _alpha1 = 0; - if (_alpha1 > 255) _alpha1 = 255; + if (_alpha1 < 0) { + _alpha1 = 0; + } + if (_alpha1 > 255) { + _alpha1 = 255; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -987,8 +1039,12 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Alpha2") == 0) { _alpha2 = value->getInt(); - if (_alpha2 < 0) _alpha2 = 0; - if (_alpha2 > 255) _alpha2 = 255; + if (_alpha2 < 0) { + _alpha2 = 0; + } + if (_alpha2 > 255) { + _alpha2 = 255; + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// @@ -1080,11 +1136,13 @@ bool PartEmitter::scSetProperty(const char *name, ScValue *value) { else if (strcmp(name, "EmitEvent") == 0) { delete[] _emitEvent; _emitEvent = NULL; - if (!value->isNULL()) BaseUtils::setString(&_emitEvent, value->getString()); + if (!value->isNULL()) { + BaseUtils::setString(&_emitEvent, value->getString()); + } return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); } - - else return BaseObject::scSetProperty(name, value); } diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index b63a82f926..4a5239edfe 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -99,24 +99,29 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer if (currentTime - _fadeStart >= (uint32)_fadeTime) { _state = PARTICLE_NORMAL; _currentAlpha = _alpha1; - } else _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + } else { + _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + } return STATUS_OK; } else if (_state == PARTICLE_FADEOUT) { if (currentTime - _fadeStart >= (uint32)_fadeTime) { _isDead = true; return STATUS_OK; - } else _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + } else { + _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + } return STATUS_OK; } else { // time is up if (_lifeTime > 0) { if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) + if (emitter->_fadeOutTime > 0) { fadeOut(currentTime, emitter->_fadeOutTime); - else + } else { _isDead = true; + } } } @@ -125,10 +130,13 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer Point32 p; p.x = (int32)_pos.x; p.y = (int32)_pos.y; - if (!BasePlatform::ptInRect(&_border, p)) + if (!BasePlatform::ptInRect(&_border, p)) { fadeOut(currentTime, emitter->_fadeOutTime); + } + } + if (_state != PARTICLE_NORMAL) { + return STATUS_OK; } - if (_state != PARTICLE_NORMAL) return STATUS_OK; // update alpha if (_lifeTime > 0) { @@ -166,13 +174,15 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer _rotation = BaseUtils::normalizeAngle(_rotation); // update scale - if (_exponentialGrowth) + if (_exponentialGrowth) { _scale += _scale / 100.0f * _growthRate * elapsedTime; - else + } else { _scale += _growthRate * elapsedTime; + } - if (_scale <= 0.0f) + if (_scale <= 0.0f) { _isDead = true; + } return STATUS_OK; @@ -181,8 +191,12 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer ////////////////////////////////////////////////////////////////////////// bool PartParticle::display(PartEmitter *emitter) { - if (!_sprite) return STATUS_FAILED; - if (_isDead) return STATUS_OK; + if (!_sprite) { + return STATUS_FAILED; + } + if (_isDead) { + return STATUS_OK; + } _sprite->GetCurrentFrame(); return _sprite->display(_pos.x, _pos.y, diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index a519da5832..4deeb0bf39 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -249,17 +249,23 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip _threadEvent = NULL; _filename = new char[strlen(filename) + 1]; - if (_filename) strcpy(_filename, filename); + if (_filename) { + strcpy(_filename, filename); + } _buffer = new byte [size]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, buffer, size); _bufferSize = size; bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // establish global variables table _globals = new ScValue(_gameRef); @@ -277,22 +283,30 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event _thread = true; _methodThread = false; _threadEvent = new char[strlen(eventName) + 1]; - if (_threadEvent) strcpy(_threadEvent, eventName); + if (_threadEvent) { + strcpy(_threadEvent, eventName); + } // copy filename _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); + if (_filename) { + strcpy(_filename, original->_filename); + } // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // copy globals _globals = original->_globals; @@ -317,29 +331,39 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event ////////////////////////////////////////////////////////////////////////// bool ScScript::createMethodThread(ScScript *original, const char *methodName) { uint32 ip = original->getMethodPos(methodName); - if (ip == 0) return STATUS_FAILED; + if (ip == 0) { + return STATUS_FAILED; + } cleanup(); _thread = true; _methodThread = true; _threadEvent = new char[strlen(methodName) + 1]; - if (_threadEvent) strcpy(_threadEvent, methodName); + if (_threadEvent) { + strcpy(_threadEvent, methodName); + } // copy filename _filename = new char[strlen(original->_filename) + 1]; - if (_filename) strcpy(_filename, original->_filename); + if (_filename) { + strcpy(_filename, original->_filename); + } // copy buffer _buffer = new byte [original->_bufferSize]; - if (!_buffer) return STATUS_FAILED; + if (!_buffer) { + return STATUS_FAILED; + } memcpy(_buffer, original->_buffer, original->_bufferSize); _bufferSize = original->_bufferSize; // initialize bool res = initScript(); - if (DID_FAIL(res)) return res; + if (DID_FAIL(res)) { + return res; + } // copy globals _globals = original->_globals; @@ -360,17 +384,25 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { ////////////////////////////////////////////////////////////////////////// void ScScript::cleanup() { - if (_buffer) delete[] _buffer; + if (_buffer) { + delete[] _buffer; + } _buffer = NULL; - if (_filename) delete[] _filename; + if (_filename) { + delete[] _filename; + } _filename = NULL; - if (_symbols) delete[] _symbols; + if (_symbols) { + delete[] _symbols; + } _symbols = NULL; _numSymbols = 0; - if (_globals && !_thread) delete _globals; + if (_globals && !_thread) { + delete _globals; + } _globals = NULL; delete _scopeStack; @@ -385,22 +417,30 @@ void ScScript::cleanup() { delete _stack; _stack = NULL; - if (_functions) delete[] _functions; + if (_functions) { + delete[] _functions; + } _functions = NULL; _numFunctions = 0; - if (_methods) delete[] _methods; + if (_methods) { + delete[] _methods; + } _methods = NULL; _numMethods = 0; - if (_events) delete[] _events; + if (_events) { + delete[] _events; + } _events = NULL; _numEvents = 0; if (_externals) { for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) delete[] _externals[i].params; + if (_externals[i].nu_params > 0) { + delete[] _externals[i].params; + } } delete[] _externals; } @@ -423,7 +463,7 @@ void ScScript::cleanup() { _waitScript = NULL; _parentScript = NULL; // ref only - + delete _scriptStream; } @@ -460,7 +500,9 @@ double ScScript::getFloat() { ////////////////////////////////////////////////////////////////////////// char *ScScript::getString() { char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') _iP++; + while (*(char *)(_buffer + _iP) != '\0') { + _iP++; + } _iP++; // string terminator _scriptStream->seek(_iP); @@ -489,12 +531,14 @@ bool ScScript::executeInstruction() { dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); + } } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); + } } break; @@ -508,8 +552,9 @@ bool ScScript::executeInstruction() { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); + } } break; } @@ -521,14 +566,20 @@ bool ScScript::executeInstruction() { _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) { + _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + } else { + _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; } else { - if (_numEvents == 0 && _numMethods == 0) _state = SCRIPT_FINISHED; - else _state = SCRIPT_PERSISTENT; + if (_numEvents == 0 && _numMethods == 0) { + _state = SCRIPT_FINISHED; + } else { + _state = SCRIPT_PERSISTENT; + } } } @@ -557,7 +608,9 @@ bool ScScript::executeInstruction() { strcpy(MethodName, str); ScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) var = var->_valRef; + if (var->_type == VAL_VARIABLE_REF) { + var = var->_valRef; + } bool res = STATUS_FAILED; bool TriedNative = false; @@ -612,7 +665,9 @@ bool ScScript::executeInstruction() { */ else { res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (var->_type == VAL_NATIVE && !TriedNative) { + res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + } if (DID_FAIL(res)) { _stack->correctParams(0); @@ -631,7 +686,9 @@ bool ScScript::executeInstruction() { TExternalFunction *f = getExternal(_symbols[SymbolIndex]); if (f) { externalCall(_stack, _thisStack, f); - } else _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + } else { + _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + } break; } @@ -639,8 +696,11 @@ bool ScScript::executeInstruction() { _operand->setNULL(); _scopeStack->push(_operand); - if (_scopeStack->_sP < 0) _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - else _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + if (_scopeStack->_sP < 0) { + _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); + } else { + _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); + } break; @@ -663,7 +723,9 @@ bool ScScript::executeInstruction() { if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { _operand->setReference(var); _stack->push(_operand); - } else _stack->push(var); + } else { + _stack->push(var); + } break; } @@ -683,15 +745,19 @@ bool ScScript::executeInstruction() { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); } else { - if (val->getType() == VAL_VARIABLE_REF) val = val->_valRef; - if (val->_type == VAL_NATIVE) var->setValue(val); - else { + if (val->getType() == VAL_VARIABLE_REF) { + val = val->_valRef; + } + if (val->_type == VAL_NATIVE) { + var->setValue(val); + } else { var->copy(val); } } - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableChangeValue(var, val); + } } break; @@ -740,8 +806,11 @@ bool ScScript::executeInstruction() { case II_PUSH_BY_EXP: { str = _stack->pop()->getString(); ScValue *val = _stack->pop()->getProp(str); - if (val) _stack->push(val); - else _stack->pushNULL(); + if (val) { + _stack->push(val); + } else { + _stack->pushNULL(); + } break; } @@ -754,10 +823,13 @@ bool ScScript::executeInstruction() { if (val == NULL) { runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); var->setNULL(); - } else var->setProp(str, val); + } else { + var->setProp(str, val); + } - if (_gameRef->getDebugMgr()->_enabled) + if (_gameRef->getDebugMgr()->_enabled) { _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); + } break; } @@ -781,7 +853,9 @@ bool ScScript::executeInstruction() { if (!val) { runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); } else { - if (!val->getBool()) _iP = dw; + if (!val->getBool()) { + _iP = dw; + } } break; } @@ -790,17 +864,19 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) + if (op1->isNULL() || op2->isNULL()) { _operand->setNULL(); - else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; strcpy(tempStr, op1->getString()); strcat(tempStr, op2->getString()); _operand->setString(tempStr); delete[] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() + op2->getInt()); - else _operand->setFloat(op1->getFloat() + op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() + op2->getFloat()); + } _stack->push(_operand); @@ -810,11 +886,13 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) + if (op1->isNULL() || op2->isNULL()) { _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() - op2->getInt()); - else _operand->setFloat(op1->getFloat() - op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() - op2->getFloat()); + } _stack->push(_operand); @@ -824,10 +902,13 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op1->isNULL() || op2->isNULL()) _operand->setNULL(); - else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) + if (op1->isNULL() || op2->isNULL()) { + _operand->setNULL(); + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { _operand->setInt(op1->getInt() * op2->getInt()); - else _operand->setFloat(op1->getFloat() * op2->getFloat()); + } else { + _operand->setFloat(op1->getFloat() * op2->getFloat()); + } _stack->push(_operand); @@ -837,11 +918,15 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getFloat() == 0.0f) + if (op2->getFloat() == 0.0f) { runtimeError("Division by zero."); + } - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) _operand->setNULL(); - else _operand->setFloat(op1->getFloat() / op2->getFloat()); + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) { + _operand->setNULL(); + } else { + _operand->setFloat(op1->getFloat() / op2->getFloat()); + } _stack->push(_operand); @@ -851,12 +936,15 @@ bool ScScript::executeInstruction() { op2 = _stack->pop(); op1 = _stack->pop(); - if (op2->getInt() == 0) + if (op2->getInt() == 0) { runtimeError("Division by zero."); + } - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) { _operand->setNULL(); - else _operand->setInt(op1->getInt() % op2->getInt()); + } else { + _operand->setInt(op1->getInt() % op2->getInt()); + } _stack->push(_operand); @@ -865,8 +953,11 @@ bool ScScript::executeInstruction() { case II_NOT: op1 = _stack->pop(); //if (op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) _operand->setBool(true); - else _operand->setBool(!op1->getBool()); + if (op1->isNULL()) { + _operand->setBool(true); + } else { + _operand->setBool(!op1->getBool()); + } _stack->push(_operand); break; @@ -1060,8 +1151,9 @@ bool ScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getFuncPos(const char *name) { for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) + if (strcmp(name, _functions[i].name) == 0) { return _functions[i].pos; + } } return 0; } @@ -1070,8 +1162,9 @@ uint32 ScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getMethodPos(const char *name) { for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) + if (strcmp(name, _methods[i].name) == 0) { return _methods[i].pos; + } } return 0; } @@ -1083,20 +1176,23 @@ ScValue *ScScript::getVar(char *name) { // scope locals if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) + if (_scopeStack->getTop()->propExists(name)) { ret = _scopeStack->getTop()->getProp(name); + } } // script globals if (ret == NULL) { - if (_globals->propExists(name)) + if (_globals->propExists(name)) { ret = _globals->getProp(name); + } } // engine globals if (ret == NULL) { - if (_engine->_globals->propExists(name)) + if (_engine->_globals->propExists(name)) { ret = _engine->_globals->getProp(name); + } } if (ret == NULL) { @@ -1162,7 +1258,9 @@ bool ScScript::finish(bool includingThreads) { if (_state != SCRIPT_FINISHED && includingThreads) { _state = SCRIPT_FINISHED; finishThreads(); - } else _state = SCRIPT_FINISHED; + } else { + _state = SCRIPT_FINISHED; + } return STATUS_OK; @@ -1188,8 +1286,9 @@ void ScScript::runtimeError(const char *fmt, ...) { _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); _gameRef->LOG(0, " %s", buff); - if (!_gameRef->_suppressScriptErrors) + if (!_gameRef->_suppressScriptErrors) { _gameRef->quickMessage("Script runtime error. View log for details."); + } } @@ -1217,8 +1316,8 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { initTables(); } else { _buffer = NULL; - _scriptStream = NULL; - } + _scriptStream = NULL; + } } persistMgr->transfer(TMEMBER(_callStack)); @@ -1249,7 +1348,9 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_unbreakable)); persistMgr->transfer(TMEMBER(_parentScript)); - if (!persistMgr->getIsSaving()) _tracingMode = false; + if (!persistMgr->getIsSaving()) { + _tracingMode = false; + } return STATUS_OK; } @@ -1260,7 +1361,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); - if (!pos) return NULL; + if (!pos) { + return NULL; + } ScScript *thread = new ScScript(_gameRef, _engine); if (thread) { @@ -1274,7 +1377,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) delete thread; return NULL; } - } else return NULL; + } else { + return NULL; + } } @@ -1282,7 +1387,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) ////////////////////////////////////////////////////////////////////////// uint32 ScScript::getEventPos(const char *name) { for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) return _events[i].pos; + if (scumm_stricmp(name, _events[i].name) == 0) { + return _events[i].pos; + } } return 0; } @@ -1307,7 +1414,9 @@ bool ScScript::pause() { return STATUS_FAILED; } - if (!_freezable || _state == SCRIPT_PERSISTENT) return STATUS_OK; + if (!_freezable || _state == SCRIPT_PERSISTENT) { + return STATUS_OK; + } _origState = _state; _state = SCRIPT_PAUSED; @@ -1318,7 +1427,9 @@ bool ScScript::pause() { ////////////////////////////////////////////////////////////////////////// bool ScScript::resume() { - if (_state != SCRIPT_PAUSED) return STATUS_OK; + if (_state != SCRIPT_PAUSED) { + return STATUS_OK; + } _state = _origState; return STATUS_OK; @@ -1328,8 +1439,9 @@ bool ScScript::resume() { ////////////////////////////////////////////////////////////////////////// ScScript::TExternalFunction *ScScript::getExternal(char *name) { for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) + if (strcmp(name, _externals[i].name) == 0) { return &_externals[i]; + } } return NULL; } @@ -1354,7 +1466,9 @@ bool ScScript::copyParameters(ScStack *stack) { } _stack->pushInt(NumParams); - for (i = 0; i < NumParams; i++) stack->pop(); + for (i = 0; i < NumParams; i++) { + stack->pop(); + } return STATUS_OK; } @@ -1364,8 +1478,9 @@ bool ScScript::copyParameters(ScStack *stack) { bool ScScript::finishThreads() { for (int i = 0; i < _engine->_scripts.getSize(); i++) { ScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { scr->finish(true); + } } return STATUS_OK; } @@ -1385,9 +1500,13 @@ const char *ScScript::dbgGetFilename() { ////////////////////////////////////////////////////////////////////////// bool ScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - else if (_thread) client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - else client->onScriptInit(this); + if (_methodThread) { + client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); + } else if (_thread) { + client->onScriptEventThreadInit(this, _parentScript, _threadEvent); + } else { + client->onScriptInit(this); + } return dbgSendVariables(client); return STATUS_OK; @@ -1421,8 +1540,11 @@ int ScScript::dbgGetNumBreakpoints() { ////////////////////////////////////////////////////////////////////////// int ScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) return _breakpoints[index]; - else return -1; + if (index >= 0 && index < _breakpoints.getSize()) { + return _breakpoints[index]; + } else { + return -1; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 792dfd4589..356617094d 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -47,8 +47,11 @@ IMPLEMENT_PERSISTENT(ScEngine, true) ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); - if (_compilerAvailable) _gameRef->LOG(0, " Script compiler bound successfuly"); - else _gameRef->LOG(0, " Script compiler is NOT available"); + if (_compilerAvailable) { + _gameRef->LOG(0, " Script compiler bound successfuly"); + } else { + _gameRef->LOG(0, " Script compiler is NOT available"); + } _globals = new ScValue(_gameRef); @@ -68,7 +71,9 @@ ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { } // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) _cachedScripts[i] = NULL; + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + _cachedScripts[i] = NULL; + } _currentScript = NULL; @@ -99,7 +104,9 @@ ScEngine::~ScEngine() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::cleanup() { for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } delete _scripts[i]; _scripts.removeAt(i); i--; @@ -143,7 +150,9 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { // get script from cache compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) return NULL; + if (!compBuffer) { + return NULL; + } // add new script ScScript *script = new ScScript(_gameRef, this); @@ -155,8 +164,11 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { } else { // publish the "self" pseudo-variable ScValue val(_gameRef); - if (owner)val.setNative(owner, true); - else val.setNULL(); + if (owner) { + val.setNative(owner, true); + } else { + val.setNULL(); + } script->_globals->setProp("self", &val); script->_globals->setProp("this", &val); @@ -226,7 +238,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig } } - if (_cachedScripts[index] != NULL) delete _cachedScripts[index]; + if (_cachedScripts[index] != NULL) { + delete _cachedScripts[index]; + } _cachedScripts[index] = cachedScript; ret = cachedScript->_buffer; @@ -244,8 +258,9 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig ////////////////////////////////////////////////////////////////////////// bool ScEngine::tick() { - if (_scripts.getSize() == 0) + if (_scripts.getSize() == 0) { return STATUS_OK; + } // resolve waiting scripts @@ -267,16 +282,24 @@ bool ScEngine::tick() { if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists */ if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) _scripts[i]->run(); - } else _scripts[i]->finish(); + if (_scripts[i]->_waitObject->isReady()) { + _scripts[i]->run(); + } + } else { + _scripts[i]->finish(); + } break; } case SCRIPT_SLEEPING: { if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= g_system->getMillis()) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= g_system->getMillis()) { + _scripts[i]->run(); + } } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) _scripts[i]->run(); + if (_scripts[i]->_waitTime <= _gameRef->_timer) { + _scripts[i]->run(); + } } break; } @@ -309,7 +332,9 @@ bool ScEngine::tick() { for (int i = 0; i < _scripts.getSize(); i++) { // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) continue; + if (_scripts[i]->_state == SCRIPT_PAUSED) { + continue; + } // time sliced script if (_scripts[i]->_timeSlice > 0) { @@ -318,20 +343,26 @@ bool ScEngine::tick() { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (_isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + if (_isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + } } // normal script else { uint32 startTime = 0; bool isProfiling = _isProfiling; - if (isProfiling) startTime = g_system->getMillis(); + if (isProfiling) { + startTime = g_system->getMillis(); + } while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } - if (isProfiling && _scripts[i]->_filename) addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + if (isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + } } _currentScript = NULL; } @@ -346,7 +377,9 @@ bool ScEngine::tick() { bool ScEngine::tickUnbreakable() { // execute unbreakable scripts for (int i = 0; i < _scripts.getSize(); i++) { - if (!_scripts[i]->_unbreakable) continue; + if (!_scripts[i]->_unbreakable) { + continue; + } while (_scripts[i]->_state == SCRIPT_RUNNING) { _currentScript = _scripts[i]; @@ -366,7 +399,9 @@ bool ScEngine::removeFinishedScripts() { // remove finished scripts for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) _scripts[i]->_owner->removeScript(_scripts[i]); + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; _scripts.removeAt(i); @@ -382,7 +417,9 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) continue; + if (_scripts[i]->_state == SCRIPT_FINISHED) { + continue; + } switch (_scripts[i]->_state) { case SCRIPT_RUNNING: case SCRIPT_SLEEPING: @@ -401,9 +438,15 @@ int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { } numTotal++; } - if (running) *running = numRunning; - if (waiting) *waiting = numWaiting; - if (persistent) *persistent = numPersistent; + if (running) { + *running = numRunning; + } + if (waiting) { + *waiting = numWaiting; + } + if (persistent) { + *persistent = numPersistent; + } return numTotal; } @@ -426,7 +469,9 @@ bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) resetScript(_scripts[i]); + if (!_gameRef->_compatKillMethodThreads) { + resetScript(_scripts[i]); + } bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well @@ -448,7 +493,9 @@ bool ScEngine::resetScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) cleanup(); + if (!persistMgr->getIsSaving()) { + cleanup(); + } persistMgr->transfer(TMEMBER(_gameRef)); persistMgr->transfer(TMEMBER(_currentScript)); @@ -474,7 +521,9 @@ void ScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::pauseAll() { for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] != _currentScript) _scripts[i]->pause(); + if (_scripts[i] != _currentScript) { + _scripts[i]->pause(); + } } return STATUS_OK; @@ -483,8 +532,9 @@ bool ScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) + for (int i = 0; i < _scripts.getSize(); i++) { _scripts[i]->resume(); + } return STATUS_OK; } @@ -493,7 +543,9 @@ bool ScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::isValidScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i] == script) return true; + if (_scripts[i] == script) { + return true; + } } return false; } @@ -511,14 +563,17 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { // process normal scripts first for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) continue; + if (_scripts[i]->_thread || _scripts[i]->_methodThread) { + continue; + } _scripts[i]->dbgSendScript(client); } // and threads later for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) + if (_scripts[i]->_thread || _scripts[i]->_methodThread) { _scripts[i]->dbgSendScript(client); + } } return STATUS_OK; @@ -526,7 +581,9 @@ bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } CScBreakpoint *bp = NULL; for (int i = 0; i < _breakpoints.getSize(); i++) { @@ -541,7 +598,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { } for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) return STATUS_OK; + if (bp->_lines[i] == line) { + return STATUS_OK; + } } bp->_lines.add(line); @@ -553,7 +612,9 @@ bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { @@ -578,7 +639,9 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } for (int i = 0; i < _scripts.getSize(); i++) { refreshScriptBreakpoints(_scripts[i]); @@ -588,9 +651,13 @@ bool ScEngine::refreshScriptBreakpoints() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::refreshScriptBreakpoints(ScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } - if (!script || !script->_filename) return STATUS_FAILED; + if (!script || !script->_filename) { + return STATUS_FAILED; + } for (int i = 0; i < _breakpoints.getSize(); i++) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { @@ -598,14 +665,18 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) { return STATUS_OK; } } - if (script->_breakpoints.getSize() > 0) script->_breakpoints.removeAll(); + if (script->_breakpoints.getSize() > 0) { + script->_breakpoints.removeAll(); + } return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool ScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } char text[512]; @@ -628,7 +699,9 @@ bool ScEngine::saveBreakpoints() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) return STATUS_OK; + if (!_gameRef->getDebugMgr()->_enabled) { + return STATUS_OK; + } char key[100]; @@ -641,7 +714,9 @@ bool ScEngine::loadBreakpoints() { char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); - if (path != NULL && line != NULL) addBreakpoint(path, atoi(line)); + if (path != NULL && line != NULL) { + addBreakpoint(path, atoi(line)); + } delete[] path; delete[] line; path = NULL; @@ -654,7 +729,9 @@ bool ScEngine::loadBreakpoints() { ////////////////////////////////////////////////////////////////////////// void ScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) return; + if (!_isProfiling) { + return; + } AnsiString fileName = filename; fileName.toLowercase(); @@ -664,7 +741,9 @@ void ScEngine::addScriptTime(const char *filename, uint32 time) { ////////////////////////////////////////////////////////////////////////// void ScEngine::enableProfiling() { - if (_isProfiling) return; + if (_isProfiling) { + return; + } // destroy old data, if any _scriptTimes.clear(); @@ -676,7 +755,9 @@ void ScEngine::enableProfiling() { ////////////////////////////////////////////////////////////////////////// void ScEngine::disableProfiling() { - if (!_isProfiling) return; + if (!_isProfiling) { + return; + } dumpStats(); _isProfiling = false; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index e443ec5832..fc441347df 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -48,13 +48,17 @@ public: CScCachedScript(const char *filename, byte *buffer, uint32 size) { _timestamp = g_system->getMillis(); _buffer = new byte[size]; - if (_buffer) memcpy(_buffer, buffer, size); + if (_buffer) { + memcpy(_buffer, buffer, size); + } _size = size; _filename = filename; }; ~CScCachedScript() { - if (_buffer) delete[] _buffer; + if (_buffer) { + delete[] _buffer; + } }; uint32 _timestamp; diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 41059b2d80..0380103cd4 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -47,8 +47,9 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { int numParams = stack->pop()->getInt(0); - if (numParams == 1) _length = stack->pop()->getInt(0); - else if (numParams > 1) { + if (numParams == 1) { + _length = stack->pop()->getInt(0); + } else if (numParams > 1) { _length = numParams; char paramName[20]; for (int i = 0; i < numParams; i++) { @@ -86,7 +87,9 @@ const char *SXArray::scToString() { } } - if (i < _length - 1 && strlen(dummy) + 1 < 32768) strcat(dummy, ","); + if (i < _length - 1 && strlen(dummy) + 1 < 32768) { + strcat(dummy, ","); + } } return dummy; } @@ -124,12 +127,14 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->push(_values->getProp(paramName)); _values->deleteProp(paramName); _length--; - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -160,7 +165,9 @@ ScValue *SXArray::scGetProperty(const char *name) { char ParamName[20]; if (validNumber(name, ParamName)) { return _values->getProp(ParamName); - } else return _scValue; + } else { + return _scValue; + } } } @@ -190,10 +197,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) { else { char paramName[20]; if (validNumber(name, paramName)) { - int Index = atoi(paramName); - if (Index >= _length) _length = Index + 1; + int index = atoi(paramName); + if (index >= _length) { + _length = index + 1; + } return _values->setProp(paramName, value); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } } @@ -223,7 +234,9 @@ bool SXArray::validNumber(const char *origStr, char *outStr) { int index = atoi(origStr); sprintf(outStr, "%d", index); return true; - } else return false; + } else { + return false; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 8eb86c4e69..67a1104b46 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -35,7 +35,7 @@ namespace WinterMute { class SXArray : public BaseScriptable { public: - bool push(ScValue *Val); + bool push(ScValue *val); bool validNumber(const char *origStr, char *outStr); DECLARE_PERSISTENT(SXArray, BaseScriptable) SXArray(BaseGame *inGame, ScStack *stack); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index d2fd3663c7..a3bb7e2183 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -199,10 +199,9 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, g_system->getTimeAndDate(_tm); stack->pushNULL(); return STATUS_OK; - } - - else + } else { return STATUS_FAILED; + } } @@ -216,9 +215,9 @@ ScValue *SXDate::scGetProperty(const char *name) { if (strcmp(name, "Type") == 0) { _scValue->setString("date"); return _scValue; + } else { + return _scValue; } - - else return _scValue; } diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 7da1601bdc..437fbb64a2 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -51,10 +51,12 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { ////////////////////////////////////////////////////////////////////////// SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { stack->correctParams(1); - ScValue *Val = stack->pop(); + ScValue *val = stack->pop(); _filename = NULL; - if (!Val->isNULL()) BaseUtils::setString(&_filename, Val->getString()); + if (!val->isNULL()) { + BaseUtils::setString(&_filename, val->getString()); + } _readFile = NULL; _writeFile = NULL; @@ -94,8 +96,11 @@ void SXFile::close() { ////////////////////////////////////////////////////////////////////////// const char *SXFile::scToString() { - if (_filename) return _filename; - else return "[file object]"; + if (_filename) { + return _filename; + } else { + return "[file object]"; + } } #define FILE_BUFFER_SIZE 32768 @@ -129,24 +134,37 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } } else { if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) _writeFile = openForWrite(_filename, false); - else _writeFile = openForAppend(_filename, false); + if (_mode == 2) { + _writeFile = openForWrite(_filename, false); + } else { + _writeFile = openForAppend(_filename, false); + } } else { - if (_mode == 2) _writeFile = openForWrite(_filename, true); - else _writeFile = openForAppend(_filename, true); + if (_mode == 2) { + _writeFile = openForWrite(_filename, true); + } else { + _writeFile = openForAppend(_filename, true); + } } if (!_writeFile) { //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); close(); - } else _textMode = strcmp(name, "OpenAsText") == 0; + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } } - if (_readFile || _writeFile) stack->pushBool(true); - else stack->pushBool(false); + if (_readFile || _writeFile) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } return STATUS_OK; } @@ -221,7 +239,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool ret = STATUS_FAILED; do { ret = _readFile->read(&b, 1); - if (ret != 1) break; + if (ret != 1) { + break; + } if (counter > bufSize) { buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); @@ -231,8 +251,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, buf[counter] = '\0'; foundNewLine = true; break; - } else if (b == 0x0D) continue; - else { + } else if (b == 0x0D) { + continue; + } else { buf[counter] = b; counter++; } @@ -244,8 +265,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } buf[counter] = '\0'; - if (!foundNewLine && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); + if (!foundNewLine && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } free(buf); @@ -272,14 +296,17 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, bool ret = STATUS_FAILED; while (counter < (uint32)textLen) { ret = _readFile->read(&b, 1); - if (ret != 1) break; + if (ret != 1) { + break; + } if (counter > bufSize) { buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); bufSize += FILE_BUFFER_SIZE; } - if (b == 0x0D) continue; - else { + if (b == 0x0D) { + continue; + } else { buf[counter] = b; counter++; } @@ -291,8 +318,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, } buf[counter] = '\0'; - if (textLen > 0 && counter == 0) stack->pushNULL(); - else stack->pushString((char *)buf); + if (textLen > 0 && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } free(buf); @@ -335,8 +365,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) stack->pushBool(val); - else stack->pushNULL(); + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) { + stack->pushBool(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -355,8 +388,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile->err()) { stack->pushInt(val); } else { - stack->pushNULL(); - } + stack->pushNULL(); + } return STATUS_OK; } @@ -375,7 +408,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, if (!_readFile->err()) { stack->pushInt(65536 + val); } else { - stack->pushNULL(); + stack->pushNULL(); } return STATUS_OK; } @@ -411,7 +444,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } float val; - (*(uint32*)&val) = _readFile->readUint32LE(); + (*(uint32 *)&val) = _readFile->readUint32LE(); if (!_readFile->err()) { stack->pushFloat(val); } else { @@ -433,8 +466,11 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, return STATUS_OK; } double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) stack->pushFloat(val); - else stack->pushNULL(); + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -458,8 +494,12 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushString((char *)str); } delete[] str; - } else stack->pushNULL(); - } else stack->pushNULL(); + } else { + stack->pushNULL(); + } + } else { + stack->pushNULL(); + } return STATUS_OK; } @@ -548,7 +588,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(false); return STATUS_OK; } - uint32 *ptr = (uint32*)&val; + uint32 *ptr = (uint32 *)&val; _writeFile->writeUint32LE(*ptr); stack->pushBool(true); @@ -594,10 +634,9 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->pushBool(true); return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); } - - - else return BaseScriptable::scCallMethod(script, stack, thisStack, name); } @@ -651,9 +690,9 @@ ScValue *SXFile::scGetProperty(const char *name) { else if (strcmp(name, "AccessMode") == 0) { _scValue->setInt(_mode); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -681,43 +720,46 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// uint32 SXFile::getPos() { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->pos(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - getPos for WriteFile not supported"); return 0; // return ftell((FILE *)_writeFile); - } else { + } else { return 0; } } ////////////////////////////////////////////////////////////////////////// bool SXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->seek(pos, whence); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - seeking in WriteFile not supported"); return false; // return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } else { + return false; } - else return false; } ////////////////////////////////////////////////////////////////////////// uint32 SXFile::getLength() { - if (_mode == 1 && _readFile) + if (_mode == 1 && _readFile) { return _readFile->size(); - else if ((_mode == 2 || _mode == 3) && _writeFile) { + } else if ((_mode == 2 || _mode == 3) && _writeFile) { error("SXFile - reading length for WriteFile not supported"); return 0; -/* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else return 0; + /* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// @@ -744,24 +786,28 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { // open for reading if (_mode == 1) { _readFile = _gameRef->_fileManager->openFile(_filename); - if (!_readFile) + if (!_readFile) { close(); + } } // open for writing / appending else { if (_textMode) { - if (_mode == 2) + if (_mode == 2) { _writeFile = openForWrite(_filename, false); - else + } else { _writeFile = openForAppend(_filename, false); + } } else { - if (_mode == 2) + if (_mode == 2) { _writeFile = openForWrite(_filename, true); - else + } else { _writeFile = openForAppend(_filename, true); + } } - if (_writeFile) + if (_writeFile) { close(); + } } setPos(pos); } @@ -777,7 +823,7 @@ Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool b // Should replace fopen(..., "ab+") and fopen(..., "a+") Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); + error("SXFile::openForAppend - WriteFiles not supported"); } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 1c37a15aa9..525b43434f 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -243,9 +243,9 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, stack->correctParams(1); stack->pushFloat(radianToDegree(stack->pop()->getFloat())); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -267,9 +267,9 @@ ScValue *SXMath::scGetProperty(const char *name) { else if (strcmp(name, "PI") == 0) { _scValue->setFloat(M_PI); return _scValue; + } else { + return _scValue; } - - else return _scValue; } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 3d3f0b218b..e15af3446e 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -70,7 +70,9 @@ void *SXMemBuffer::scToMemBuffer() { ////////////////////////////////////////////////////////////////////////// void SXMemBuffer::cleanup() { - if (_size) free(_buffer); + if (_size) { + free(_buffer); + } _buffer = NULL; _size = 0; } @@ -81,14 +83,18 @@ bool SXMemBuffer::resize(int newSize) { if (_size == 0) { _buffer = malloc(newSize); - if (_buffer) _size = newSize; + if (_buffer) { + _size = newSize; + } } else { void *newBuf = realloc(_buffer, newSize); if (!newBuf) { if (newSize == 0) { _buffer = newBuf; _size = newSize; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } else { _buffer = newBuf; _size = newSize; @@ -107,14 +113,16 @@ bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); return false; } - if (_size == 0) + if (_size == 0) { return true; + } if (start < 0 || length == 0 || start + length > _size) { script->runtimeError("Set/Get method call is out of bounds"); return false; - } else + } else { return true; + } } ////////////////////////////////////////////////////////////////////////// @@ -132,10 +140,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->correctParams(1); int newSize = stack->pop()->getInt(); newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) + if (DID_SUCCEED(resize(newSize))) { stack->pushBool(true); - else + } else { stack->pushBool(false); + } return STATUS_OK; } @@ -146,10 +155,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetBool") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) + if (!checkBounds(script, start, sizeof(bool))) { stack->pushNULL(); - else + } else { stack->pushBool(*(bool *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -160,10 +170,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetByte") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) + if (!checkBounds(script, start, sizeof(byte))) { stack->pushNULL(); - else + } else { stack->pushInt(*(byte *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -174,10 +185,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) + if (!checkBounds(script, Start, sizeof(short))) { stack->pushNULL(); - else + } else { stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + } return STATUS_OK; } @@ -188,10 +200,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) + if (!checkBounds(script, start, sizeof(int))) { stack->pushNULL(); - else + } else { stack->pushInt(*(int *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -202,10 +215,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetFloat") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) + if (!checkBounds(script, start, sizeof(float))) { stack->pushNULL(); - else + } else { stack->pushFloat(*(float *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -216,10 +230,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetDouble") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) + if (!checkBounds(script, start, sizeof(double))) { stack->pushNULL(); - else + } else { stack->pushFloat(*(double *)((byte *)_buffer + start)); + } return STATUS_OK; } @@ -242,9 +257,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } } - if (!checkBounds(script, start, length)) + if (!checkBounds(script, start, length)) { stack->pushNULL(); - else { + } else { char *str = new char[length + 1]; strncpy(str, (const char *)_buffer + start, length); str[length] = '\0'; @@ -260,9 +275,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "GetPointer") == 0) { stack->correctParams(1); int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) + if (!checkBounds(script, start, sizeof(void *))) { stack->pushNULL(); - else { + } else { void *pointer = *(void **)((byte *)_buffer + start); SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); stack->pushNative(buf, false); @@ -278,9 +293,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); bool val = stack->pop()->getBool(); - if (!checkBounds(script, start, sizeof(bool))) + if (!checkBounds(script, start, sizeof(bool))) { stack->pushBool(false); - else { + } else { *(bool *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -295,9 +310,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); byte val = (byte)stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) + if (!checkBounds(script, start, sizeof(byte))) { stack->pushBool(false); - else { + } else { *(byte *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -312,9 +327,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); short val = (short)stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(short))) + if (!checkBounds(script, start, sizeof(short))) { stack->pushBool(false); - else { + } else { *(short *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -329,9 +344,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); int val = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) + if (!checkBounds(script, start, sizeof(int))) { stack->pushBool(false); - else { + } else { *(int *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -346,9 +361,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); float val = (float)stack->pop()->getFloat(); - if (!checkBounds(script, start, sizeof(float))) + if (!checkBounds(script, start, sizeof(float))) { stack->pushBool(false); - else { + } else { *(float *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -363,9 +378,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); double val = stack->pop()->getFloat(); - if (!checkBounds(script, start, sizeof(double))) + if (!checkBounds(script, start, sizeof(double))) { stack->pushBool(false); - else { + } else { *(double *)((byte *)_buffer + start) = val; stack->pushBool(true); } @@ -380,9 +395,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt int start = stack->pop()->getInt(); const char *val = stack->pop()->getString(); - if (!checkBounds(script, start, strlen(val) + 1)) + if (!checkBounds(script, start, strlen(val) + 1)) { stack->pushBool(false); - else { + } else { memcpy((byte *)_buffer + start, val, strlen(val) + 1); stack->pushBool(true); } @@ -395,11 +410,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "SetPointer") == 0) { stack->correctParams(2); int start = stack->pop()->getInt(); - /* ScValue *Val = */ stack->pop(); + /* ScValue *val = */ stack->pop(); - if (!checkBounds(script, start, sizeof(void *))) + if (!checkBounds(script, start, sizeof(void *))) { stack->pushBool(false); - else { + } else { /* int Pointer = (int)Val->getMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); @@ -426,9 +441,9 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } stack->pushNULL(); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -450,9 +465,9 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) { if (strcmp(name, "Size") == 0) { _scValue->setInt(_size); return _scValue; + } else { + return BaseScriptable::scGetProperty(name); } - - else return BaseScriptable::scGetProperty(name); } @@ -487,12 +502,16 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_size)); if (persistMgr->getIsSaving()) { - if (_size > 0) persistMgr->putBytes((byte *)_buffer, _size); + if (_size > 0) { + persistMgr->putBytes((byte *)_buffer, _size); + } } else { if (_size > 0) { _buffer = malloc(_size); persistMgr->getBytes((byte *)_buffer, _size); - } else _buffer = NULL; + } else { + _buffer = NULL; + } } return STATUS_OK; @@ -501,8 +520,11 @@ bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// int SXMemBuffer::scCompare(BaseScriptable *val) { - if (_buffer == val->scToMemBuffer()) return 0; - else return 1; + if (_buffer == val->scToMemBuffer()) { + return 0; + } else { + return 1; + } } } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 385d7ca746..1c7349bd8d 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -61,13 +61,17 @@ SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { setStringVal(val->getString()); } - if (_capacity == 0) setStringVal(""); + if (_capacity == 0) { + setStringVal(""); + } } ////////////////////////////////////////////////////////////////////////// SXString::~SXString() { - if (_string) delete[] _string; + if (_string) { + delete[] _string; + } } @@ -87,8 +91,11 @@ void SXString::setStringVal(const char *val) { ////////////////////////////////////////////////////////////////////////// const char *SXString::scToString() { - if (_string) return _string; - else return "[null string]"; + if (_string) { + return _string; + } else { + return "[null string]"; + } } @@ -108,22 +115,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int start = stack->pop()->getInt(); int end = stack->pop()->getInt(); - if (end < start) BaseUtils::swap(&start, &end); + if (end < start) { + BaseUtils::swap(&start, &end); + } //try { WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } //WideString subStr = str.substr(start, end - start + 1); WideString subStr(str.c_str() + start, end - start + 1); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } // } catch (std::exception &) { // stack->pushNULL(); // } @@ -146,22 +157,26 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack return STATUS_OK; } - if (val->isNULL()) len = strlen(_string) - start; + if (val->isNULL()) { + len = strlen(_string) - start; + } // try { WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } // WideString subStr = str.substr(start, len); WideString subStr(str.c_str() + start, len); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } // } catch (std::exception &) { // stack->pushNULL(); // } @@ -176,17 +191,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } str.toUppercase(); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } return STATUS_OK; } @@ -198,17 +215,19 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(0); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } str.toLowercase(); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { stack->pushString(StringUtil::wideToUtf8(str).c_str()); - else + } else { stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } return STATUS_OK; } @@ -223,16 +242,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int index = stack->pop()->getInt(); WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { toFind = StringUtil::utf8ToWide(strToFind); - else + } else { toFind = StringUtil::ansiToWide(strToFind); + } int indexOf = StringUtil::indexOf(str, toFind, index); stack->pushInt(indexOf); @@ -247,7 +268,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); ScValue *val = stack->pop(); char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) strcpy(separators, val->getString()); + if (!val->isNULL()) { + strcpy(separators, val->getString()); + } SXArray *array = new SXArray(_gameRef); if (!array) { @@ -257,16 +280,18 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { str = StringUtil::utf8ToWide(_string); - else + } else { str = StringUtil::ansiToWide(_string); + } WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { delims = StringUtil::utf8ToWide(separators); - else + } else { delims = StringUtil::ansiToWide(separators); + } Common::Array parts; @@ -298,10 +323,11 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { WideString &part = (*it); - if (_gameRef->_textEncoding == TEXT_UTF8) + if (_gameRef->_textEncoding == TEXT_UTF8) { val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - else + } else { val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + } array->push(val); delete val; @@ -310,9 +336,9 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushNative(array, false); return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -334,8 +360,9 @@ ScValue *SXString::scGetProperty(const char *name) { if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); - } else + } else { _scValue->setInt(strlen(_string)); + } return _scValue; } @@ -345,9 +372,9 @@ ScValue *SXString::scGetProperty(const char *name) { else if (strcmp(name, "Capacity") == 0) { _scValue->setInt(_capacity); return _scValue; + } else { + return _scValue; } - - else return _scValue; } @@ -358,8 +385,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Capacity") == 0) { int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) _gameRef->LOG(0, "Warning: cannot lower string capacity"); - else if (newCap != _capacity) { + if (newCap < (int32)(strlen(_string) + 1)) { + _gameRef->LOG(0, "Warning: cannot lower string capacity"); + } else if (newCap != _capacity) { char *newStr = new char[newCap]; if (newStr) { memset(newStr, 0, newCap); @@ -370,9 +398,9 @@ bool SXString::scSetProperty(const char *name, ScValue *value) { } } return STATUS_OK; + } else { + return STATUS_FAILED; } - - else return STATUS_FAILED; } @@ -384,12 +412,16 @@ bool SXString::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_capacity)); if (persistMgr->getIsSaving()) { - if (_capacity > 0) persistMgr->putBytes((byte *)_string, _capacity); + if (_capacity > 0) { + persistMgr->putBytes((byte *)_string, _capacity); + } } else { if (_capacity > 0) { _string = new char[_capacity]; persistMgr->getBytes((byte *)_string, _capacity); - } else _string = NULL; + } else { + _string = NULL; + } } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 74cc7a57ee..0d4ea54b8c 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -96,16 +96,22 @@ ScValue *ScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) return NULL; - else return _values[_sP]; + if (_sP < 0 || _sP >= _values.getSize()) { + return NULL; + } else { + return _values[_sP]; + } } ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getAt(int index) { index = _sP - index; - if (index < 0 || index >= _values.getSize()) return NULL; - else return _values[index]; + if (index < 0 || index >= _values.getSize()) { + return NULL; + } else { + return _values[index]; + } } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 5e824cd10c..01cb4044ff 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -122,7 +122,9 @@ ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { void ScValue::cleanup(bool ignoreNatives) { deleteProps(); - if (_valString) delete[] _valString; + if (_valString) { + delete[] _valString; + } if (!ignoreNatives) { if (_valNative && !_persistent) { @@ -157,7 +159,9 @@ ScValue::~ScValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->getProp(name); + if (_type == VAL_VARIABLE_REF) { + return _valRef->getProp(name); + } if (_type == VAL_STRING && strcmp(name, "Length") == 0) { _gameRef->_scValue->_type = VAL_INT; @@ -178,18 +182,24 @@ ScValue *ScValue::getProp(const char *name) { ScValue *ret = NULL; - if (_type == VAL_NATIVE && _valNative) ret = _valNative->scGetProperty(name); + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scGetProperty(name); + } if (ret == NULL) { _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) ret = _valIter->_value; + if (_valIter != _valObject.end()) { + ret = _valIter->_value; + } } return ret; } ////////////////////////////////////////////////////////////////////////// bool ScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) return _valRef->deleteProp(name); + if (_type == VAL_VARIABLE_REF) { + return _valRef->deleteProp(name); + } _valIter = _valObject.find(name); if (_valIter != _valObject.end()) { @@ -204,8 +214,9 @@ bool ScValue::deleteProp(const char *name) { ////////////////////////////////////////////////////////////////////////// bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->setProp(name, val); + } bool ret = STATUS_FAILED; if (_type == VAL_NATIVE && _valNative) { @@ -219,15 +230,19 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs if (_valIter != _valObject.end()) { newVal = _valIter->_value; } - if (!newVal) + if (!newVal) { newVal = new ScValue(_gameRef); - else newVal->cleanup(); + } else { + newVal->cleanup(); + } newVal->copy(val, copyWhole); newVal->_isConstVar = setAsConst; _valObject[name] = newVal; - if (_type != VAL_NATIVE) _type = VAL_OBJECT; + if (_type != VAL_NATIVE) { + _type = VAL_OBJECT; + } /* _valIter = _valObject.find(Name); @@ -250,8 +265,9 @@ bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAs ////////////////////////////////////////////////////////////////////////// bool ScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->propExists(name); + } _valIter = _valObject.find(name); return (_valIter != _valObject.end()); @@ -273,15 +289,18 @@ void ScValue::deleteProps() { void ScValue::CleanProps(bool includingNatives) { _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) _valIter->_value->setNULL(); + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { + _valIter->_value->setNULL(); + } _valIter++; } } ////////////////////////////////////////////////////////////////////////// bool ScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isNULL(); + } return (_type == VAL_NULL); } @@ -289,8 +308,9 @@ bool ScValue::isNULL() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isNative() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isNative(); + } return (_type == VAL_NATIVE); } @@ -298,8 +318,9 @@ bool ScValue::isNative() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isString() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isString(); + } return (_type == VAL_STRING); } @@ -307,8 +328,9 @@ bool ScValue::isString() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isFloat(); + } return (_type == VAL_FLOAT); } @@ -316,8 +338,9 @@ bool ScValue::isFloat() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isInt() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isInt(); + } return (_type == VAL_INT); } @@ -325,8 +348,9 @@ bool ScValue::isInt() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isBool() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isBool(); + } return (_type == VAL_BOOL); } @@ -334,8 +358,9 @@ bool ScValue::isBool() { ////////////////////////////////////////////////////////////////////////// bool ScValue::isObject() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->isObject(); + } return (_type == VAL_OBJECT); } @@ -343,8 +368,9 @@ bool ScValue::isObject() { ////////////////////////////////////////////////////////////////////////// TValType ScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getType(); + } return _type; } @@ -414,8 +440,11 @@ void ScValue::setString(const char *val) { } setStringVal(val); - if (_valString) _type = VAL_STRING; - else _type = VAL_NULL; + if (_valString) { + _type = VAL_STRING; + } else { + _type = VAL_NULL; + } } void ScValue::setString(const Common::String &val) { @@ -450,7 +479,9 @@ void ScValue::setNULL() { if (_valNative && !_persistent) { _valNative->_refCount--; - if (_valNative->_refCount <= 0) delete _valNative; + if (_valNative->_refCount <= 0) { + delete _valNative; + } } _valNative = NULL; deleteProps(); @@ -472,7 +503,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { - if (_valNative != val) delete _valNative; + if (_valNative != val) { + delete _valNative; + } _valNative = NULL; } } @@ -481,7 +514,9 @@ void ScValue::setNative(BaseScriptable *val, bool persistent) { _persistent = persistent; _valNative = val; - if (_valNative && !_persistent) _valNative->_refCount++; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } } } @@ -507,8 +542,9 @@ void ScValue::setReference(ScValue *val) { ////////////////////////////////////////////////////////////////////////// bool ScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getBool(); + } switch (_type) { case VAL_BOOL: @@ -534,7 +570,9 @@ bool ScValue::getBool(bool defaultVal) { ////////////////////////////////////////////////////////////////////////// int ScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) return _valRef->getInt(); + if (_type == VAL_VARIABLE_REF) { + return _valRef->getInt(); + } switch (_type) { case VAL_BOOL: @@ -560,8 +598,9 @@ int ScValue::getInt(int defaultVal) { ////////////////////////////////////////////////////////////////////////// double ScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getFloat(); + } switch (_type) { case VAL_BOOL: @@ -586,19 +625,23 @@ double ScValue::getFloat(double defaultVal) { ////////////////////////////////////////////////////////////////////////// void *ScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getMemBuffer(); + } - if (_type == VAL_NATIVE) + if (_type == VAL_NATIVE) { return _valNative->scToMemBuffer(); - else return (void *)NULL; + } else { + return (void *)NULL; + } } ////////////////////////////////////////////////////////////////////////// const char *ScValue::getString() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getString(); + } switch (_type) { case VAL_OBJECT: @@ -647,11 +690,15 @@ const char *ScValue::getString() { ////////////////////////////////////////////////////////////////////////// BaseScriptable *ScValue::getNative() { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->getNative(); + } - if (_type == VAL_NATIVE) return _valNative; - else return NULL; + if (_type == VAL_NATIVE) { + return _valNative; + } else { + return NULL; + } } @@ -668,12 +715,16 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { if (_valNative && !_persistent) { _valNative->_refCount--; if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) delete _valNative; + if (_valNative != orig->_valNative) { + delete _valNative; + } _valNative = NULL; } } - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) orig = orig->_valRef; + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) { + orig = orig->_valRef; + } cleanup(true); @@ -687,7 +738,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { _persistent = orig->_persistent; _valNative = orig->_valNative; - if (_valNative && !_persistent) _valNative->_refCount++; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } //!!!! ref->native++ // copy properties @@ -698,7 +751,9 @@ void ScValue::copy(ScValue *orig, bool copyWhole) { _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); orig->_valIter++; } - } else _valObject.clear(); + } else { + _valObject.clear(); + } } @@ -730,7 +785,9 @@ void ScValue::setValue(ScValue *val) { } } // otherwise just copy everything - else copy(val); + else { + copy(val); + } } @@ -841,39 +898,60 @@ int ScValue::compare(ScValue *val1, ScValue *val2) { // same class? if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { return val1->getNative()->scCompare(val2->getNative()); - } else return strcmp(val1->getString(), val2->getString()); + } else { + return strcmp(val1->getString(), val2->getString()); + } } // both objects? - if (val1->isObject() && val2->isObject()) return -1; + if (val1->isObject() && val2->isObject()) { + return -1; + } // null states - if (val1->isNULL() && !val2->isNULL()) return -1; - else if (!val1->isNULL() && val2->isNULL()) return 1; - else if (val1->isNULL() && val2->isNULL()) return 0; + if (val1->isNULL() && !val2->isNULL()) { + return -1; + } else if (!val1->isNULL() && val2->isNULL()) { + return 1; + } else if (val1->isNULL() && val2->isNULL()) { + return 0; + } // one of them is string? convert both to string - if (val1->isString() || val2->isString()) return strcmp(val1->getString(), val2->getString()); + if (val1->isString() || val2->isString()) { + return strcmp(val1->getString(), val2->getString()); + } // one of them is float? if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) return -1; - else if (val1->getFloat() > val2->getFloat()) return 1; - else return 0; + if (val1->getFloat() < val2->getFloat()) { + return -1; + } else if (val1->getFloat() > val2->getFloat()) { + return 1; + } else { + return 0; + } } // otherwise compare as int's - if (val1->getInt() < val2->getInt()) return -1; - else if (val1->getInt() > val2->getInt()) return 1; - else return 0; + if (val1->getInt() < val2->getInt()) { + return -1; + } else if (val1->getInt() > val2->getInt()) { + return 1; + } else { + return 0; + } } ////////////////////////////////////////////////////////////////////////// int ScValue::compareStrict(ScValue *val1, ScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) return -1; - else return ScValue::compare(val1, val2); + if (val1->getTypeTolerant() != val2->getTypeTolerant()) { + return -1; + } else { + return ScValue::compare(val1, val2); + } } @@ -1013,16 +1091,18 @@ bool ScValue::dbgSetVal() { ////////////////////////////////////////////////////////////////////////// int ScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) + if (_valNative && _valNative->_scProp) { return _valNative->_scProp->dbgGetNumProperties(); - else return _valObject.size(); + } else { + return _valObject.size(); + } } ////////////////////////////////////////////////////////////////////////// bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) + if (_valNative && _valNative->_scProp) { return _valNative->_scProp->dbgGetProperty(index, name, value); - else { + } else { int count = 0; _valIter = _valObject.begin(); while (_valIter != _valObject.end()) { @@ -1040,8 +1120,9 @@ bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value ////////////////////////////////////////////////////////////////////////// bool ScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) + if (_type == VAL_VARIABLE_REF) { return _valRef->dbgGetDescription(buf, bufSize); + } if (_type == VAL_NATIVE) { _valNative->scDebuggerDesc(buf, bufSize); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 8cc8c21948..9cd9e4cc75 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -57,7 +57,9 @@ BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// BaseSound::~BaseSound() { - if (_sound) _gameRef->_soundMgr->removeSound(_sound); + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + } _sound = NULL; delete[] _soundFilename; @@ -83,7 +85,9 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo _soundStreamed = streamed; return STATUS_OK; - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -91,22 +95,32 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { - if (_soundPosition) _sound->setPosition(_soundPosition); + if (_soundPosition) { + _sound->setPosition(_soundPosition); + } _sound->setLooping(_soundLooping); _sound->setPrivateVolume(_soundPrivateVolume); _sound->setLoopStart(_soundLoopStart); _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) return _sound->resume(); - else return STATUS_OK; - } else return STATUS_FAILED; + if (_soundPlaying) { + return _sound->resume(); + } else { + return STATUS_OK; + } + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getLength() { - if (_sound) return _sound->getLength(); - else return 0; + if (_sound) { + return _sound->getLength(); + } else { + return 0; + } } @@ -115,7 +129,9 @@ bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; return _sound->play(looping, _soundPosition); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -124,7 +140,9 @@ bool BaseSound::stop() { if (_sound) { _soundPaused = false; return _sound->stop(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -132,9 +150,13 @@ bool BaseSound::stop() { bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; - if (freezePaused) _sound->_freezePaused = true; + if (freezePaused) { + _sound->_freezePaused = true; + } return _sound->pause(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -143,7 +165,9 @@ bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; return _sound->resume(); - } else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } @@ -153,8 +177,9 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { _soundPlaying = _sound->isPlaying(); _soundLooping = _sound->_looping; _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) + if (_soundPlaying) { _soundPosition = _sound->getPosition(); + } _soundLoopStart = _sound->_loopStart; _soundFreezePaused = _sound->_freezePaused; } @@ -195,64 +220,81 @@ bool BaseSound::isPaused() { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPositionTime(uint32 time) { - if (!_sound) return STATUS_FAILED; + if (!_sound) { + return STATUS_FAILED; + } _soundPosition = time; bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) + if (_sound->isPlaying()) { _soundPosition = 0; + } return ret; } ////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getPositionTime() { - if (!_sound) return 0; + if (!_sound) { + return 0; + } - if (!_sound->isPlaying()) + if (!_sound->isPlaying()) { return 0; - else return _sound->getPosition(); + } else { + return _sound->getPosition(); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolumePercent(int percent) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->setPrivateVolume(percent * 255 / 100); + } else { + return _sound->setPrivateVolume(percent * 255 / 100); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolume(int volume) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->setPrivateVolume(volume); + } else { + return _sound->setPrivateVolume(volume); + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else return _sound->_privateVolume = volume; + } else { + return _sound->_privateVolume = volume; + } } ////////////////////////////////////////////////////////////////////////// int BaseSound::getVolumePercent() { - if (!_sound) + if (!_sound) { return 0; - else return _sound->_privateVolume * 100 / 255; + } else { + return _sound->_privateVolume * 100 / 255; + } } ////////////////////////////////////////////////////////////////////////// int BaseSound::getVolume() { - if (!_sound) + if (!_sound) { return 0; - else return _sound->_privateVolume; + } else { + return _sound->_privateVolume; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::setLoopStart(uint32 pos) { - if (!_sound) + if (!_sound) { return STATUS_FAILED; - else { + } else { _sound->setLoopStart(pos); return STATUS_OK; } @@ -260,16 +302,19 @@ bool BaseSound::setLoopStart(uint32 pos) { ////////////////////////////////////////////////////////////////////////// bool BaseSound::setPan(float pan) { - if (_sound) + if (_sound) { return _sound->setPan(pan); - else return STATUS_FAILED; + } else { + return STATUS_FAILED; + } } ////////////////////////////////////////////////////////////////////////// bool BaseSound::ApplyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) + if (!_sound) { return STATUS_OK; + } if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { bool ret = _sound->applyFX(type, param1, param2, param3, param4); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index cebc3a3765..74aae59e3d 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -61,8 +61,9 @@ BaseSoundMgr::~BaseSoundMgr() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) + for (uint32 i = 0; i < _sounds.size(); i++) { delete _sounds[i]; + } _sounds.clear(); #if 0 BASS_Free(); @@ -93,8 +94,9 @@ bool BaseSoundMgr::initialize() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::initLoop() { - if (!_soundAvailable) + if (!_soundAvailable) { return STATUS_OK; + } #if 0 BASS_Update(500); @@ -105,8 +107,9 @@ bool BaseSoundMgr::initLoop() { ////////////////////////////////////////////////////////////////////////// BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) + if (!_soundAvailable) { return NULL; + } BaseSoundBuffer *sound; @@ -123,7 +126,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun } sound = new BaseSoundBuffer(_gameRef); - if (!sound) return NULL; + if (!sound) { + return NULL; + } sound->setStreaming(streamed); sound->setType(type); @@ -149,8 +154,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) + if (!sound) { return STATUS_FAILED; + } // Make sure the master-volume is applied to the sound. sound->updateVolume(); @@ -177,8 +183,9 @@ bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) + if (!_soundAvailable) { return STATUS_OK; + } switch (type) { case Audio::Mixer::kSFXSoundType: -- cgit v1.2.3 From f5cbee18f86de7c5c423fc855c8466e6ce01c714 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 17:45:32 +0200 Subject: WINTERMUTE: Remove unused code in BaseFontTTF --- .../wintermute/base/font/base_font_truetype.cpp | 46 +--------------------- engines/wintermute/base/font/base_font_truetype.h | 30 -------------- 2 files changed, 2 insertions(+), 74 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 420df58b74..e14d79cb42 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -61,13 +61,7 @@ BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { _cachedTexts[i] = NULL; } -#if 0 - _fTFace = NULL; - _fTStream = NULL; -#endif - - _ascender = _descender = _lineHeight = _pointSize = _underlinePos = 0; - _horDpi = _vertDpi = 0; + _lineHeight = 0; _maxCharWidth = _maxCharHeight = 0; } @@ -85,15 +79,6 @@ BaseFontTT::~BaseFontTT(void) { delete _deletableFont; _font = NULL; - -#if 0 - if (_fTFace) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - } - delete[] _fTStream; - _fTStream = NULL; -#endif } @@ -258,7 +243,7 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { //TextLineList lines; - // TODO + // TODO: Use WideString-conversion here. //WrapText(text, width, maxHeight, lines); Common::Array lines; _font->wordWrapText(text, width, lines); @@ -402,33 +387,6 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, return NULL; } -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect) { - //SDL_BlitSurface(src, NULL, target, targetRect); - warning("BaseFontTT::BlitSurface - not ported yet"); -#if 0 - for (int y = 0; y < src->h; y++) { - if (targetRect->y + y < 0 || targetRect->y + y >= target->h) { - continue; - } - - - uint8 *srcBuf = (uint8 *)src->pixels + y * src->pitch; - uint8 *tgtBuf = (uint8 *)target->pixels + (y + targetRect->y) * target->pitch; - - uint32 *srcBuf32 = (uint32 *)srcBuf; - uint32 *tgtBuf32 = (uint32 *)tgtBuf; - - for (int x = 0; x < src->w; x++) { - if (targetRect->x + x < 0 || targetRect->x + x >= target->w) { - continue; - } - - tgtBuf32[x + targetRect->x] = srcBuf32[x]; - } - } -#endif -} ////////////////////////////////////////////////////////////////////////// int BaseFontTT::getLetterHeight() { diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index f8c5eee74d..434fa7100c 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -94,27 +94,6 @@ public: uint32 _color; }; - ////////////////////////////////////////////////////////////////////////// - class TextLine { - public: - TextLine(const WideString &text, int width) { - _text = text; - _width = width; - } - - const WideString getText() const { - return _text; - } - int getWidth() const { - return _width; - } - private: - WideString _text; - int _width; - }; - typedef Common::List TextLineList; - - public: DECLARE_PERSISTENT(BaseFontTT, BaseFont) BaseFontTT(BaseGame *inGame); @@ -138,12 +117,9 @@ public: private: bool parseLayer(BaseTTFontLayer *layer, byte *buffer); - void wrapText(const WideString &text, int maxWidth, int maxHeight, TextLineList &lines); void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - void blitSurface(Graphics::Surface *src, Graphics::Surface *target, Common::Rect *targetRect); - BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; @@ -153,13 +129,7 @@ private: const Graphics::Font *_font; const Graphics::Font *_fallbackFont; - float _ascender; - float _descender; float _lineHeight; - float _underlinePos; - float _pointSize; - float _vertDpi; - float _horDpi; size_t _maxCharWidth; size_t _maxCharHeight; -- cgit v1.2.3 From e9a847fb352dd0e59fe45fd27c41a93d40f2bd1f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 18:20:58 +0200 Subject: WINTERMUTE: Remove #if 0 - commented out code. --- engines/wintermute/base/base_game.cpp | 18 +-- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/gfx/base_image.cpp | 8 +- .../base/gfx/osystem/base_render_osystem.cpp | 49 +------- .../base/gfx/osystem/base_surface_osystem.cpp | 134 ++------------------- .../base/gfx/osystem/base_surface_osystem.h | 2 - .../wintermute/base/sound/base_sound_buffer.cpp | 93 +------------- .../wintermute/base/sound/base_sound_manager.cpp | 17 --- engines/wintermute/base/sound/base_sound_manager.h | 1 - 9 files changed, 15 insertions(+), 309 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 9de183660e..41ea01dffd 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -616,7 +616,6 @@ bool BaseGame::initLoop() { getDebugMgr()->onGameTick(); _renderer->initLoop(); - _soundMgr->initLoop(); updateMusicCrossfade(); _surfaceStorage->initLoop(); @@ -4023,17 +4022,12 @@ void BaseGame::setWindowTitle() { if (_textEncoding == TEXT_UTF8) { utf8Title = Utf8String(title); } else { - warning("BaseGame::SetWindowTitle -Ignoring textencoding"); + warning("BaseGame::SetWindowTitle - Ignoring textencoding"); utf8Title = Utf8String(title); /* WideString wstr = StringUtil::AnsiToWide(Title); title = StringUtil::WideToUtf8(wstr);*/ } -#if 0 - BaseRenderOSystem *renderer = static_cast(_renderer); - // TODO - - SDL_SetWindowTitle(renderer->GetSdlWindow(), title.c_str()); -#endif + warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); } } @@ -4722,18 +4716,14 @@ void BaseGame::getMousePos(Point32 *pos) { } ////////////////////////////////////////////////////////////////////////// -bool BaseGame::miniUpdate() { +void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. if (!_miniUpdateEnabled) { - return STATUS_OK; + return; } if (g_system->getMillis() - _lastMiniUpdate > 200) { - if (_soundMgr) { - _soundMgr->initLoop(); - } _lastMiniUpdate = g_system->getMillis(); } - return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8da62af40a..08d1869452 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -89,7 +89,7 @@ public: uint32 _lastMiniUpdate; bool _miniUpdateEnabled; - virtual bool miniUpdate(); + virtual void miniUpdate(); void getMousePos(Point32 *Pos); Rect32 _mouseLockRect; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 571deed793..628bffff55 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -114,6 +114,7 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { + warning("BaseImage::resize(%d, %d), stubbed", newWidth, newHeight); #if 0 if (!_bitmap) { return STATUS_FAILED; @@ -128,13 +129,6 @@ bool BaseImage::resize(int newWidth, int newHeight) { FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); - if (newImg) { - FreeImage_Unload(_bitmap); - _bitmap = newImg; - return STATUS_OK; - } else { - return STATUS_FAILED; - } #endif return false; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index e465194e58..6913b3434c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -114,25 +114,10 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; -#if 0 - if (_renderer) { - SDL_DestroyRenderer(_renderer); - } - if (_win) { - SDL_DestroyWindow(_win); - } - SDL_Quit(); -#endif } ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { - //if (SDL_Init(SDL_INIT_VIDEO) < 0) return STATUS_FAILED; - -#if 0 - SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 0); - SDL_GL_SetAttribute(SDL_GL_RETAINED_BACKING, 1); -#endif _width = width; _height = height; _renderRect.setWidth(_width); @@ -192,15 +177,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; -#if 0 - Uint32 flags = SDL_WINDOW_SHOWN; -#endif -#ifdef __IPHONEOS__ - //flags |= SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS; -#endif - - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); -// if (!windowed) flags |= SDL_WINDOW_FULLSCREEN; + //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); @@ -211,33 +188,9 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); return STATUS_FAILED; } -#if 0 - _win = SDL_CreateWindow("WME Lite", - SDL_WINDOWPOS_UNDEFINED, - SDL_WINDOWPOS_UNDEFINED, - _realWidth, _realHeight, - flags); - - if (!_win) { - return STATUS_FAILED; - } -#endif g_system->showMouse(false); -#ifdef __IPHONEOS__ - // SDL defaults to OGL ES2, which doesn't work on old devices - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengles"); -#else - //SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); -#endif -#if 0 - _renderer = SDL_CreateRenderer(_win, -1, 0); - - if (!_renderer) { - return STATUS_FAILED; - } -#endif _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _active = true; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 4b680e2793..b77abf6a79 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -131,11 +131,7 @@ bool BaseSurfaceOSystem::finishLoad() { bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); if (isSaveGameGrayscale) { warning("grayscaleConversion not yet implemented"); - /* FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); - if (newImg) { - FreeImage_Unload(img); - img = newImg; - }*/ + // FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO } // no alpha, set color key @@ -161,31 +157,6 @@ bool BaseSurfaceOSystem::finishLoad() { } _hasAlpha = hasTransparency(_surface); - //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); //TODO - //_texture = SdlUtil::CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("Surface-textures not fully ported yet"); - hasWarned = true; - } - //delete imgDecoder; -#if 0 - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surf); - if (!_texture) { - SDL_FreeSurface(surf); - delete imgDecoder; - return STATUS_FAILED; - } - - GenAlphaMask(surf); - - SDL_FreeSurface(surf); - delete imgDecoder; // TODO: Update this if ImageDecoder doesn't end up owning the surface. -#endif - _valid = true; _gameRef->addMem(_width * _height * 4); @@ -207,9 +178,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { if (!surface) { return; } -#if 0 - SDL_LockSurface(surface); -#endif + bool hasColorKey; /* uint32 colorKey; */ uint8 ckRed, ckGreen, ckBlue; @@ -239,9 +208,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } } } -#if 0 - SDL_UnlockSurface(surface); -#endif + if (!hasTransparency) { delete[] _alphaMask; _alphaMask = NULL; @@ -286,11 +253,6 @@ uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::create(int width, int height) { - warning("BaseSurfaceOSystem::Create not ported yet"); //TODO -#if 0 - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTexture(renderer->GetSdlRenderer(), SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, Width, Height); -#endif _width = width; _height = height; @@ -301,69 +263,17 @@ bool BaseSurfaceOSystem::create(int width, int height) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::createFromSDLSurface(Graphics::Surface *surface) { - warning("BaseSurfaceOSystem::CreateFromSDLSurface not ported yet"); //TODO -#if 0 - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - _texture = SDL_CreateTextureFromSurface(renderer->GetSdlRenderer(), surface); -#endif - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - _surface = new Graphics::Surface(); - _surface->copyFrom(*surface); - _width = surface->w; - _height = surface->h; -#if 0 - _gameRef->AddMem(_width * _height * 4); -#endif - _valid = true; - - return STATUS_OK; -} - ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::IsTransparentAt not ported yet"); - hasWarned = true; - } -#if 0 - int access; - int width, height; - //SDL_QueryTexture(_texture, NULL, &access, &width, &height); //TODO - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) { - return true; - } - - - StartPixelOp(); - bool ret = isTransparentAtLite(X, Y); - EndPixelOp(); - - return ret; -#endif - return 0; + return isTransparentAtLite(x, y); } ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { - //if (!_lockPixels) return false; - - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::IsTransparentAtLite not ported yet"); - hasWarned = true; + if (x < 0 || x >= _surface->w || y < 0 || y >= _surface->h) { + return true; } + if (_surface->format.bytesPerPixel == 4) { uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); uint8 r, g, b, a; @@ -374,35 +284,8 @@ bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { return false; } } -#if 0 - uint32 format; - int access; - int width, height; - - //SDL_QueryTexture(_texture, &format, &access, &width, &height); - //if (access != SDL_TEXTUREACCESS_STREAMING) return false; - if (X < 0 || X >= width || Y < 0 || Y >= height) { - return true; - } - if (!_alphaMask) { - return false; - } else { - return _alphaMask[Y * width + X] <= 128; - } -#endif return false; - /* - Uint32* dst = (Uint32*)((Uint8*)_lockPixels + Y * _lockPitch); - Uint32 pixel = dst[X]; - - SDL_PixelFormat* pixelFormat = SDL_AllocFormat(format); - Uint8 r, g, b, a; - SDL_GetRGBA(pixel, pixelFormat, &r, &g, &b, &a); - SDL_FreeFormat(pixelFormat); - - return a <= 128; - */ } ////////////////////////////////////////////////////////////////////////// @@ -533,9 +416,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo } renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); -#if 0 - SDL_RenderCopy(renderer->GetSdlRenderer(), _texture, &srcRect, &position); -#endif return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 3a8d64703f..9ed80cec50 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -44,8 +44,6 @@ public: bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); - bool createFromSDLSurface(Graphics::Surface *surface); //TODO: Rename function - bool isTransparentAt(int x, int y); bool isTransparentAtLite(int x, int y); diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index f2db0a18fb..d94f8c61b6 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -129,63 +129,6 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { BaseUtils::setString(&_filename, filename); return STATUS_OK; -#if 0 - BASS_FILEPROCS fileProc; - fileProc.close = BaseSoundBuffer::FileCloseProc; - fileProc.read = BaseSoundBuffer::FileReadProc; - fileProc.seek = BaseSoundBuffer::FileSeekProc; - fileProc.length = BaseSoundBuffer::FileLenProc; - - _stream = BASS_StreamCreateFileUser(STREAMFILE_NOBUFFER, 0, &fileProc, (void *)_file); - if (!_stream) { - _gameRef->LOG(0, "BASS error: %d while loading '%s'", BASS_ErrorGetCode(), filename); - return STATUS_FAILED; - } - - BaseUtils::setString(&_filename, filename); - - /* - bool res; - bool NewlyCreated = false; - - if (!_soundBuffer || ForceReload || _streamed){ - if (!_file) _file = _gameRef->_fileManager->openFile(filename); - if (!_file){ - _gameRef->LOG(0, "Error opening sound file '%s'", filename); - return STATUS_FAILED; - } - // switch to streamed for big files - if (!_streamed && (_file->GetSize() > MAX_NONSTREAMED_FILE_SIZE && !_gameRef->_forceNonStreamedSounds)) SetStreaming(true); - } - - // create buffer - if (!_soundBuffer){ - NewlyCreated = true; - - res = InitializeBuffer(_file); - if (DID_FAIL(res)){ - _gameRef->LOG(res, "Error creating sound buffer for file '%s'", filename); - return res; - } - } - - - - // store filename - if (!_filename){ - _filename = new char[strlen(filename)+1]; - strcpy(_filename, filename); - } - - // close file (if not streaming) - if (!_streamed && _file){ - _gameRef->_fileManager->closeFile(_file); - _file = NULL; - } - */ - - return STATUS_OK; -#endif } @@ -215,15 +158,8 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO _looping = looping; -#if 0 - - - if (_stream) { - BASS_ChannelFlags(_stream, looping ? BASS_SAMPLE_LOOP : 0, BASS_SAMPLE_LOOP); - } -#endif } ////////////////////////////////////////////////////////////////////////// @@ -314,42 +250,15 @@ uint32 BaseSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPosition(uint32 pos) { warning("BaseSoundBuffer::SetPosition - not implemented yet"); -#if 0 - if (_stream) { - QWORD pos = BASS_ChannelSeconds2Bytes(_stream, (float)Pos / 1000.0f); - BASS_ChannelSetPosition(_stream, pos, BASS_POS_BYTE); - } -#endif return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setLoopStart(uint32 pos) { _loopStart = pos; -#if 0 - if (_stream) { - if (_sync) { - BASS_ChannelRemoveSync(_stream, _sync); - _sync = NULL; - } - if (_loopStart > 0) { - QWORD len = BASS_ChannelGetLength(_stream, BASS_POS_BYTE); - _sync = BASS_ChannelSetSync(_stream, BASS_SYNC_POS | BASS_SYNC_MIXTIME, len, BaseSoundBuffer::LoopSyncProc, (void *)this); - } - } -#endif return STATUS_OK; } -#if 0 -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::LoopSyncProc(HSYNC handle, uint32 channel, uint32 data, void *user) { - BaseSoundBuffer *soundBuf = static_cast(user); - QWORD pos = BASS_ChannelSeconds2Bytes(channel, (float)soundBuf->GetLoopStart() / 1000.0f); - if (!BASS_ChannelSetPosition(channel, pos, BASS_POS_BYTE)) - BASS_ChannelSetPosition(channel, 0, BASS_POS_BYTE); -} -#endif ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPan(float pan) { if (_handle) { diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 74aae59e3d..d2e640e3f3 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -65,9 +65,6 @@ bool BaseSoundMgr::cleanup() { delete _sounds[i]; } _sounds.clear(); -#if 0 - BASS_Free(); -#endif return STATUS_OK; } @@ -91,20 +88,6 @@ bool BaseSoundMgr::initialize() { return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::initLoop() { - if (!_soundAvailable) { - return STATUS_OK; - } -#if 0 - - BASS_Update(500); -#endif - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) { diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 53caffbe61..464330c733 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -55,7 +55,6 @@ public: bool removeSound(BaseSoundBuffer *sound); BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initLoop(); bool initialize(); bool _soundAvailable; BaseSoundMgr(BaseGame *inGame); -- cgit v1.2.3 From 91edc76b3e98a3b94ca67c17bdc740f272572759 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:24:04 +0200 Subject: WINTERMUTE: Avoid crashing when a file doesn't exist in a DCP. --- engines/wintermute/base/base_file_manager.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index ff693e055c..94f561997e 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -259,6 +259,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } } Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + if (!entry) { + return NULL; + } file = entry->createReadStream(); return file; } -- cgit v1.2.3 From eb22e36d5e12b64442ce23c656227483dd9cf61e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:31:08 +0200 Subject: WINTERMUTE: Disable SaveGame thumbs for now --- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index e067241589..b29935d943 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -52,6 +52,8 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::open(const Common::String &filename) { close(); + warning("SaveGame-thumbs disabled for now"); + return STATUS_FAILED; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { return STATUS_FAILED; -- cgit v1.2.3 From 4eda234611bd77f053defe9e61d592b308270eaa Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 19:41:18 +0200 Subject: WINTERMUTE: Replace BaseArray with a templated subclass of Common::Array. This needs additional cleanup, but compiles and runs at this point. --- engines/wintermute/base/base_frame.cpp | 12 ++++++------ engines/wintermute/base/base_frame.h | 4 ++-- engines/wintermute/base/base_game.cpp | 20 ++++++++++---------- engines/wintermute/base/base_game.h | 8 ++++---- engines/wintermute/base/base_region.cpp | 8 ++++---- engines/wintermute/base/base_region.h | 2 +- engines/wintermute/base/base_script_holder.cpp | 4 ++-- engines/wintermute/base/base_script_holder.h | 2 +- engines/wintermute/base/base_sprite.cpp | 6 +++--- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font_storage.h | 2 +- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 12 ++++++------ engines/wintermute/base/particles/part_emitter.h | 6 +++--- engines/wintermute/base/scriptables/script.h | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 16 ++++++++-------- engines/wintermute/base/scriptables/script_engine.h | 8 ++++---- engines/wintermute/base/scriptables/script_stack.cpp | 8 ++++---- engines/wintermute/base/scriptables/script_stack.h | 2 +- 21 files changed, 66 insertions(+), 66 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 68b866bbf5..208d6037d9 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -64,13 +64,13 @@ BaseFrame::~BaseFrame() { for (int i = 0; i < _subframes.getSize(); i++) { delete _subframes[i]; } - _subframes.removeAll(); + _subframes.clear(); for (int i = 0; i < _applyEvent.getSize(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } - _applyEvent.removeAll(); + _applyEvent.clear(); } @@ -334,7 +334,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { sub->_editorSelected = editorSelected; - _subframes.insertAt(0, sub); + _subframes.insert_at(0, sub); return STATUS_OK; } @@ -495,7 +495,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac for (int i = 0; i < _subframes.getSize(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; - _subframes.removeAt(i); + _subframes.remove_at(i); break; } } @@ -550,7 +550,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (index >= _subframes.getSize()) { _subframes.add(sub); } else { - _subframes.insertAt(index, sub); + _subframes.insert_at(index, sub); } stack->pushNative(sub, true); @@ -598,7 +598,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac for (int i = 0; i < _applyEvent.getSize(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { delete[] _applyEvent[i]; - _applyEvent.removeAt(i); + _applyEvent.remove_at(i); break; } } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index dcbf74bc47..c8e9cbb400 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -51,14 +51,14 @@ public: int _moveY; int _moveX; uint32 _delay; - BaseArray _subframes; + BaseArray _subframes; bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); virtual ~BaseFrame(); - BaseArray _applyEvent; + BaseArray _applyEvent; // scripting interface virtual ScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 41ea01dffd..00f5731787 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -356,9 +356,9 @@ bool BaseGame::cleanup() { delete _regObjects[i]; _regObjects[i] = NULL; } - _regObjects.removeAll(); + _regObjects.clear(); - _windows.removeAll(); // refs only + _windows.clear(); // refs only _focusedWindow = NULL; // ref only delete[] _saveImageName; @@ -382,7 +382,7 @@ bool BaseGame::cleanup() { _scripts[i]->_owner = NULL; _scripts[i]->finish(); } - _scripts.removeAll(); + _scripts.clear(); _fontStorage->removeFont(_systemFont); _systemFont = NULL; @@ -393,9 +393,9 @@ bool BaseGame::cleanup() { for (int i = 0; i < _quickMessages.getSize(); i++) { delete _quickMessages[i]; } - _quickMessages.removeAll(); + _quickMessages.clear(); - _viewportStack.removeAll(); + _viewportStack.clear(); _viewportSP = -1; setName(NULL); @@ -2906,7 +2906,7 @@ bool BaseGame::displayQuickMsg() { for (int i = 0; i < _quickMessages.getSize(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; - _quickMessages.removeAt(i); + _quickMessages.remove_at(i); i--; } } @@ -2927,7 +2927,7 @@ bool BaseGame::displayQuickMsg() { void BaseGame::quickMessage(const char *text) { if (_quickMessages.getSize() >= MAX_QUICK_MSG) { delete _quickMessages[0]; - _quickMessages.removeAt(0); + _quickMessages.remove_at(0); } _quickMessages.add(new BaseQuickMsg(_gameRef, text)); } @@ -2962,7 +2962,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { // is it a window? for (int i = 0; i < _windows.getSize(); i++) { if ((BaseObject *)_windows[i] == object) { - _windows.removeAt(i); + _windows.remove_at(i); // get new focused window if (_focusedWindow == object) { @@ -2986,7 +2986,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { // destroy object for (int i = 0; i < _regObjects.getSize(); i++) { if (_regObjects[i] == object) { - _regObjects.removeAt(i); + _regObjects.remove_at(i); if (!_loadInProgress) { SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); } @@ -3864,7 +3864,7 @@ bool BaseGame::focusWindow(UIWindow *window) { for (int i = 0; i < _windows.getSize(); i++) { if (_windows[i] == window) { if (i < _windows.getSize() - 1) { - _windows.removeAt(i); + _windows.remove_at(i); _windows.add(window); _gameRef->_focusedWindow = window; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 08d1869452..ecb698b70a 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -358,10 +358,10 @@ private: bool stopVideo(); BaseDebugger *_debugMgr; - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; - BaseArray _regObjects; + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; AnsiString getDeviceType() const; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 67cda44ece..13815a5958 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -63,7 +63,7 @@ void BaseRegion::cleanup() { for (int i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); BasePlatform::setRectEmpty(&_rect); _editorSelectedPoint = -1; @@ -165,7 +165,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { for (i = 0; i < _points.getSize(); i++) { delete _points[i]; } - _points.removeAll(); + _points.clear(); while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -249,7 +249,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int y = stack->pop()->getInt(); if (Index >= 0 && Index < _points.getSize()) { - _points.insertAt(Index, new BasePoint(x, y)); + _points.insert_at(Index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -293,7 +293,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta delete _points[index]; _points[index] = NULL; - _points.removeAt(index); + _points.remove_at(index); createRegion(); stack->pushBool(true); diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index a15e0cca2a..3b4b28030d 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -53,7 +53,7 @@ public: bool loadFile(const char *filename); bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; - BaseArray _points; + BaseArray _points; virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); // scripting interface diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index b90b4dc60a..131acf326f 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -64,7 +64,7 @@ bool BaseScriptHolder::cleanup() { _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } - _scripts.removeAll(); + _scripts.clear(); return STATUS_OK; } @@ -336,7 +336,7 @@ bool BaseScriptHolder::addScript(const char *filename) { bool BaseScriptHolder::removeScript(ScScript *script) { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i] == script) { - _scripts.removeAt(i); + _scripts.remove_at(i); break; } } diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index ef1c389dcb..4162936ded 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -57,7 +57,7 @@ public: bool _freezable; bool _ready; - BaseArray _scripts; + BaseArray _scripts; // scripting interface virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 2fda638665..274c792263 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -92,7 +92,7 @@ void BaseSprite::cleanup() { for (int i = 0; i < _frames.getSize(); i++) { delete _frames[i]; } - _frames.removeAll(); + _frames.clear(); delete[] _editorBgFile; _editorBgFile = NULL; @@ -578,7 +578,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta _lastFrameTime = 0; } delete _frames[i]; - _frames.removeAt(i); + _frames.remove_at(i); break; } } @@ -653,7 +653,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (index >= _frames.getSize()) { _frames.add(frame); } else { - _frames.insertAt(index, frame); + _frames.insert_at(index, frame); } stack->pushNative(frame, true); diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 6ddec287d6..477ab70878 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -75,7 +75,7 @@ public: bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); virtual ~BaseSprite(); - BaseArray _frames; + BaseArray _frames; bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 8b4fa74181..95f1ae601c 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -57,7 +57,7 @@ bool BaseFontStorage::cleanup(bool warn) { } delete _fonts[i]; } - _fonts.removeAll(); + _fonts.clear(); return STATUS_OK; } @@ -117,7 +117,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { delete _fonts[i]; - _fonts.removeAt(i); + _fonts.remove_at(i); } break; } diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 2c9c6817c3..3af9244ffe 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -46,7 +46,7 @@ public: BaseFont *addFont(const char *filename); BaseFontStorage(BaseGame *inGame); virtual ~BaseFontStorage(); - BaseArray _fonts; + BaseArray _fonts; bool initLoop(); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index e14d79cb42..ac6430d4c9 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -72,7 +72,7 @@ BaseFontTT::~BaseFontTT(void) { for (int i = 0; i < _layers.getSize(); i++) { delete _layers[i]; } - _layers.removeAll(); + _layers.clear(); delete[] _fontFile; _fontFile = NULL; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 434fa7100c..20ef531a46 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -142,7 +142,7 @@ public: int _fontHeight; char *_fontFile; - BaseArray _layers; + BaseArray _layers; void clearCache(); }; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index b16fb83abf..8b86365196 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -97,18 +97,18 @@ PartEmitter::~PartEmitter(void) { for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.removeAll(); + _particles.clear(); for (int i = 0; i < _forces.getSize(); i++) { delete _forces[i]; } - _forces.removeAll(); + _forces.clear(); for (int i = 0; i < _sprites.getSize(); i++) { delete[] _sprites[i]; } - _sprites.removeAll(); + _sprites.clear(); delete[] _emitEvent; _emitEvent = NULL; @@ -148,7 +148,7 @@ bool PartEmitter::removeSprite(const char *filename) { for (int i = 0; i < _sprites.getSize(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete[] _sprites[i]; - _sprites.removeAt(i); + _sprites.remove_at(i); return STATUS_OK; } } @@ -446,7 +446,7 @@ bool PartEmitter::removeForce(const char *name) { for (int i = 0; i < _forces.getSize(); i++) { if (scumm_stricmp(name, _forces[i]->getName()) == 0) { delete _forces[i]; - _forces.removeAt(i); + _forces.remove_at(i); return STATUS_OK; } } @@ -527,7 +527,7 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt for (int i = 0; i < _particles.getSize(); i++) { delete _particles[i]; } - _particles.removeAll(); + _particles.clear(); _running = false; stack->pushBool(true); diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index fc557a9512..4e3b837a11 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -60,7 +60,7 @@ public: bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); bool removeForce(const char *name); - BaseArray _forces; + BaseArray _forces; // scripting interface virtual ScValue *scGetProperty(const char *name); @@ -131,8 +131,8 @@ private: bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); uint32 _lastGenTime; - BaseArray _particles; - BaseArray _sprites; + BaseArray _particles; + BaseArray _sprites; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index ba73e1015f..c343ad24ad 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -46,7 +46,7 @@ public: bool dbgSendScript(IWmeDebugClient *client); bool dbgSendVariables(IWmeDebugClient *client); - BaseArray _breakpoints; + BaseArray _breakpoints; bool _tracingMode; ScScript *_parentScript; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 356617094d..e1aed7ed82 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -97,7 +97,7 @@ ScEngine::~ScEngine() { delete _breakpoints[i]; _breakpoints[i] = NULL; } - _breakpoints.removeAll(); + _breakpoints.clear(); } @@ -108,11 +108,11 @@ bool ScEngine::cleanup() { _scripts[i]->_owner->removeScript(_scripts[i]); } delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } - _scripts.removeAll(); + _scripts.clear(); delete _globals; _globals = NULL; @@ -404,7 +404,7 @@ bool ScEngine::removeFinishedScripts() { } _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } } @@ -511,7 +511,7 @@ void ScEngine::editorCleanup() { for (int i = 0; i < _scripts.getSize(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; - _scripts.removeAt(i); + _scripts.remove_at(i); i--; } } @@ -620,10 +620,10 @@ bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.removeAt(j); + _breakpoints[i]->_lines.remove_at(j); if (_breakpoints[i]->_lines.getSize() == 0) { delete _breakpoints[i]; - _breakpoints.removeAt(i); + _breakpoints.remove_at(i); } // refresh changes refreshScriptBreakpoints(); @@ -666,7 +666,7 @@ bool ScEngine::refreshScriptBreakpoints(ScScript *script) { } } if (script->_breakpoints.getSize() > 0) { - script->_breakpoints.removeAll(); + script->_breakpoints.clear(); } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index fc441347df..fcfaa51971 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -74,11 +74,11 @@ public: } ~CScBreakpoint() { - _lines.removeAll(); + _lines.clear(); } Common::String _filename; - BaseArray _lines; + BaseArray _lines; }; @@ -87,7 +87,7 @@ public: public: bool dbgSendScripts(IWmeDebugClient *client); - BaseArray _breakpoints; + BaseArray _breakpoints; bool addBreakpoint(const char *scriptFilename, int line); bool removeBreakpoint(const char *scriptFilename, int line); bool refreshScriptBreakpoints(); @@ -122,7 +122,7 @@ public: static void closeFile(void *data, byte *buffer); static void parseElement(void *data, int line, int type, void *elementData); - BaseArray _scripts; + BaseArray _scripts; void enableProfiling(); void disableProfiling(); diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 0d4ea54b8c..8840a2c0f1 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -50,7 +50,7 @@ ScStack::~ScStack() { for (int i = 0; i < _values.getSize(); i++) { delete _values[i]; } - _values.removeAll(); + _values.clear(); } @@ -123,7 +123,7 @@ void ScStack::correctParams(uint32 expectedParams) { while (expectedParams < nuParams) { //Pop(); delete _values[_sP - expectedParams]; - _values.removeAt(_sP - expectedParams); + _values.remove_at(_sP - expectedParams); nuParams--; _sP--; } @@ -132,13 +132,13 @@ void ScStack::correctParams(uint32 expectedParams) { //Push(null_val); ScValue *nullVal = new ScValue(_gameRef); nullVal->setNULL(); - _values.insertAt(_sP - nuParams + 1, nullVal); + _values.insert_at(_sP - nuParams + 1, nullVal); nuParams++; _sP++; if (_values.getSize() > _sP + 1) { delete _values[_values.getSize() - 1]; - _values.removeAt(_values.getSize() - 1); + _values.remove_at(_values.getSize() - 1); } } } diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 3aacad0765..95839cc680 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -56,7 +56,7 @@ public: ScValue *pop(); ScStack(BaseGame *inGame); virtual ~ScStack(); - BaseArray _values; + BaseArray _values; int _sP; }; -- cgit v1.2.3 From 2c530bc6edc9ffd95fa86488a663e67d2735041f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 20:49:59 +0200 Subject: WINTERMUTE: var_name -> varName --- engines/wintermute/base/font/base_font_bitmap.cpp | 6 +++--- engines/wintermute/base/scriptables/script.cpp | 24 +++++++++++------------ engines/wintermute/base/scriptables/script.h | 12 ++++++------ 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9cce8ca9ee..ee876f2503 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -341,7 +341,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { buffer = (byte *)params; int widths[300]; - int num = 0, default_width = 8; + int num = 0, defaultWidth = 8; int lastWidth = 0; int i; int r = 255, g = 255, b = 255; @@ -377,7 +377,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { break; case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &default_width); + parser.scanStr(params, "%d", &defaultWidth); break; case TOKEN_WIDTHS_FRAME: @@ -482,7 +482,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { } } else { for (i = lastWidth; i < NUM_CHARACTERS; i++) { - _widths[i] = default_width; + _widths[i] = defaultWidth; } } diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 4deeb0bf39..54a04c454f 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -106,12 +106,12 @@ void ScScript::readHeader() { _scriptStream->seek(0); _header.magic = _scriptStream->readUint32LE(); _header.version = _scriptStream->readUint32LE(); - _header.code_start = _scriptStream->readUint32LE(); - _header.func_table = _scriptStream->readUint32LE(); - _header.symbol_table = _scriptStream->readUint32LE(); - _header.event_table = _scriptStream->readUint32LE(); - _header.externals_table = _scriptStream->readUint32LE(); - _header.method_table = _scriptStream->readUint32LE(); + _header.codeStart = _scriptStream->readUint32LE(); + _header.funcTable = _scriptStream->readUint32LE(); + _header.symbolTable = _scriptStream->readUint32LE(); + _header.eventTable = _scriptStream->readUint32LE(); + _header.externalsTable = _scriptStream->readUint32LE(); + _header.methodTable = _scriptStream->readUint32LE(); _scriptStream->seek(oldPos); } @@ -148,7 +148,7 @@ bool ScScript::initScript() { // skip to the beginning - _iP = _header.code_start; + _iP = _header.codeStart; _scriptStream->seek(_iP); _currentLine = 0; @@ -169,7 +169,7 @@ bool ScScript::initTables() { readHeader(); // load symbol table - _iP = _header.symbol_table; + _iP = _header.symbolTable; _numSymbols = getDWORD(); _symbols = new char*[_numSymbols]; @@ -179,7 +179,7 @@ bool ScScript::initTables() { } // load functions table - _iP = _header.func_table; + _iP = _header.funcTable; _numFunctions = getDWORD(); _functions = new TFunctionPos[_numFunctions]; @@ -190,7 +190,7 @@ bool ScScript::initTables() { // load events table - _iP = _header.event_table; + _iP = _header.eventTable; _numEvents = getDWORD(); _events = new TEventPos[_numEvents]; @@ -202,7 +202,7 @@ bool ScScript::initTables() { // load externals if (_header.version >= 0x0101) { - _iP = _header.externals_table; + _iP = _header.externalsTable; _numExternals = getDWORD(); _externals = new TExternalFunction[_numExternals]; @@ -222,7 +222,7 @@ bool ScScript::initTables() { } // load method table - _iP = _header.method_table; + _iP = _header.methodTable; _numMethods = getDWORD(); _methods = new TMethodPos[_numMethods]; diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index c343ad24ad..2ee1319acb 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -88,12 +88,12 @@ public: typedef struct { uint32 magic; uint32 version; - uint32 code_start; - uint32 func_table; - uint32 symbol_table; - uint32 event_table; - uint32 externals_table; - uint32 method_table; + uint32 codeStart; + uint32 funcTable; + uint32 symbolTable; + uint32 eventTable; + uint32 externalsTable; + uint32 methodTable; } TScriptHeader; TScriptHeader _header; -- cgit v1.2.3 From 496a3938c451683845e73fa9b2cba20dadddfe21 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 21:01:00 +0200 Subject: WINTERMUTE: Remove gotos. --- engines/wintermute/base/base_game.cpp | 78 +++++++++------------- .../wintermute/base/base_persistence_manager.cpp | 8 --- 2 files changed, 32 insertions(+), 54 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 00f5731787..402b7294aa 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -3359,36 +3359,29 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initSave(desc))) { - goto save_finish; - } - - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); + if (DID_SUCCEED(ret = pm->initSave(desc))) { + if (!quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName) { + _saveLoadImage = _renderer->createSurface(); - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } } } - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { - goto save_finish; - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { - goto save_finish; - } - if (DID_FAIL(ret = pm->saveFile(filename))) { - goto save_finish; + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = pm->saveFile(filename))) { + _registry->writeInt("System", "MostRecentSaveSlot", slot); + } + } + } } - _registry->writeInt("System", "MostRecentSaveSlot", slot); - -save_finish: // TODO: Remove gotos delete pm; _indicatorDisplay = false; @@ -3436,30 +3429,23 @@ bool BaseGame::loadGame(const char *filename) { _indicatorDisplay = true; _indicatorProgress = 0; BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); - if (DID_FAIL(ret = pm->initLoad(filename))) { - goto load_finish; - } - - //if (DID_FAIL(ret = cleanup())) goto load_finish; - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { - goto load_finish; - } - if (DID_FAIL(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { - goto load_finish; + if (DID_SUCCEED(ret = pm->initLoad(filename))) { + //if (DID_SUCCEED(ret = cleanup())) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { + // data initialization after load + initAfterLoad(); + + _gameRef->applyEvent("AfterLoad", true); + + displayContent(true, false); + //_renderer->flip(); + + getDebugMgr()->onGameInit(); + } + } } - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - - getDebugMgr()->onGameInit(); - -load_finish: - _indicatorDisplay = false; delete pm; _loadInProgress = false; diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index d8f928b683..9f07da57ac 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -354,14 +354,6 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { } - /* - if ( _savedVerMajor != DCGF_VER_MAJOR || _savedVerMinor != DCGF_VER_MINOR) - { - _gameRef->LOG(0, "ERROR: Saved game is created by other WME version"); - goto init_fail; - } - */ - return STATUS_OK; } -- cgit v1.2.3 From 3a49f2bad407787ef65d04c5f9ae423485629b41 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Thu, 26 Jul 2012 22:20:55 +0200 Subject: WINTERMUTE: More variable/function renaming VarName->varName --- engines/wintermute/base/base_frame.cpp | 6 +- engines/wintermute/base/base_frame.h | 2 +- engines/wintermute/base/base_game.cpp | 28 +++++----- engines/wintermute/base/base_game.h | 4 +- engines/wintermute/base/base_object.cpp | 14 ++--- .../wintermute/base/base_persistence_manager.cpp | 14 ++--- engines/wintermute/base/base_region.cpp | 26 ++++----- engines/wintermute/base/base_sprite.cpp | 22 ++++---- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/base_surface_storage.h | 2 +- engines/wintermute/base/font/base_font.cpp | 4 +- engines/wintermute/base/font/base_font_bitmap.cpp | 64 +++++++++++----------- engines/wintermute/base/font/base_font_bitmap.h | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/gfx/base_surface.h | 6 +- .../base/gfx/osystem/base_render_osystem.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- .../base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 10 ++-- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 54 +++++++++--------- .../wintermute/base/scriptables/script_engine.cpp | 18 +++--- .../base/scriptables/script_ext_array.cpp | 18 +++--- .../base/scriptables/script_ext_file.cpp | 8 +-- .../wintermute/base/scriptables/script_ext_file.h | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 20 +++---- engines/wintermute/base/sound/base_sound.cpp | 2 +- engines/wintermute/base/sound/base_sound.h | 2 +- .../wintermute/base/sound/base_sound_buffer.cpp | 4 +- 30 files changed, 175 insertions(+), 175 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 208d6037d9..44e39823e6 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -268,9 +268,9 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { break; case TOKEN_APPLY_EVENT: { - char *Event = new char[strlen(params) + 1]; - strcpy(Event, params); - _applyEvent.add(Event); + char *event = new char[strlen(params) + 1]; + strcpy(event, params); + _applyEvent.add(event); } break; diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index c8e9cbb400..b019ebf7b6 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -52,7 +52,7 @@ public: int _moveX; uint32 _delay; BaseArray _subframes; - bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 Alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); BaseFrame(BaseGame *inGame); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 402b7294aa..20ed358ec2 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1051,14 +1051,14 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); ScValue *val = stack->pop(); - bool ClearOld; + bool clearOld; if (val->isNULL()) { - ClearOld = true; + clearOld = true; } else { - ClearOld = val->getBool(); + clearOld = val->getBool(); } - if (DID_FAIL(_stringTable->loadFile(filename, ClearOld))) { + if (DID_FAIL(_stringTable->loadFile(filename, clearOld))) { stack->pushBool(false); } else { stack->pushBool(true); @@ -1530,7 +1530,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack bool dropFrames = stack->pop()->getBool(true); ScValue *valSub = stack->pop(); - const char *SubtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { type = (int)VID_PLAY_STRETCH; @@ -1538,7 +1538,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack delete _theoraPlayer; _theoraPlayer = new VideoTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, SubtitleFile))) { + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, subtitleFile))) { _theoraPlayer->_dontDropFrames = !dropFrames; if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { stack->pushBool(true); @@ -1649,8 +1649,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); - int Slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(Slot)); + int slot = stack->pop()->getInt(); + stack->pushBool(isSaveSlotUsed(slot)); return STATUS_OK; } @@ -2162,7 +2162,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "AccOutputText") == 0) { stack->correctParams(2); - /* const char *Str = */ stack->pop()->getString(); + /* const char *str = */ stack->pop()->getString(); /* int type = */ stack->pop()->getInt(); // do nothing stack->pushNULL(); @@ -2225,9 +2225,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack crc checksum = crc_finalize(remainder); if (asHex) { - char Hex[100]; - sprintf(Hex, "%x", checksum); - stack->pushString(Hex); + char hex[100]; + sprintf(hex, "%x", checksum); + stack->pushString(hex); } else { stack->pushInt(checksum); } @@ -3032,7 +3032,7 @@ bool BaseGame::validObject(BaseObject *object) { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { +bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { ScValue *thisObj; ////////////////////////////////////////////////////////////////////////// @@ -4266,7 +4266,7 @@ bool BaseGame::displayIndicator() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::updateMusicCrossfade() { - /* byte GlobMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + /* byte globMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ if (!_musicCrossfadeRunning) { return STATUS_OK; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index ecb698b70a..d4a4c0e682 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -39,7 +39,7 @@ namespace WinterMute { -typedef void (*ENGINE_LOG_CALLBACK)(char *Text, bool Result, void *Data); +typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); class BaseSoundMgr; class BaseFader; @@ -168,7 +168,7 @@ public: bool _suppressScriptErrors; bool _mouseLeftDown; // TODO: Hide - virtual bool ExternalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface virtual ScValue *scGetProperty(const char *name); virtual bool scSetProperty(const char *name, ScValue *value); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 18619616fe..76047ef4b4 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -428,8 +428,8 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta else if (strcmp(name, "SetSoundPosition") == 0) { stack->correctParams(1); - uint32 Time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(Time))) { + uint32 time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(time))) { stack->pushBool(false); } else { stack->pushBool(true); @@ -1099,7 +1099,7 @@ bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const _sFX->setPositionTime(_sFXStart); _sFXStart = 0; } - _sFX->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + _sFX->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); if (playNow) { setSoundEvent(eventName); if (loopStart) { @@ -1192,16 +1192,16 @@ bool BaseObject::updateSounds() { ////////////////////////////////////////////////////////////////////////// bool BaseObject::updateOneSound(BaseSound *sound) { - bool Ret = STATUS_OK; + bool ret = STATUS_OK; if (sound) { if (_autoSoundPanning) { - Ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); } - Ret = sound->ApplyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + ret = sound->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); } - return Ret; + return ret; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 9f07da57ac..bc751e6aed 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -206,13 +206,13 @@ bool BasePersistenceManager::initSave(const char *desc) { magic = SAVE_MAGIC_2; putDWORD(magic); - byte VerMajor, VerMinor, ExtMajor, ExtMinor; - _gameRef->getVersion(&VerMajor, &VerMinor, &ExtMajor, &ExtMinor); - //uint32 Version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(VerMajor); - _saveStream->writeByte(VerMinor); - _saveStream->writeByte(ExtMajor); - _saveStream->writeByte(ExtMinor); + byte verMajor, verMinor, extMajor, extMinor; + _gameRef->getVersion(&verMajor, &verMinor, &extMajor, &extMinor); + //uint32 version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(verMajor); + _saveStream->writeByte(verMinor); + _saveStream->writeByte(extMajor); + _saveStream->writeByte(extMinor); // new in ver 2 putDWORD((uint32)DCGF_VER_BUILD); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 13815a5958..79ea5396fc 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -244,12 +244,12 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "InsertPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.getSize()) { - _points.insert_at(Index, new BasePoint(x, y)); + if (index >= 0 && index < _points.getSize()) { + _points.insert_at(index, new BasePoint(x, y)); createRegion(); stack->pushBool(true); @@ -265,13 +265,13 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SetPoint") == 0) { stack->correctParams(3); - int Index = stack->pop()->getInt(); + int index = stack->pop()->getInt(); int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (Index >= 0 && Index < _points.getSize()) { - _points[Index]->x = x; - _points[Index]->y = y; + if (index >= 0 && index < _points.getSize()) { + _points[index]->x = x; + _points[index]->y = y; createRegion(); stack->pushBool(true); @@ -497,16 +497,16 @@ bool BaseRegion::getBoundingRect(Rect32 *rect) { if (_points.getSize() == 0) { BasePlatform::setRectEmpty(rect); } else { - int MinX = INT_MAX, MinY = INT_MAX, MaxX = INT_MIN, MaxY = INT_MIN; + int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; for (int i = 0; i < _points.getSize(); i++) { - MinX = MIN(MinX, _points[i]->x); - MinY = MIN(MinY, _points[i]->y); + minX = MIN(minX, _points[i]->x); + minY = MIN(minY, _points[i]->y); - MaxX = MAX(MaxX, _points[i]->x); - MaxY = MAX(MaxY, _points[i]->y); + maxX = MAX(maxX, _points[i]->x); + maxY = MAX(maxY, _points[i]->y); } - BasePlatform::setRect(rect, MinX, MinY, MaxX, MaxY); + BasePlatform::setRect(rect, minX, minY, maxX, maxY); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 274c792263..fb1b5a82cf 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -103,7 +103,7 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - GetCurrentFrame(zoomX, zoomY); + getCurrentFrame(zoomX, zoomY); if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { return STATUS_OK; } @@ -291,14 +291,14 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa break; case TOKEN_FRAME: { - int FrameLifeTime = lifeTime; + int frameLifeTime = lifeTime; if (cacheType == CACHE_HALF && frameCount % 2 != 1) { - FrameLifeTime = -1; + frameLifeTime = -1; } frame = new BaseFrame(_gameRef); - if (DID_FAIL(frame->loadBuffer(params, FrameLifeTime, _streamedKeepLoaded))) { + if (DID_FAIL(frame->loadBuffer(params, frameLifeTime, _streamedKeepLoaded))) { delete frame; _gameRef->LOG(0, "Error parsing frame %d", frameCount); return STATUS_FAILED; @@ -345,7 +345,7 @@ void BaseSprite::reset() { ////////////////////////////////////////////////////////////////////// -bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { +bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; if (_currentFrame == -1) { @@ -406,7 +406,7 @@ bool BaseSprite::GetCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// -bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float ZoomY, uint32 Alpha, float Rotate, TSpriteBlendMode BlendMode) { +bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { return STATUS_OK; } @@ -421,7 +421,7 @@ bool BaseSprite::display(int X, int Y, BaseObject *Register, float ZoomX, float } // draw frame - return _frames[_currentFrame]->draw(X - _gameRef->_offsetX, Y - _gameRef->_offsetY, Register, ZoomX, ZoomY, _precise, Alpha, _editorAllFrames, Rotate, BlendMode); + return _frames[_currentFrame]->draw(x - _gameRef->_offsetX, y - _gameRef->_offsetY, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); } @@ -549,12 +549,12 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); - int Index = stack->pop()->getInt(-1); - if (Index < 0 || Index >= _frames.getSize()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", Index); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= _frames.getSize()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); stack->pushNULL(); } else { - stack->pushNative(_frames[Index], true); + stack->pushNative(_frames[index], true); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 477ab70878..084d7b2d70 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -57,7 +57,7 @@ public: int _moveY; int _moveX; bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool GetCurrentFrame(float zoomX = 100, float zoomY = 100); + bool getCurrentFrame(float zoomX = 100, float zoomY = 100); bool _canBreak; bool _editorMuted; bool _continuous; diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 350210b95e..13c4deb3db 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -40,7 +40,7 @@ public: bool initLoop(); bool sortSurfaces(); static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool Warn = false); + bool cleanup(bool warn = false); //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 937557f4d7..34ff717ae5 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -191,13 +191,13 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { return false; } - byte *WorkBuffer = buffer; + byte *workBuffer = buffer; char *params; BaseParser parser(gameRef); bool ret = false; - if (parser.getCommand((char **)&WorkBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { + if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { ret = true; } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ee876f2503..9431c730bd 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -127,9 +127,9 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli return 0; } - int LineLength = 0; - int RealLength = 0; - int NumLines = 0; + int lineLength = 0; + int realLength = 0; + int numLines = 0; int i; @@ -139,66 +139,66 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli int last_end = 0; bool done = false; - bool new_line = false; - bool long_line = false; + bool newLine = false; + bool longLine = false; if (draw) { _gameRef->_renderer->startSpriteBatch(); } while (!done) { - if (maxHeight > 0 && (NumLines + 1)*_tileHeight > maxHeight) { + if (maxHeight > 0 && (numLines + 1)*_tileHeight > maxHeight) { if (draw) { _gameRef->_renderer->endSpriteBatch(); } - return NumLines * _tileHeight; + return numLines * _tileHeight; } index++; if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { end = index - 1; - RealLength = LineLength; + realLength = lineLength; } if (str[index] == '\n') { end = index - 1; - RealLength = LineLength; - new_line = true; + realLength = lineLength; + newLine = true; } - if (LineLength + getCharWidth(str[index]) > width && last_end == end) { + if (lineLength + getCharWidth(str[index]) > width && last_end == end) { end = index - 1; - RealLength = LineLength; - new_line = true; - long_line = true; + realLength = lineLength; + newLine = true; + longLine = true; } if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { done = true; - if (!new_line) { + if (!newLine) { end = index; - LineLength += getCharWidth(str[index]); - RealLength = LineLength; + lineLength += getCharWidth(str[index]); + realLength = lineLength; } } else { - LineLength += getCharWidth(str[index]); + lineLength += getCharWidth(str[index]); } - if ((LineLength > width) || done || new_line) { + if ((lineLength > width) || done || newLine) { if (end < 0) { done = true; } - int StartX; + int startX; switch (align) { case TAL_CENTER: - StartX = x + (width - RealLength) / 2; + startX = x + (width - realLength) / 2; break; case TAL_RIGHT: - StartX = x + width - RealLength; + startX = x + width - realLength; break; case TAL_LEFT: - StartX = x; + startX = x; break; default: error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); @@ -206,21 +206,21 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli } for (i = start; i < end + 1; i++) { if (draw) { - drawChar(str[i], StartX, y); + drawChar(str[i], startX, y); } - StartX += getCharWidth(str[i]); + startX += getCharWidth(str[i]); } y += _tileHeight; last_end = end; - if (long_line) { + if (longLine) { end--; } start = end + 2; index = end + 1; - LineLength = 0; - new_line = false; - long_line = false; - NumLines++; + lineLength = 0; + newLine = false; + longLine = false; + numLines++; } } @@ -228,7 +228,7 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli _gameRef->_renderer->endSpriteBatch(); } - return NumLines * _tileHeight; + return numLines * _tileHeight; } @@ -255,7 +255,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); bool handled = false; if (_sprite) { - _sprite->GetCurrentFrame(); + _sprite->getCurrentFrame(); if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 79806be95f..abf2d39aa0 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -62,7 +62,7 @@ private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int MaxLength = -1); + int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index ac6430d4c9..c643a5e1b1 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -701,7 +701,7 @@ bool BaseFontTT::initFont() { // http://en.wikipedia.org/wiki/E_(typography) float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float EmsPerUnit = 1.0f / _fTFace->units_per_EM; + float emsPerUnit = 1.0f / _fTFace->units_per_EM; float pixelsPerUnit = pixelsPerEm * EmsPerUnit; // bounding box in pixels diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 68e3e3d26c..635d48058f 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -87,7 +87,7 @@ bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect } ////////////////////////////////////////////////////////////////////////// -bool BaseSurface::create(int Width, int Height) { +bool BaseSurface::create(int width, int height) { return STATUS_FAILED; } diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 66a3460d48..4f67f871dd 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -52,12 +52,12 @@ public: virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool MirrorY = false) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float ZoomX, float ZoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool restore(); virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual bool create(int Width, int Height); + virtual bool create(int width, int height); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return STATUS_FAILED; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 6913b3434c..7e43b0b7f4 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -619,8 +619,8 @@ void BaseRenderOSystem::dumpData(const char *filename) { BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - int TotalKB = 0; - int TotalLoss = 0; + int totalKB = 0; + int totalLoss = 0; fprintf(f, "Filename;Usage;Size;KBytes\n"); for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index b77abf6a79..aa9cc8474a 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -327,8 +327,8 @@ bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool Transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !Transparent, blendMode, mirrorX, mirrorY); +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !transparent, blendMode, mirrorX, mirrorY); } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 9ed80cec50..8e4370892b 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -55,7 +55,7 @@ public: bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool Transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 8b86365196..f8c0c1a5cf 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -45,7 +45,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(PartEmitter, false) ////////////////////////////////////////////////////////////////////////// -PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject(inGame) { +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { _width = _height = 0; BasePlatform::setRectEmpty(&_border); @@ -88,7 +88,7 @@ PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner) : BaseObject _useRegion = false; _emitEvent = NULL; - _owner = Owner; + _owner = owner; } @@ -136,9 +136,9 @@ bool PartEmitter::addSprite(const char *filename) { _gameRef->_fileManager->closeFile(File); } - char *Str = new char[strlen(filename) + 1]; - strcpy(Str, filename); - _sprites.add(Str); + char *str = new char[strlen(filename) + 1]; + strcpy(str, filename); + _sprites.add(str); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 4a5239edfe..27dbe9999c 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -198,7 +198,7 @@ bool PartParticle::display(PartEmitter *emitter) { return STATUS_OK; } - _sprite->GetCurrentFrame(); + _sprite->getCurrentFrame(); return _sprite->display(_pos.x, _pos.y, NULL, _scale, _scale, diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 54a04c454f..75c4d38574 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -165,7 +165,7 @@ bool ScScript::initScript() { ////////////////////////////////////////////////////////////////////////// bool ScScript::initTables() { - uint32 OrigIP = _iP; + uint32 origIP = _iP; readHeader(); // load symbol table @@ -232,7 +232,7 @@ bool ScScript::initTables() { } - _iP = OrigIP; + _iP = origIP; return STATUS_OK; } @@ -546,7 +546,7 @@ bool ScScript::executeInstruction() { case II_DEF_GLOB_VAR: case II_DEF_CONST_VAR: { dw = getDWORD(); - /* char *Temp = _symbols[dw]; // TODO delete */ + /* char *temp = _symbols[dw]; // TODO delete */ // only create global var if it doesn't exist if (!_engine->_globals->propExists(_symbols[dw])) { _operand->setNULL(); @@ -604,8 +604,8 @@ bool ScScript::executeInstruction() { // push var // push string str = _stack->pop()->getString(); - char *MethodName = new char[strlen(str) + 1]; - strcpy(MethodName, str); + char *methodName = new char[strlen(str) + 1]; + strcpy(methodName, str); ScValue *var = _stack->pop(); if (var->_type == VAL_VARIABLE_REF) { @@ -613,21 +613,21 @@ bool ScScript::executeInstruction() { } bool res = STATUS_FAILED; - bool TriedNative = false; + bool triedNative = false; // we are already calling this method, try native - if (_thread && _methodThread && strcmp(MethodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - TriedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (_thread && _methodThread && strcmp(methodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + triedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); } if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(MethodName)) { + if (var->isNative() && var->getNative()->canHandleMethod(methodName)) { if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(MethodName); + _waitScript = var->getNative()->invokeMethodThread(methodName); if (!_waitScript) { _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", MethodName); + runtimeError("Error invoking method '%s'.", methodName); _stack->pushNULL(); } else { _state = SCRIPT_WAITING_SCRIPT; @@ -636,10 +636,10 @@ bool ScScript::executeInstruction() { } else { // can call methods in unbreakable mode _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", MethodName); + runtimeError("Cannot call method '%s'. Ignored.", methodName); _stack->pushNULL(); } - delete[] MethodName; + delete[] methodName; break; } /* @@ -665,29 +665,29 @@ bool ScScript::executeInstruction() { */ else { res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !TriedNative) { - res = var->_valNative->scCallMethod(this, _stack, _thisStack, MethodName); + if (var->_type == VAL_NATIVE && !triedNative) { + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); } if (DID_FAIL(res)) { _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", MethodName); + runtimeError("Call to undefined method '%s'. Ignored.", methodName); _stack->pushNULL(); } } } - delete[] MethodName; + delete[] methodName; } break; case II_EXTERNAL_CALL: { - uint32 SymbolIndex = getDWORD(); + uint32 symbolIndex = getDWORD(); - TExternalFunction *f = getExternal(_symbols[SymbolIndex]); + TExternalFunction *f = getExternal(_symbols[symbolIndex]); if (f) { externalCall(_stack, _thisStack, f); } else { - _gameRef->ExternalCall(this, _stack, _thisStack, _symbols[SymbolIndex]); + _gameRef->externalCall(this, _stack, _thisStack, _symbols[symbolIndex]); } break; @@ -737,8 +737,8 @@ bool ScScript::executeInstruction() { } case II_POP_VAR: { - char *VarName = _symbols[getDWORD()]; - ScValue *var = getVar(VarName); + char *varName = _symbols[getDWORD()]; + ScValue *var = getVar(varName); if (var) { ScValue *val = _stack->pop(); if (!val) { @@ -1460,13 +1460,13 @@ bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExter ////////////////////////////////////////////////////////////////////////// bool ScScript::copyParameters(ScStack *stack) { int i; - int NumParams = stack->pop()->getInt(); - for (i = NumParams - 1; i >= 0; i--) { + int numParams = stack->pop()->getInt(); + for (i = numParams - 1; i >= 0; i--) { _stack->push(stack->getAt(i)); } - _stack->pushInt(NumParams); + _stack->pushInt(numParams); - for (i = 0; i < NumParams; i++) { + for (i = 0; i < numParams; i++) { stack->pop(); } diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e1aed7ed82..bc8d54ef58 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -227,13 +227,13 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); if (cachedScript) { int index = 0; - uint32 MinTime = g_system->getMillis(); + uint32 minTime = g_system->getMillis(); for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { if (_cachedScripts[i] == NULL) { index = i; break; - } else if (_cachedScripts[i]->_timestamp <= MinTime) { - MinTime = _cachedScripts[i]->_timestamp; + } else if (_cachedScripts[i]->_timestamp <= minTime) { + minTime = _cachedScripts[i]->_timestamp; index = i; } } @@ -338,13 +338,13 @@ bool ScEngine::tick() { // time sliced script if (_scripts[i]->_timeSlice > 0) { - uint32 StartTime = g_system->getMillis(); - while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - StartTime < _scripts[i]->_timeSlice) { + uint32 startTime = g_system->getMillis(); + while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - startTime < _scripts[i]->_timeSlice) { _currentScript = _scripts[i]; _scripts[i]->executeInstruction(); } if (_isProfiling && _scripts[i]->_filename) { - addScriptTime(_scripts[i]->_filename, g_system->getMillis() - StartTime); + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); } } @@ -473,8 +473,8 @@ bool ScEngine::resetObject(BaseObject *Object) { resetScript(_scripts[i]); } - bool IsThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!IsThread); // 1.9b1 - top-level script kills its threads as well + bool isThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!isThread); // 1.9b1 - top-level script kills its threads as well } } return STATUS_OK; @@ -707,7 +707,7 @@ bool ScEngine::loadBreakpoints() { int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { - /* uint32 BufSize = 512; */ + /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 0380103cd4..cc3bec89c0 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -162,9 +162,9 @@ ScValue *SXArray::scGetProperty(const char *name) { // [number] ////////////////////////////////////////////////////////////////////////// else { - char ParamName[20]; - if (validNumber(name, ParamName)) { - return _values->getProp(ParamName); + char paramName[20]; + if (validNumber(name, paramName)) { + return _values->getProp(paramName); } else { return _scValue; } @@ -178,14 +178,14 @@ bool SXArray::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length") == 0) { - int OrigLength = _length; + int origLength = _length; _length = MAX(value->getInt(0), 0); - char PropName[20]; - if (_length < OrigLength) { - for (int i = _length; i < OrigLength; i++) { - sprintf(PropName, "%d", i); - _values->deleteProp(PropName); + char propName[20]; + if (_length < origLength) { + for (int i = _length; i < origLength; i++) { + sprintf(propName, "%d", i); + _values->deleteProp(propName); } } return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 437fbb64a2..4eeabca04d 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -188,8 +188,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, script->runtimeError("File.%s: File is not open", name); stack->pushBool(false); } else { - int Pos = stack->pop()->getInt(); - stack->pushBool(setPos(Pos)); + int pos = stack->pop()->getInt(); + stack->pushBool(setPos(pos)); } return STATUS_OK; } @@ -703,10 +703,10 @@ bool SXFile::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length")==0){ - int OrigLength = _length; + int origLength = _length; _length = max(value->getInt(0), 0); - char PropName[20]; + char propName[20]; if (_length < OrigLength){ for(int i=_length; ipop()->getInt(); - resize(MAX(0, NewSize)); + int newSize = stack->pop()->getInt(); + resize(MAX(0, newSize)); } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *Buffer): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer): BaseScriptable(inGame) { _size = 0; - _buffer = Buffer; + _buffer = buffer; } @@ -184,11 +184,11 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetShort") == 0) { stack->correctParams(1); - int Start = stack->pop()->getInt(); - if (!checkBounds(script, Start, sizeof(short))) { + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(short))) { stack->pushNULL(); } else { - stack->pushInt(65536 + * (short *)((byte *)_buffer + Start)); + stack->pushInt(65536 + * (short *)((byte *)_buffer + start)); } return STATUS_OK; @@ -416,7 +416,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushBool(false); } else { /* - int Pointer = (int)Val->getMemBuffer(); + int pointer = (int)Val->getMemBuffer(); memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); stack->pushBool(true); */ @@ -478,10 +478,10 @@ bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { // Length ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "Length")==0){ - int OrigLength = _length; + int origLength = _length; _length = max(value->getInt(0), 0); - char PropName[20]; + char propName[20]; if (_length < OrigLength){ for(int i=_length; iformat.ARGBToColor(a, r, g, b); - if (_disableDirtyRects) { - _renderSurface->fillRect(fillRect, col); - } else { - setAlphaMod(a); - setColorMod(r, g, b); - Graphics::Surface surf; - surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); - Common::Rect sizeRect(fillRect); - sizeRect.translate(-fillRect.top, -fillRect.left); - surf.fillRect(fillRect, col); - drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); - surf.free(); - _clearColor = col; - } + + setAlphaMod(255); + setColorMod(255, 255, 255); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); //SDL_RenderFillRect(_renderer, &fillRect); @@ -320,14 +317,16 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S return; } - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - drawFromTicket(*it); - return; + if (owner) { // Fade-tickets are owner-less + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + drawFromTicket(*it); + return; + } } } RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); -- cgit v1.2.3 From bb131aaa072d1d75e7d1c0a5f6f0ef3614fc8eb7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 00:05:15 +0200 Subject: WINTERMUTE: Clean up some TODOs. --- engines/wintermute/base/base.cpp | 2 -- engines/wintermute/base/base_game.cpp | 25 +++------------------- engines/wintermute/base/base_object.cpp | 2 +- engines/wintermute/base/file/base_file_entry.cpp | 8 +++---- engines/wintermute/base/file/base_package.cpp | 18 ++++++++++++++++ engines/wintermute/base/file/dcpackage.h | 20 ++--------------- .../base/gfx/osystem/base_render_osystem.cpp | 2 -- .../base/gfx/osystem/base_surface_osystem.cpp | 3 +-- 8 files changed, 28 insertions(+), 52 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 687d2d52e6..d5163fa7a6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -175,8 +175,6 @@ bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent, "{\n"); buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - //buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", (char *)_editorPropsIter->first.c_str()); // <- TODO, remove - //buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->second.c_str()); // <- TODO, remove buffer->putTextIndent(indent, "}\n\n"); _editorPropsIter++; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 20ed358ec2..cb53d37c2d 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1459,13 +1459,6 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // PlayVideo ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayVideo") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK; - // TODO: ADDVIDEO - */ - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); stack->correctParams(6); @@ -1508,12 +1501,6 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack // PlayTheora ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "PlayTheora") == 0) { - /* stack->correctParams(0); - stack->pushBool(false); - - return STATUS_OK;*/ - // TODO: ADDVIDEO - stack->correctParams(7); const char *filename = stack->pop()->getString(); ScValue *valType = stack->pop(); @@ -1830,14 +1817,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); const char *filename = stack->pop()->getString(); - // TODO: Replace with fileExists - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); - if (!file) { - stack->pushBool(false); - } else { - _fileManager->closeFile(file); - stack->pushBool(true); - } + bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false + stack->pushBool(exists); return STATUS_OK; } @@ -3933,7 +3914,7 @@ bool BaseGame::handleKeypress(Common::Event *event, bool printable) { } else { /*if (event->type != SDL_TEXTINPUT)*/ applyEvent("Keypress"); return true; - } //else return true; + } return false; } diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 76047ef4b4..5fbfc31924 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -138,7 +138,7 @@ bool BaseObject::cleanup() { ////////////////////////////////////////////////////////////////////////// -void BaseObject::setCaption(const char *caption, int caseVal) { // TODO: rename Case to something usefull +void BaseObject::setCaption(const char *caption, int caseVal) { if (caseVal == 0) { caseVal = 1; } diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 7bf635b858..da1bfa7ac8 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -65,18 +65,16 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { return NULL; } - // TODO: Cleanup + bool compressed = (_compressedLength != 0); - /* _size = fileEntry->_length; */ if (compressed) { - // TODO: Really, most of this logic might be doable directly in the fileEntry? - // But for now, this should get us rolling atleast. file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); + // file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // TODO: Uncomment on merge } else { file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); } - if (file->size() == 0) { + if (file->size() == 0) { // TODO: Cleanup on next merge (CBPkgFile is just a placeholder for the commented out wrap above. file = new CBPkgFile(file, _length); } diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index b41ae3c1bd..80d3b4a515 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -82,6 +82,24 @@ static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) } +void TPackageHeader::readFromStream(Common::ReadStream *stream) { + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); + + _gameVersion = stream->readUint32LE(); + + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + _creationTime = stream->readUint32LE(); + + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); +} + PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { uint32 absoluteOffset = 0; _priority = 0; diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 4a51683260..ccebc5909c 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -50,24 +50,8 @@ struct TPackageHeader { uint32 _creationTime; char _desc[100]; uint32 _numDirs; - // TODO: Move this out of the header. - void readFromStream(Common::ReadStream *stream) { - _magic1 = stream->readUint32LE(); - _magic2 = stream->readUint32LE(); - _packageVersion = stream->readUint32LE(); - - _gameVersion = stream->readUint32LE(); - - _priority = stream->readByte(); - _cd = stream->readByte(); - _masterIndex = stream->readByte(); - stream->readByte(); // To align the next byte... - - _creationTime = stream->readUint32LE(); - - stream->read(_desc, 100); - _numDirs = stream->readUint32LE(); - } + // base_package.cpp: + void readFromStream(Common::ReadStream *stream); }; /* diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 917a76be85..b41df5f1e2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -94,8 +94,6 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { return new BaseRenderOSystem(inGame); } -// TODO: Redo everything here. - ////////////////////////////////////////////////////////////////////////// BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index aa9cc8474a..5e6347fdef 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -57,7 +57,6 @@ BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { ////////////////////////////////////////////////////////////////////////// BaseSurfaceOSystem::~BaseSurfaceOSystem() { - //TODO if (_surface) { _surface->free(); delete _surface; @@ -385,8 +384,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo Common::Rect position; position.left = x + offsetX; position.top = y + offsetY; - // TODO: Scaling... + // Crop off-by-ones: if (position.left == -1) { position.left = 0; // TODO: Something is wrong } -- cgit v1.2.3 From b3b86c440cb2a13a43ce6dd3102bf85f4211795b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 15:55:06 +0200 Subject: WINTERMUTE: Clear out a few warning()s --- engines/wintermute/base/base_file_manager.cpp | 4 ++-- engines/wintermute/base/base_persistence_manager.cpp | 3 +-- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 9 ++++++--- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 12 +----------- engines/wintermute/base/sound/base_sound.h | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 7 +++---- 6 files changed, 13 insertions(+), 23 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 94f561997e..1c58da2be9 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -212,7 +212,7 @@ bool BaseFileManager::registerPackages() { // and that has to be like that to support the detection-scheme. Common::FSList files; for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - warning("Should register %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().hasSuffix(".dcp")) { @@ -227,7 +227,7 @@ bool BaseFileManager::registerPackages() { continue; } } - warning("Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + debugC(kWinterMuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); } } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index bc751e6aed..995b996b33 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -127,7 +127,7 @@ Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); + debugC(kWinterMuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); return; @@ -172,7 +172,6 @@ uint32 BasePersistenceManager::getMaxUsedSlot() { bool BasePersistenceManager::getSaveExists(int slot) { Common::String filename = getFilenameForSlot(slot); - warning("Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { return false; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index b41df5f1e2..00ef2ec95c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -258,8 +258,9 @@ void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect // thus we avoid printing it more than once. static bool hasWarned = false; if (!hasWarned) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - warning("Implement BaseRenderOSystem::FadeToColor"); // TODO. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + } hasWarned = true; } @@ -489,7 +490,9 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { static bool hasWarned = false; if (!hasWarned) { - warning("BaseRenderOSystem::DrawLine - not fully ported yet"); + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); + } hasWarned = true; } byte r = RGBCOLGetR(color); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5e6347fdef..5102d182f9 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -348,14 +348,6 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo alpha = renderer->_forceAlphaColor; } - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - warning("BaseSurfaceOSystem::DrawSprite not fully ported yet"); // TODO. - hasWarned = true; - } - byte r = RGBCOLGetR(alpha); byte g = RGBCOLGetG(alpha); byte b = RGBCOLGetB(alpha); @@ -363,10 +355,8 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo renderer->setAlphaMod(a); renderer->setColorMod(r, g, b); -#if 0 - SDL_SetTextureColorMod(_texture, r, g, b); - SDL_SetTextureAlphaMod(_texture, a); +#if 0 // These are kept for reference if BlendMode is reimplemented at some point. if (alphaDisable) { SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); } else { diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index bb37e55388..7ea9f38f6c 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -80,7 +80,6 @@ private: float _sFXParam3; float _sFXParam4; BaseSoundBuffer *_sound; - }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 34aee36f1b..aa03609177 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -134,9 +134,6 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::play(bool looping, uint32 startSample) { - if (startSample != 0) { - warning("BSoundBuffer::Play - Should start playback at %d, but currently we don't", startSample); - } if (_handle) { g_system->getMixer()->stopHandle(*_handle); delete _handle; @@ -269,12 +266,14 @@ bool BaseSoundBuffer::setPan(float pan) { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - warning("BaseSoundBuffer::ApplyFX - not implemented yet"); + // This function was already stubbed out in WME Lite, and thus isn't reimplemented here either. switch (type) { case SFX_ECHO: + //warning("BaseSoundBuffer::ApplyFX(SFX_ECHO, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); break; case SFX_REVERB: + //warning("BaseSoundBuffer::ApplyFX(SFX_REVERB, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); break; default: -- cgit v1.2.3 From df5943ae59350b37e6f811ec2e9a968d0660fcab Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 15:59:58 +0200 Subject: WINTERMUTE: Start sounds again after loading a save. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 15 +++++++++++++-- engines/wintermute/base/sound/base_sound_buffer.h | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index aa03609177..25be117db2 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -63,6 +63,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { _looping = false; _loopStart = 0; + _startPos = 0; _type = Audio::Mixer::kSFXSoundType; @@ -155,14 +156,21 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO + if (isPlaying()) { + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO + } _looping = looping; } ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::resume() { + // If the sound was paused while active: if (_stream && _handle) { g_system->getMixer()->pauseHandle(*_handle, false); + } else if (_stream) { // Otherwise we come from a savegame, and thus have no handle + play(_looping, _startPos); + } else { + warning("BaseSoundBuffer::resume - Called without a handle or a stream"); } return STATUS_OK; } @@ -246,7 +254,10 @@ uint32 BaseSoundBuffer::getPosition() { ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::setPosition(uint32 pos) { - warning("BaseSoundBuffer::SetPosition - not implemented yet"); + if (isPlaying()) { + warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); + } + _startPos = pos; return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index c32f83eb1e..107ceb87d7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -88,6 +88,7 @@ public: int _privateVolume; private: + uint32 _startPos; char *_filename; bool _streamed; Common::SeekableReadStream *_file; -- cgit v1.2.3 From 3ff2e2cc936dce22b74699c30a160389c4f50447 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:01:03 +0200 Subject: WINTERMUTE: Support the SPACE-key as a printable character. --- engines/wintermute/base/base_keyboard_state.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 3bad8f6012..2b77cb23ca 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -204,7 +204,8 @@ bool BaseKeyboardState::readKey(Common::Event *event) { //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO _currentCharCode = keyCodeToVKey(event); if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0)) { + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0) || + (_currentCharCode == Common::KEYCODE_SPACE)) { _currentPrintable = true; } else { _currentPrintable = false; -- cgit v1.2.3 From 996e79b3d5e5d336080017a800e50be6a9a33d15 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:04:37 +0200 Subject: WINTERMUTE: Fix SaveGame-thumb loading/saving. --- engines/wintermute/base/base_file_manager.cpp | 15 +++++++++++---- engines/wintermute/base/base_game.cpp | 14 ++++---------- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 -- 3 files changed, 15 insertions(+), 16 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 1c58da2be9..f1320b814b 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -267,6 +267,13 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f } bool BaseFileManager::hasFile(const Common::String &filename) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + BasePersistenceManager pm(_gameRef); + if (filename.size() < 9) + return false; + int slot = atoi(filename.c_str() + 9); + return pm.getSaveExists(slot); + } if (diskFileExists(filename)) { return true; } @@ -315,11 +322,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f if (!_gameRef) { error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); } - BaseSaveThumbFile *SaveThumbFile = new BaseSaveThumbFile(_gameRef); - if (DID_SUCCEED(SaveThumbFile->open(filename))) { - ret = SaveThumbFile->getMemStream(); + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef); + if (DID_SUCCEED(saveThumbFile->open(filename))) { + ret = saveThumbFile->getMemStream(); } - delete SaveThumbFile; + delete saveThumbFile; return ret; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index cb53d37c2d..8fd2b193b1 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4001,8 +4001,6 @@ void BaseGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - AnsiString dataDir = getDataDir(); - //sprintf(Buffer, "%s/save%03d.%s", dataDir.c_str(), Slot, _savedGameExt); BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); Common::String filename = pm->getFilenameForSlot(slot); delete pm; @@ -4046,14 +4044,10 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - - warning("BaseGame::IsSaveSlotUsed(%d) - FIXME, ugly solution", slot); - Common::SeekableReadStream *file = g_wintermute->getSaveFileMan()->openForLoading(filename); - if (!file) { - return false; - } - delete file; - return true; + BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + bool ret = pm->getSaveExists(slot); + delete pm; + return ret; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index b29935d943..e067241589 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -52,8 +52,6 @@ BaseSaveThumbFile::~BaseSaveThumbFile() { ////////////////////////////////////////////////////////////////////////// bool BaseSaveThumbFile::open(const Common::String &filename) { close(); - warning("SaveGame-thumbs disabled for now"); - return STATUS_FAILED; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { return STATUS_FAILED; -- cgit v1.2.3 From a190bb8fdc5959bb2b529baab0d45bc31d2f467a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:07:50 +0200 Subject: WINTERMUTE: Add a stubbed fallback for the absolute path used in East Side Story C:\\windows\\fonts\\framd.ttf --- engines/wintermute/base/file/base_disk_file.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 7d805aedb5..93533b4057 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -52,9 +52,10 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // The filename can be an explicit path, thus we need to chop it up, expecting the path the game // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) - // Absolute path: TODO: Add specific fallbacks here. + // Absolute path: These should have been handled in openDiskFile. if (filename.contains(':')) { - error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + // So just return an invalid node. + return Common::FSNode(); } // Relative path: @@ -112,9 +113,19 @@ bool diskFileExists(const Common::String &filename) { Common::SeekableReadStream *openDiskFile(const Common::String &filename) { uint32 prefixSize = 0; Common::SeekableReadStream *file = NULL; + Common::String fixedFilename = filename; + + // Absolute path: TODO: Add specific fallbacks here. + if (filename.contains(':')) { + if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" + fixedFilename = filename.c_str() + 17; + } else { + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + } + } // Try directly from SearchMan first Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, filename); + SearchMan.listMatchingMembers(files, fixedFilename); for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { if ((*it)->getName() == filename) { -- cgit v1.2.3 From a9e9ed7d3b5411e5eaf44ac87f1a10ce53e962d9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 16:08:46 +0200 Subject: WINTERMUTE: Formatting "var_name"->"varName" --- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 34ff717ae5..1f938dfac2 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -53,7 +53,7 @@ BaseFont::~BaseFont() { ////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { +void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 9431c730bd..152e08273d 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -69,8 +69,8 @@ BaseFontBitmap::~BaseFontBitmap() { ////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int max_height, int maxLength) { - textHeightDraw(text, x, y, width, align, true, max_height, maxLength); +void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); } -- cgit v1.2.3 From 6262a2ac8751b1bfff7becc8cf181ab9dd16bf87 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 17:43:17 +0200 Subject: WINTERMUTE: Use an arbitrary size nearest neighbour scaler for save thumbnails. Thanks to clone2727 --- engines/wintermute/base/gfx/base_image.cpp | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 628bffff55..3aa21d0f7f 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -224,27 +224,15 @@ bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { -#if 0 - if (_bitmap) { - FreeImage_Unload(_bitmap); - } - - if (NewWidth == 0) { - NewWidth = FreeImage_GetWidth(OrigImage->GetBitmap()); - } - if (NewHeight == 0) { - NewHeight = FreeImage_GetHeight(OrigImage->GetBitmap()); - } + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - _bitmap = FreeImage_Rescale(OrigImage->GetBitmap(), NewWidth, NewHeight, FILTER_BILINEAR); -#endif TransparentSurface temp(*origImage->_surface, false); if (_deletableSurface) { _deletableSurface->free(); delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scale(newWidth, newHeight); + _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); return true; } -- cgit v1.2.3 From f6ac34ab9a48b702e3c3678cfd208ebeb2517dc4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 18:13:42 +0200 Subject: WINTERMUTE: Get rid of almost all LLVM GCC 4.2 warnings. --- engines/wintermute/base/base_file_manager.cpp | 4 ++-- engines/wintermute/base/base_persistence_manager.cpp | 8 ++++---- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- engines/wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_file.cpp | 6 +++--- engines/wintermute/base/sound/base_sound.cpp | 3 ++- 8 files changed, 15 insertions(+), 14 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f1320b814b..5bad96d65e 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -253,8 +253,8 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f strcpy(fileName, upcName.c_str()); // correct slashes - for (int32 i = 0; i < upcName.size(); i++) { - if (upcName[i] == '/') { + for (uint32 i = 0; i < upcName.size(); i++) { + if (upcName[(int32)i] == '/') { upcName.setChar('\\', (uint32)i); } } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 995b996b33..ce7c66b7dd 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -492,7 +492,7 @@ float BasePersistenceManager::getFloat() { } void BasePersistenceManager::putDouble(double val) { - Common::String str = Common::String::format("F%f", val); + Common::String str = Common::String::format("D%f", val); str.format("D%f", val); _saveStream->writeUint32LE(str.size()); _saveStream->writeString(str); @@ -500,10 +500,10 @@ void BasePersistenceManager::putDouble(double val) { double BasePersistenceManager::getDouble() { char *str = getString(); - double value = 0.0f; - int ret = sscanf(str, "F%f", &value); + float value = 0.0f; // TODO: Do we ever really need to carry a full double-precision number? + int ret = sscanf(str, "D%f", &value); if (ret != 1) { - warning("%s not parsed as float", str); + warning("%s not parsed as double", str); } delete[] str; return value; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 3d878b1346..689066eb6e 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -73,7 +73,7 @@ bool BaseSurfaceStorage::initLoop() { break; } - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime >= _surfaces[i]->_lifeTime) { + if (_surfaces[i]->_lifeTime > 0 && (int)(_surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 152e08273d..ed7c13a54d 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -174,7 +174,7 @@ int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAli longLine = true; } - if (str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { done = true; if (!newLine) { end = index; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 168aa75d91..3a29bf542d 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -111,7 +111,7 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { ////////////////////////////////////////////////////////////////////////// void BaseRenderer::deleteRectList() { - for (int i = 0; i < _rectList.size(); i++) { + for (uint32 i = 0; i < _rectList.size(); i++) { delete _rectList[i]; } _rectList.clear(); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 27dbe9999c..0c0ec08ba9 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -199,7 +199,7 @@ bool PartParticle::display(PartEmitter *emitter) { } _sprite->getCurrentFrame(); - return _sprite->display(_pos.x, _pos.y, + return _sprite->display((int)_pos.x, (int)_pos.y, NULL, _scale, _scale, BYTETORGBA(255, 255, 255, _currentAlpha), diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 4eeabca04d..9736ae3ee2 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -211,8 +211,8 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Copy") == 0) { stack->correctParams(2); - const char *dest = stack->pop()->getString(); - bool overwrite = stack->pop()->getBool(true); + /* const char *dest = */ stack->pop()->getString(); + /* bool overwrite = */ stack->pop()->getBool(true); close(); error("SXFile-Method: Copy not supported"); @@ -601,7 +601,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, else if (strcmp(name, "WriteDouble") == 0) { error("SXFile::WriteDouble - Not endian safe yet"); stack->correctParams(1); - double val = stack->pop()->getFloat(); + /* double val = */ stack->pop()->getFloat(); if (_textMode || !_writeFile) { script->runtimeError("File.%s: File must be open for writing in binary mode.", name); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 9bea6be770..8a139ead4f 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -268,7 +268,8 @@ bool BaseSound::setPrivateVolume(int volume) { if (!_sound) { return STATUS_FAILED; } else { - return _sound->_privateVolume = volume; + _sound->_privateVolume = volume; + return STATUS_OK; } } -- cgit v1.2.3 From 99d4c55e88712a0b0dc0d97e4c9c52946a5f48f2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:07:00 +0200 Subject: WINTERMUTE: Remove all unneccessary #if 0 blocks --- .../wintermute/base/font/base_font_truetype.cpp | 164 +-------------------- engines/wintermute/base/gfx/base_image.cpp | 25 ++-- engines/wintermute/base/gfx/base_renderer.h | 1 + .../base/gfx/osystem/base_render_osystem.cpp | 114 +++----------- .../base/gfx/osystem/base_render_osystem.h | 2 +- .../base/scriptables/script_ext_date.cpp | 4 +- .../wintermute/base/scriptables/script_value.cpp | 4 - 7 files changed, 34 insertions(+), 280 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index c643a5e1b1..638b939ec1 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -256,12 +256,6 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, } else if (align == TAL_RIGHT) { alignment = Graphics::kTextAlignRight; } - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("BaseFontTT::RenderTextToTexture - Not fully ported yet"); - } debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; @@ -287,104 +281,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, delete surface; delete convertedSurface; return retSurface; -#if 0 //TODO - int textHeight = lines.size() * (_maxCharHeight + _ascender); - SDL_Surface *surface = SDL_CreateRGBSurface(0, width, textHeight, 32, 0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000); - - SDL_LockSurface(surface); - - int posY = (int)GetLineHeight() - (int)_descender; - - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - int posX = 0; - - switch (align) { - case TAL_CENTER: - posX += (width - line->GetWidth()) / 2; - break; - - case TAL_RIGHT: - posX += width - line->GetWidth(); - break; - } - - - textOffset = 0; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) { - continue; - } - - textOffset = MAX(textOffset, glyph->GetBearingY()); - } - - - int origPosX = posX; - - wchar_t prevChar = L'\0'; - for (size_t i = 0; i < line->GetText().size(); i++) { - wchar_t ch = line->GetText()[i]; - - GlyphInfo *glyph = _glyphCache->GetGlyph(ch); - if (!glyph) { - continue; - } - - float kerning = 0; - if (prevChar != L'\0') { - kerning = GetKerning(prevChar, ch); - } - posX += (int)kerning; - - - if (glyph->GetBearingY() > 0) { - int i = 10; - } - - SDL_Rect rect; - rect.x = posX + glyph->GetBearingX(); - rect.y = posY - glyph->GetBearingY() + textOffset; - rect.w = glyph->GetImage()->w; - rect.h = glyph->GetImage()->h; - - BlitSurface(glyph->GetImage(), surface, &rect); - - prevChar = ch; - posX += (int)(glyph->GetAdvanceX()); - posY += (int)(glyph->GetAdvanceY()); - } - - if (_isUnderline) { - for (int i = origPosX; i < origPosX + line->GetWidth(); i++) { - Uint8 *buf = (Uint8 *)surface->pixels + (int)(_underlinePos + _ascender) * surface->pitch; - Uint32 *buf32 = (Uint32 *)buf; - - buf32[i] = SDL_MapRGBA(surface->format, 255, 255, 255, 255); - } - } - - SDL_UnlockSurface(surface); - - delete line; - line = NULL; - posY += GetLineHeight(); - } - - BaseSurfaceOSystem *wmeSurface = new BaseSurfaceOSystem(_gameRef); - if (DID_SUCCEED(wmeSurface->CreateFromSDLSurface(surface))) { - SDL_FreeSurface(surface); - return wmeSurface; - } else { - SDL_FreeSurface(surface); - delete wmeSurface; - return NULL; - } -#endif - return NULL; + // TODO: _isUnderline, _isBold, _isItalic, _isStriked } @@ -666,65 +563,6 @@ bool BaseFontTT::initFont() { } _lineHeight = _font->getFontHeight(); return STATUS_OK; -#if 0 - FT_Error error; - - float vertDpi = 96.0; - float horDpi = 96.0; - - - _fTStream = (FT_Stream)new byte[sizeof(*_fTStream)]; - memset(_fTStream, 0, sizeof(*_fTStream)); - - _fTStream->read = BaseFontTT::FTReadSeekProc; - _fTStream->close = BaseFontTT::FTCloseProc; - _fTStream->descriptor.pointer = file; - _fTStream->size = file->GetSize(); - - FT_Open_Args args; - args.flags = FT_OPEN_STREAM; - args.stream = _fTStream; - - error = FT_Open_Face(_gameRef->_fontStorage->GetFTLibrary(), &args, 0, &_fTFace); - if (error) { - SAFE_DELETE_ARRAY(_fTStream); - _gameRef->_fileManager->closeFile(file); - return STATUS_FAILED; - } - - error = FT_Set_Char_Size(_fTFace, 0, (FT_F26Dot6)(_fontHeight * 64), (FT_UInt)horDpi, (FT_UInt)vertDpi); - if (error) { - FT_Done_Face(_fTFace); - _fTFace = NULL; - return STATUS_FAILED; - } - - // http://en.wikipedia.org/wiki/E_(typography) - float pixelsPerEm = (_fontHeight / 72.f) * vertDpi; // Size in inches * dpi - float emsPerUnit = 1.0f / _fTFace->units_per_EM; - float pixelsPerUnit = pixelsPerEm * EmsPerUnit; - - // bounding box in pixels - float xMin = _fTFace->bbox.xMin * pixelsPerUnit; - float xMax = _fTFace->bbox.xMax * pixelsPerUnit; - float yMin = _fTFace->bbox.yMin * pixelsPerUnit; - float yMax = _fTFace->bbox.yMax * pixelsPerUnit; - - // metrics in pixels - _ascender = _fTFace->ascender * pixelsPerUnit; - _descender = - _fTFace->descender * pixelsPerUnit; - _lineHeight = MathUtil::RoundUp(_fTFace->height * pixelsPerUnit) + 2; - _underlinePos = - _fTFace->underline_position * pixelsPerUnit; - - // max character size (used for texture grid) - _maxCharWidth = (size_t)MathUtil::RoundUp(xMax - xMin); - _maxCharHeight = (size_t)MathUtil::RoundUp(yMax - yMin); - - _glyphCache = new FontGlyphCache(); - _glyphCache->Initialize(); - -#endif - return STATUS_OK; } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 3aa21d0f7f..1fff59d85b 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -114,23 +114,16 @@ bool BaseImage::saveBMPFile(const char *filename) const { ////////////////////////////////////////////////////////////////////////// bool BaseImage::resize(int newWidth, int newHeight) { - warning("BaseImage::resize(%d, %d), stubbed", newWidth, newHeight); -#if 0 - if (!_bitmap) { - return STATUS_FAILED; - } - - if (newWidth == 0) { - NewWidth = FreeImage_GetWidth(_bitmap); - } - if (newHeight == 0) { - NewHeight = FreeImage_GetHeight(_bitmap); + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + TransparentSurface temp(*_surface, true); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; } - - - FIBITMAP *newImg = FreeImage_Rescale(_bitmap, NewWidth, NewHeight, FILTER_BILINEAR); -#endif - return false; + _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + temp.free(); + return true; } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 83b5ad0e16..008db69713 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -62,6 +62,7 @@ public: virtual BaseImage *takeScreenshot() = 0; virtual bool setViewport(int left, int top, int right, int bottom); virtual bool setViewport(Rect32 *rect); + virtual Rect32 getViewPort() = 0; virtual bool setScreenViewport(); virtual Graphics::PixelFormat getPixelFormat() const = 0; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 00ef2ec95c..90dda1af72 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -231,8 +231,6 @@ bool BaseRenderOSystem::flip() { ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { - //SDL_SetRenderDrawColor(_renderer, r, g, b, 0xFF); - //SDL_RenderClear(_renderer); _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); if (!_disableDirtyRects) { return STATUS_OK; @@ -240,6 +238,7 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { if (!rect) { rect = &_renderRect; } + // TODO: This doesn't work with dirty rects _renderSurface->fillRect(*rect, _clearColor); return STATUS_OK; @@ -410,7 +409,6 @@ void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { _dirtyRect->extend(rect); } _dirtyRect->clip(_renderRect); -// warning("AddDirtyRect: %d %d %d %d", rect.left, rect.top, rect.right, rect.bottom); } void BaseRenderOSystem::drawTickets() { @@ -421,7 +419,6 @@ void BaseRenderOSystem::drawTickets() { if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { RenderTicket *ticket = *it; addDirtyRect((*it)->_dstRect); - //warning("Discarding Rect: %d %d %d %d Width: %d Height: %d", (*it)->_dstRect.left, (*it)->_dstRect.top, (*it)->_dstRect.right, (*it)->_dstRect.bottom, (*it)->_dstRect.width() , (*it)->_dstRect.height()); it = _renderQueue.erase(it); delete ticket; decrement++; @@ -436,7 +433,6 @@ void BaseRenderOSystem::drawTickets() { // The color-mods are stored in the RenderTickets on add, since we set that state again during // draw, we need to keep track of what it was prior to draw. uint32 oldColorMod = _colorMod; -// warning("DirtyRect: %d %d %d %d Width: %d Height: %d", _dirtyRect->left, _dirtyRect->top, _dirtyRect->right, _dirtyRect->bottom, _dirtyRect->width(), _dirtyRect->height()); // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); @@ -521,38 +517,11 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { ////////////////////////////////////////////////////////////////////////// BaseImage *BaseRenderOSystem::takeScreenshot() { -// TODO: Fix this +// TODO: Clip by viewport. warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); screenshot->copyFrom(_renderSurface); return screenshot; -#if 0 - SDL_Rect viewport; - - SDL_RenderGetViewport(_renderer, &viewport); - - SDL_Surface *surface = SDL_CreateRGBSurface(0, viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK, 0x00000000); - if (!surface) { - return NULL; - } - - if (SDL_RenderReadPixels(_renderer, NULL, surface->format->format, surface->pixels, surface->pitch) < 0) { - return NULL; - } - - FIBITMAP *dib = FreeImage_Allocate(viewport.w, viewport.h, 24, FI_RGBA_RED_MASK, FI_RGBA_GREEN_MASK, FI_RGBA_BLUE_MASK); - - int bytespp = FreeImage_GetLine(dib) / FreeImage_GetWidth(dib); - - for (unsigned y = 0; y < FreeImage_GetHeight(dib); y++) { - byte *bits = FreeImage_GetScanLine(dib, y); - byte *src = (byte *)surface->pixels + (viewport.h - y - 1) * surface->pitch; - memcpy(bits, src, bytespp * viewport.w); - } - - return new BaseImage(_gameRef, dib); -#endif - return NULL; } ////////////////////////////////////////////////////////////////////////// @@ -569,84 +538,43 @@ bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { rect.right = (int16)((right - left) * _ratioX); rect.bottom = (int16)((bottom - top) * _ratioY); + _renderRect = rect; return STATUS_OK; } +Rect32 BaseRenderOSystem::getViewPort() { + Rect32 ret; + ret.top = _renderRect.top; + ret.bottom = _renderRect.bottom; + ret.left = _renderRect.left; + ret.right = _renderRect.right; + return ret; +} + ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - rect->x = MathUtil::Round(rect->x * _ratioX + _borderLeft - viewportRect.x); - rect->y = MathUtil::Round(rect->y * _ratioY + _borderTop - viewportRect.y); - rect->w = MathUtil::RoundUp(rect->w * _ratioX); - rect->h = MathUtil::RoundUp(rect->h * _ratioY); -#endif + rect->left = MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); + rect->top = MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); + rect->setWidth(MathUtil::roundUp(rect->width() * _ratioX)); + rect->setHeight(MathUtil::roundUp(rect->height() * _ratioY)); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointFromScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = point->x / _ratioX - _borderLeft / _ratioX + viewportRect.x; - point->y = point->y / _ratioY - _borderTop / _ratioY + viewportRect.y; -#endif + point->x = point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left; + point->y = point->y / _ratioY - _borderTop / _ratioY + _renderRect.top; } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointToScreen(Point32 *point) { -#if 0 - SDL_Rect viewportRect; - SDL_RenderGetViewport(GetSdlRenderer(), &viewportRect); - - point->x = MathUtil::RoundUp(point->x * _ratioX) + _borderLeft - viewportRect.x; - point->y = MathUtil::RoundUp(point->y * _ratioY) + _borderTop - viewportRect.y; -#endif + point->x = MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::dumpData(const char *filename) { - warning("BaseRenderOSystem::DumpData(%s) - not reimplemented yet", filename); // TODO -#if 0 - FILE *f = fopen(filename, "wt"); - if (!f) { - return; - } - - BaseSurfaceStorage *Mgr = _gameRef->_surfaceStorage; - - int totalKB = 0; - int totalLoss = 0; - fprintf(f, "Filename;Usage;Size;KBytes\n"); - for (int i = 0; i < Mgr->_surfaces.getSize(); i++) { - BaseSurfaceOSystem *Surf = (BaseSurfaceOSystem *)Mgr->_surfaces[i]; - if (!Surf->_filename) { - continue; - } - if (!Surf->_valid) { - continue; - } - - fprintf(f, "%s;%d;", Surf->_filename, Surf->_referenceCount); - fprintf(f, "%dx%d;", Surf->getWidth(), Surf->getHeight()); - - int kb = Surf->getWidth() * Surf->getHeight() * 4 / 1024; - - TotalKB += kb; - fprintf(f, "%d;", kb); - fprintf(f, "\n"); - } - fprintf(f, "Total %d;;;%d\n", Mgr->_surfaces.getSize(), TotalKB); - - - fclose(f); - _gameRef->LOG(0, "Texture Stats Dump completed."); - _gameRef->QuickMessage("Texture Stats Dump completed."); -#endif + warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO } BaseSurface *BaseRenderOSystem::createSurface() { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 0d00b1b427..dfffc68c17 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -82,7 +82,7 @@ public: void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); - + Rect32 getViewPort(); void modTargetRect(Common::Rect *rect); void pointFromScreen(Point32 *point); void pointToScreen(Point32 *point); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index a3bb7e2183..181be8ddd0 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -68,9 +68,7 @@ const char *SXDate::scToString() { // TODO: Make this more stringy, and less ISO 8601-like _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); return _strRep.c_str(); -#if 0 - return asctime(&_tm); -#endif + //return asctime(&_tm); } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 01cb4044ff..9b83daf42f 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -166,11 +166,7 @@ ScValue *ScValue::getProp(const char *name) { if (_type == VAL_STRING && strcmp(name, "Length") == 0) { _gameRef->_scValue->_type = VAL_INT; -#if 0 // TODO: Remove FreeType-dependency if (_gameRef->_textEncoding == TEXT_ANSI) { -#else - if (true) { -#endif _gameRef->_scValue->setInt(strlen(_valString)); } else { WideString wstr = StringUtil::utf8ToWide(_valString); -- cgit v1.2.3 From c7fa8e7d1024e4447a7396b5099870d01b775746 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:35:20 +0200 Subject: WINTERMUTE: Move settings-files to save-dir (gzipped xml now) --- engines/wintermute/base/base_game.cpp | 7 +++-- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/base_registry.cpp | 31 +++++++++++++--------- .../base/gfx/osystem/base_render_osystem.cpp | 25 +---------------- 4 files changed, 25 insertions(+), 40 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 8fd2b193b1..3e6cb6e043 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -80,7 +80,7 @@ IMPLEMENT_PERSISTENT(BaseGame, true) ////////////////////////////////////////////////////////////////////// -BaseGame::BaseGame(): BaseObject(this) { +BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { _shuttingDown = false; _state = GAME_RUNNING; @@ -259,6 +259,7 @@ BaseGame::BaseGame(): BaseObject(this) { _autoSaveSlot = 999; _cursorHidden = false; + // Block kept as a reminder that the engine CAN run in constrained/touch-mode /*#ifdef __IPHONEOS__ _touchInterface = true; _constrainedMemory = true; // TODO differentiate old and new iOS devices @@ -331,7 +332,7 @@ BaseGame::~BaseGame() { _stringTable = NULL; DEBUG_DebugDisable(); - BasePlatform::outputDebugString("--- shutting down normally ---\n"); + debugC(kWinterMuteDebugLog, "--- shutting down normally ---\n"); } @@ -2249,6 +2250,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "ShowStatusLine") == 0) { stack->correctParams(0); + // Block kept to show intention of opcode. /*#ifdef __IPHONEOS__ IOS_ShowStatusLine(TRUE); #endif*/ @@ -2262,6 +2264,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "HideStatusLine") == 0) { stack->correctParams(0); + // Block kept to show intention of opcode. /*#ifdef __IPHONEOS__ IOS_ShowStatusLine(FALSE); #endif*/ diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index d4a4c0e682..76881eefd7 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -147,7 +147,7 @@ public: SXMath *_mathClass; BaseSurfaceStorage *_surfaceStorage; BaseFontStorage *_fontStorage; - BaseGame(); + BaseGame(const Common::String &gameId); virtual ~BaseGame(); void DEBUG_DebugDisable(); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 441d00c05b..02f1da7322 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -32,6 +32,8 @@ #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" +#include "common/savefile.h" #include "common/config-manager.h" #include "common/file.h" @@ -173,16 +175,14 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - if (local) { - loadXml("settings.xml", _localValues); - } else { - loadXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); - } + Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - saveXml(PathUtil::combine(_gameRef->getDataDir(), "settings.xml"), _values); + Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + saveXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// @@ -212,10 +212,15 @@ AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, c ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - TiXmlDocument doc(fileName.c_str()); - if (!doc.LoadFile()) { + Common::SeekableReadStream *stream = g_wintermute->getSaveFileMan()->openForLoading(fileName); + if (!stream) { return; } + char *data = new char[stream->size()]; + stream->read(data, stream->size()); + TiXmlDocument doc; + doc.Parse(data); + delete data; TiXmlElement *rootElem = doc.RootElement(); if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) @@ -260,14 +265,14 @@ void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { TiXmlPrinter printer; doc.Accept(&printer); - Common::DumpFile stream; - stream.open(fileName.c_str()); + Common::WriteStream *stream = g_wintermute->getSaveFileMan()->openForSaving(fileName); - if (!stream.isOpen()) { + if (!stream) { return; } else { - stream.write(printer.CStr(), printer.Size()); - stream.close(); + stream->write(printer.CStr(), printer.Size()); + stream->finalize(); + delete stream; } } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 90dda1af72..58839d5ffe 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -124,33 +124,10 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _realWidth = width; _realHeight = height; + //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - // find suitable resolution - /*#ifdef __IPHONEOS__ - _realWidth = 480; - _realHeight = 320; - - int numModes = SDL_GetNumDisplayModes(0); - for (int i = 0; i < numModes; i++) { - SDL_DisplayMode mode; - SDL_GetDisplayMode(0, i, &mode); - - if (mode.w > mode.h) { - _realWidth = mode.w; - _realHeight = mode.h; - break; - } - } - #else*/ _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); -//#endif - - /* - _realWidth = 480; - _realHeight = 320; - */ - float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; -- cgit v1.2.3 From 8ed71a99f6aaee27a3187cb47fe0c3b30acf88a0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:37:00 +0200 Subject: WINTERMUTE: Constructor(args): SuperClass(args) -> Constructor(args) : SuperClass(args) --- engines/wintermute/base/base_active_rect.cpp | 6 +++--- engines/wintermute/base/base_dynamic_buffer.cpp | 2 +- engines/wintermute/base/base_fader.cpp | 2 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_keyboard_state.cpp | 2 +- engines/wintermute/base/base_object.cpp | 2 +- engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/base_quick_msg.cpp | 2 +- engines/wintermute/base/base_region.cpp | 2 +- engines/wintermute/base/base_registry.cpp | 2 +- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_scriptable.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_string_table.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/base_transition_manager.cpp | 2 +- engines/wintermute/base/base_viewport.cpp | 2 +- engines/wintermute/base/file/base_file.cpp | 2 +- engines/wintermute/base/file/base_save_thumb_file.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/base_renderer.cpp | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 2 +- engines/wintermute/base/scriptables/script_engine.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_array.cpp | 4 ++-- engines/wintermute/base/scriptables/script_ext_date.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_file.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_math.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp | 4 ++-- engines/wintermute/base/scriptables/script_ext_object.cpp | 2 +- engines/wintermute/base/scriptables/script_ext_string.cpp | 2 +- engines/wintermute/base/scriptables/script_stack.cpp | 2 +- engines/wintermute/base/scriptables/script_value.cpp | 10 +++++----- engines/wintermute/base/sound/base_sound.cpp | 2 +- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 +- engines/wintermute/base/sound/base_sound_manager.cpp | 2 +- 41 files changed, 49 insertions(+), 49 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 0756d10698..a895735725 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -34,7 +34,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { BasePlatform::setRectEmpty(&_rect); _owner = NULL; _frame = NULL; @@ -47,7 +47,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise) : BaseClass(inGame) { _owner = owner; _frame = frame; BasePlatform::setRect(&_rect, x, y, x + width, y + height); @@ -60,7 +60,7 @@ BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame } ////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY): BaseClass(inGame) { +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { _owner = owner; _region = region; BasePlatform::copyRect(&_rect, ®ion->_rect); diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index a61227b0dc..949548b68b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy): BaseClass(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) { _buffer = NULL; _size = 0; _realSize = 0; diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 04fde5457c..4bc166f841 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -39,7 +39,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFader, false) ////////////////////////////////////////////////////////////////////////// -BaseFader::BaseFader(BaseGame *inGame): BaseObject(inGame) { +BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { _active = false; _red = _green = _blue = 0; _currentAlpha = 0x00; diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 44e39823e6..edbfe3447f 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -44,7 +44,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFrame, false) ////////////////////////////////////////////////////////////////////// -BaseFrame::BaseFrame(BaseGame *inGame): BaseScriptable(inGame, true) { +BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _delay = 0; _moveX = _moveY = 0; diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 2b77cb23ca..01b5cea36d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -37,7 +37,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseKeyboardState, false) ////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::BaseKeyboardState(BaseGame *inGame): BaseScriptable(inGame) { +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(inGame) { _currentPrintable = false; _currentCharCode = 0; _currentKeyData = 0; diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 5fbfc31924..7d186c7f0a 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseObject, false) ////////////////////////////////////////////////////////////////////// -BaseObject::BaseObject(BaseGame *inGame): BaseScriptHolder(inGame) { +BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { _posX = _posY = 0; _movable = true; _zoomable = true; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 98d77f4ed5..3bd4f0441f 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -42,7 +42,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser(BaseGame *inGame): BaseClass(inGame) { +BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index bf38adb578..e9f3e430af 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text): BaseClass(inGame) { +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { _text = new char [strlen(text) + 1]; if (_text) { strcpy(_text, text); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 79ea5396fc..7335d904c7 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseRegion, false) ////////////////////////////////////////////////////////////////////////// -BaseRegion::BaseRegion(BaseGame *inGame): BaseObject(inGame) { +BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { _active = true; _editorSelectedPoint = -1; _lastMimicScale = -1; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 02f1da7322..2b6127bd09 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry(BaseGame *inGame): BaseClass(inGame) { +BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) { _iniName = NULL; setIniName("./wme.ini"); diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 5007b65422..8b71c73818 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame): BaseClass(inGame) { +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { _thumbnail = NULL; } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 131acf326f..51d1b32814 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -39,7 +39,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseScriptHolder, false) ////////////////////////////////////////////////////////////////////// -BaseScriptHolder::BaseScriptHolder(BaseGame *inGame): BaseScriptable(inGame) { +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { setName(""); _freezable = true; diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index ad89b63d65..743805cad7 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseScriptable, false) ////////////////////////////////////////////////////////////////////////// -BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable): BaseNamedObject(inGame) { +BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) : BaseNamedObject(inGame) { _refCount = 0; if (noValue) { diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index fb1b5a82cf..00af5bd960 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -47,7 +47,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSprite, false) ////////////////////////////////////////////////////////////////////// -BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner): BaseScriptHolder(inGame) { +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { _editorAllFrames = false; _owner = Owner; setDefaults(); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 18a18fe0ba..8dc9e25e4b 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseStringTable::BaseStringTable(BaseGame *inGame): BaseClass(inGame) { +BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { } diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index e8290ee659..17b5196f2a 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSubFrame, false) ////////////////////////////////////////////////////////////////////////// -BaseSubFrame::BaseSubFrame(BaseGame *inGame): BaseScriptable(inGame, true) { +BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _surface = NULL; _hotspotX = _hotspotY = 0; _alpha = 0xFFFFFFFF; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 689066eb6e..63e14aa543 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -38,7 +38,7 @@ namespace WinterMute { //IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); ////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame): BaseClass(inGame) { +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { _lastCleanupTime = 0; } diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 7a78865552..63a13309fb 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -32,7 +32,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame): BaseClass(inGame) { +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { _state = TRANS_MGR_READY; _type = TRANSITION_NONE; _origInteractive = false; diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index ad875ec00d..a6c7eea96e 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseViewport, false) ////////////////////////////////////////////////////////////////////////// -BaseViewport::BaseViewport(BaseGame *inGame): BaseClass(inGame) { +BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { BasePlatform::setRectEmpty(&_rect); _mainObject = NULL; _offsetX = _offsetY = 0; diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index b2c0b31db9..11d095e70b 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile(BaseGame *inGame): BaseClass(inGame) { +BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) { _pos = 0; _size = 0; } diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index e067241589..a285a93923 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame): BaseFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) { _data = NULL; } diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 1f938dfac2..5087f1752d 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -42,7 +42,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFont, false) ////////////////////////////////////////////////////////////////////// -BaseFont::BaseFont(BaseGame *inGame): BaseObject(inGame) { +BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ed7c13a54d..046ab77333 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -47,7 +47,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontBitmap, false) ////////////////////////////////////////////////////////////////////// -BaseFontBitmap::BaseFontBitmap(BaseGame *inGame): BaseFont(inGame) { +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { _subframe = NULL; _sprite = NULL; _widthsFrame = 0; diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 95f1ae601c..bc4152131f 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -41,7 +41,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontStorage, true) ////////////////////////////////////////////////////////////////////////// -BaseFontStorage::BaseFontStorage(BaseGame *inGame): BaseClass(inGame) { +BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { } ////////////////////////////////////////////////////////////////////////// diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 638b939ec1..2dd436dc37 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -48,7 +48,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseFontTT, false) ////////////////////////////////////////////////////////////////////////// -BaseFontTT::BaseFontTT(BaseGame *inGame): BaseFont(inGame) { +BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { _fontHeight = 12; _isBold = _isItalic = _isUnderline = _isStriked = false; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 3a29bf542d..ab5111332e 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -36,7 +36,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseRenderer::BaseRenderer(BaseGame *inGame): BaseClass(inGame) { +BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _window = 0; _clipperWindow = 0; _active = false; diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 635d48058f..62ddece47c 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -33,7 +33,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseSurface::BaseSurface(BaseGame *inGame): BaseClass(inGame) { +BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { _referenceCount = 0; _width = _height = 0; diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 75c4d38574..d8d4bc66da 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -38,7 +38,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScScript, false) ////////////////////////////////////////////////////////////////////////// -ScScript::ScScript(BaseGame *inGame, ScEngine *Engine): BaseClass(inGame) { +ScScript::ScScript(BaseGame *inGame, ScEngine *Engine) : BaseClass(inGame) { _buffer = NULL; _bufferSize = _iP = 0; _scriptStream = NULL; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index bc8d54ef58..01f647c110 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -44,7 +44,7 @@ IMPLEMENT_PERSISTENT(ScEngine, true) #define COMPILER_DLL "dcscomp.dll" ////////////////////////////////////////////////////////////////////////// -ScEngine::ScEngine(BaseGame *inGame): BaseClass(inGame) { +ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { _gameRef->LOG(0, "Initializing scripting engine..."); if (_compilerAvailable) { diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index cc3bec89c0..79303723e0 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -41,7 +41,7 @@ BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { _length = 0; _values = new ScValue(_gameRef); @@ -60,7 +60,7 @@ SXArray::SXArray(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { } ////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame): BaseScriptable(inGame) { +SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { _length = 0; _values = new ScValue(_gameRef); } diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 181be8ddd0..72f41c83cc 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -39,7 +39,7 @@ BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXDate::SXDate(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(6); memset(&_tm, 0, sizeof(_tm)); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 9736ae3ee2..5743722d6f 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -49,7 +49,7 @@ BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXFile::SXFile(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(1); ScValue *val = stack->pop(); diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 525b43434f..6b80da6389 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -47,7 +47,7 @@ BaseScriptable *makeSXMath(BaseGame *inGame) { } ////////////////////////////////////////////////////////////////////////// -SXMath::SXMath(BaseGame *inGame): BaseScriptable(inGame) { +SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { } diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 9bde5d45e7..afe5e65467 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -42,7 +42,7 @@ BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { stack->correctParams(1); _buffer = NULL; _size = 0; @@ -52,7 +52,7 @@ SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack): BaseScriptable(inGam } ////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer): BaseScriptable(inGame) { +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { _size = 0; _buffer = buffer; } diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index b72e3e4b97..ab7296b1ce 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -43,7 +43,7 @@ BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXObject::SXObject(BaseGame *inGame, ScStack *stack): BaseObject(inGame) { +SXObject::SXObject(BaseGame *inGame, ScStack *stack) : BaseObject(inGame) { int numParams = stack->pop()->getInt(0); for (int i = 0; i < numParams; i++) { addScript(stack->pop()->getString()); diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 1c7349bd8d..adbf16611c 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -44,7 +44,7 @@ BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { } ////////////////////////////////////////////////////////////////////////// -SXString::SXString(BaseGame *inGame, ScStack *stack): BaseScriptable(inGame) { +SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { _string = NULL; _capacity = 0; diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 8840a2c0f1..9b3a0201ac 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -35,7 +35,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScStack, false) ////////////////////////////////////////////////////////////////////////// -ScStack::ScStack(BaseGame *inGame): BaseClass(inGame) { +ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { _sP = -1; } diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 9b83daf42f..456f93507e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -43,7 +43,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(ScValue, false) ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { _type = VAL_NULL; _valBool = false; @@ -58,7 +58,7 @@ ScValue::ScValue(BaseGame *inGame): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { _type = VAL_BOOL; _valBool = val; @@ -73,7 +73,7 @@ ScValue::ScValue(BaseGame *inGame, bool val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { _type = VAL_INT; _valInt = val; @@ -88,7 +88,7 @@ ScValue::ScValue(BaseGame *inGame, int val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { _type = VAL_FLOAT; _valFloat = val; @@ -103,7 +103,7 @@ ScValue::ScValue(BaseGame *inGame, double val): BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, const char *val): BaseClass(inGame) { +ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { _type = VAL_STRING; _valString = NULL; setStringVal(val); diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 8a139ead4f..6151128624 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -36,7 +36,7 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSound, false) ////////////////////////////////////////////////////////////////////////// -BaseSound::BaseSound(BaseGame *inGame): BaseClass(inGame) { +BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sound = NULL; _soundFilename = NULL; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 25be117db2..ed667592e9 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -50,7 +50,7 @@ namespace WinterMute { #define MAX_NONSTREAMED_FILE_SIZE 1024*1024 ////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame): BaseClass(inGame) { +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { _stream = NULL; _handle = NULL; // _sync = NULL; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index d2e640e3f3..4659c35ff7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -46,7 +46,7 @@ namespace WinterMute { //IMPLEMENT_PERSISTENT(BaseSoundMgr, true); ////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::BaseSoundMgr(BaseGame *inGame): BaseClass(inGame) { +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { _soundAvailable = false; _volumeMaster = 255; } -- cgit v1.2.3 From e08a0d84a2dd4ebb312fc72b9757c303e351dbb1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 27 Jul 2012 19:42:37 +0200 Subject: WINTERMUTE: Hardcode the Game.SaveDirectory return value in-engine for now. --- engines/wintermute/base/base_game.cpp | 10 +--------- engines/wintermute/base/base_game.h | 1 - 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 3e6cb6e043..a7ea7fe95f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -2604,7 +2604,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = getDataDir(); + AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. _scValue->setString(dataDir.c_str()); return _scValue; } @@ -4012,14 +4012,6 @@ bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -AnsiString BaseGame::getDataDir() { - AnsiString userDir = PathUtil::getUserDirectory(); - AnsiString baseDir = _registry->getBasePath(); - return PathUtil::combine(userDir, baseDir); -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 76881eefd7..9adca0743c 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -254,7 +254,6 @@ public: virtual bool initAfterLoad(); BaseSaveThumbHelper *_cachedThumbnail; - AnsiString getDataDir(); void addMem(int bytes); bool _touchInterface; bool _constrainedMemory; -- cgit v1.2.3 From e841bf16d6b955f779e5e30535848bd650d22352 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 28 Jul 2012 23:10:33 +0200 Subject: WINTERMUTE: Fix a few warnings pointed out by fuzzie. --- engines/wintermute/base/base_file_manager.cpp | 3 ++- engines/wintermute/base/base_region.h | 3 ++- engines/wintermute/base/base_registry.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/file/base_package.cpp | 6 +++--- engines/wintermute/base/font/base_font_bitmap.cpp | 2 +- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 5 +++-- 7 files changed, 13 insertions(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 5bad96d65e..7fe7b3ab98 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -269,8 +269,9 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { BasePersistenceManager pm(_gameRef); - if (filename.size() < 9) + if (filename.size() <= 9) { return false; + } int slot = atoi(filename.c_str() + 9); return pm.getSaveExists(slot); } diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 3b4b28030d..7770d345f7 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -54,7 +54,8 @@ public: bool loadBuffer(byte *buffer, bool complete = true); Rect32 _rect; BaseArray _points; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride = NULL); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, NULL); } + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); // scripting interface virtual ScValue *scGetProperty(const char *name); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 2b6127bd09..afaa01f06d 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -220,7 +220,7 @@ void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { stream->read(data, stream->size()); TiXmlDocument doc; doc.Parse(data); - delete data; + delete[] data; TiXmlElement *rootElem = doc.RootElement(); if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 63e14aa543..c01c86c009 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -73,7 +73,7 @@ bool BaseSurfaceStorage::initLoop() { break; } - if (_surfaces[i]->_lifeTime > 0 && (int)(_surfaces[i]->_valid && _gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); _surfaces[i]->invalidate(); } diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 80d3b4a515..ab74810d1d 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -169,7 +169,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool for (uint32 j = 0; j < numFiles; j++) { char *name; - uint32 offset, length, compLength, flags, timeDate1, timeDate2; + uint32 offset, length, compLength, flags;/*, timeDate1, timeDate2;*/ nameLength = stream->readByte(); name = new char[nameLength]; @@ -195,8 +195,8 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool flags = stream->readUint32LE(); if (hdr._packageVersion == PACKAGE_VERSION) { - timeDate1 = stream->readUint32LE(); - timeDate2 = stream->readUint32LE(); + /* timeDate1 = */ stream->readUint32LE(); + /* timeDate2 = */ stream->readUint32LE(); } _filesIter = _files.find(upcName); if (_filesIter == _files.end()) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 046ab77333..e2c5fa881c 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -371,7 +371,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { case TOKEN_WIDTHS: parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS, num > 0; lastWidth++, num--, i++) { + for (i = 0; lastWidth < NUM_CHARACTERS && num > 0; lastWidth++, num--, i++) { _widths[lastWidth] = (byte)widths[i]; } break; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5102d182f9..d3209cb1c0 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -394,12 +394,13 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo // TODO: This actually requires us to have the SAME source-offsets every time, // But no checking is in place for that yet. - bool hasAlpha; + // TODO: Optimize by not doing alpha-blits if we lack or disable alpha +/* bool hasAlpha; if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; - } + }*/ if (alphaDisable) { warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } -- cgit v1.2.3 From 6dc1e09da93c0ba0507fd0ceadbbb504469deccc Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 00:27:50 +0200 Subject: WINTERMUTE: Replace const char* with const Common::String & in fonts, gfx, particles, sound and files. --- engines/wintermute/base/base.cpp | 8 ++-- engines/wintermute/base/base.h | 4 +- engines/wintermute/base/base_frame.cpp | 8 ++-- engines/wintermute/base/base_game.cpp | 4 +- engines/wintermute/base/base_sprite.cpp | 10 ++--- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/base_sub_frame.cpp | 6 +-- engines/wintermute/base/base_sub_frame.h | 2 +- engines/wintermute/base/base_surface_storage.cpp | 8 ++-- engines/wintermute/base/base_surface_storage.h | 2 +- engines/wintermute/base/font/base_font.cpp | 4 +- engines/wintermute/base/font/base_font.h | 4 +- engines/wintermute/base/font/base_font_bitmap.cpp | 8 ++-- engines/wintermute/base/font/base_font_bitmap.h | 2 +- engines/wintermute/base/font/base_font_storage.cpp | 6 +-- engines/wintermute/base/font/base_font_storage.h | 2 +- .../wintermute/base/font/base_font_truetype.cpp | 8 ++-- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/gfx/base_surface.cpp | 7 --- engines/wintermute/base/gfx/base_surface.h | 2 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- .../base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 12 +++--- engines/wintermute/base/particles/part_emitter.h | 6 +-- .../wintermute/base/particles/part_particle.cpp | 4 +- engines/wintermute/base/particles/part_particle.h | 2 +- engines/wintermute/base/scriptables/script.cpp | 32 +++++++------- engines/wintermute/base/scriptables/script.h | 16 +++---- engines/wintermute/base/sound/base_sound.cpp | 50 ++-------------------- engines/wintermute/base/sound/base_sound.h | 24 +++++------ .../wintermute/base/sound/base_sound_buffer.cpp | 17 +++----- engines/wintermute/base/sound/base_sound_buffer.h | 4 +- .../wintermute/base/sound/base_sound_manager.cpp | 9 ++-- engines/wintermute/base/sound/base_sound_manager.h | 2 +- 34 files changed, 115 insertions(+), 166 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index d5163fa7a6..074bd0db68 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -54,7 +54,7 @@ BaseClass::~BaseClass() { ////////////////////////////////////////////////////////////////////////// -const char *BaseClass::getEditorProp(const char *propName, const char *initVal) { +Common::String BaseClass::getEditorProp(const Common::String &propName, const Common::String &initVal) { _editorPropsIter = _editorProps.find(propName); if (_editorPropsIter != _editorProps.end()) { return _editorPropsIter->_value.c_str(); @@ -65,12 +65,12 @@ const char *BaseClass::getEditorProp(const char *propName, const char *initVal) ////////////////////////////////////////////////////////////////////////// -bool BaseClass::setEditorProp(const char *propName, const char *propValue) { - if (propName == NULL) { +bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { + if (propName.size() == 0) { return STATUS_FAILED; } - if (propValue == NULL) { + if (propValue.size() == 0) { _editorProps.erase(propName); } else { _editorProps[propName] = propValue; diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index 8c6aad12e6..dcd186be42 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -43,8 +43,8 @@ class BaseDynamicBuffer; class BaseClass { public: bool _persistable; - bool setEditorProp(const char *propName, const char *propValue); - const char *getEditorProp(const char *propName, const char *initVal = NULL); + bool setEditorProp(const Common::String &propName, const Common::String &propValue); + Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); BaseClass(TDynamicConstructor, TDynamicConstructor) {}; bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index edbfe3447f..27e07790bb 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -367,8 +367,8 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); } - if (_sound && _sound->_soundFilename) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->_soundFilename); + if (_sound && _sound->getFilename()) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); } buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); @@ -431,8 +431,8 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSound") == 0) { stack->correctParams(0); - if (_sound && _sound->_soundFilename) { - stack->pushString(_sound->_soundFilename); + if (_sound && _sound->getFilename()) { + stack->pushString(_sound->getFilename()); } else { stack->pushNULL(); } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index a7ea7fe95f..fdf638f94f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1247,10 +1247,10 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { stack->pushNULL(); } else { - if (!_music[channel] || !_music[channel]->_soundFilename) { + if (!_music[channel] || !_music[channel]->getFilename()) { stack->pushNULL(); } else { - stack->pushString(_music[channel]->_soundFilename); + stack->pushString(_music[channel]->getFilename()); } } return STATUS_OK; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 00af5bd960..6ab8e60a17 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -124,10 +124,10 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa ////////////////////////////////////////////////////////////////////// -bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType cacheType) { +bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); if (!file) { - _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); if (_gameRef->_debugDebugMode) { return loadFile("invalid_debug.bmp", lifeTime, cacheType); } else { @@ -146,7 +146,7 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename); + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); ret = STATUS_FAILED; delete frame; delete subframe; @@ -161,13 +161,13 @@ bool BaseSprite::loadFile(const char *filename, int lifeTime, TSpriteCacheType c byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { - _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename); + _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); } delete[] buffer; } } - setFilename(filename); + setFilename(filename.c_str()); return ret; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 084d7b2d70..952bff0017 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -67,7 +67,7 @@ public: bool _paused; bool _finished; bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const char *filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); uint32 _lastFrameTime; bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 17b5196f2a..6ce8c78b3b 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -594,7 +594,7 @@ const char *BaseSubFrame::scToString() { ////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSubFrame::setSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { if (_surface) { _gameRef->_surfaceStorage->removeSurface(_surface); _surface = NULL; @@ -605,8 +605,8 @@ bool BaseSubFrame::setSurface(const char *filename, bool defaultCK, byte ckRed, _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); if (_surface) { - _surfaceFilename = new char[strlen(filename) + 1]; - strcpy(_surfaceFilename, filename); + _surfaceFilename = new char[filename.size() + 1]; + strcpy(_surfaceFilename, filename.c_str()); _cKDefault = defaultCK; _cKRed = ckRed; diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 52b1d76c01..023e306706 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -41,7 +41,7 @@ public: bool _mirrorX; bool _mirrorY; bool _decoration; - bool setSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool setSurfaceSimple(); DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) void setDefaultRect(); diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index c01c86c009..7d6f499012 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -100,17 +100,17 @@ bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { ////////////////////////////////////////////////////////////////////// -BaseSurface *BaseSurfaceStorage::addSurface(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { for (uint32 i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename) == 0) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) { _surfaces[i]->_referenceCount++; return _surfaces[i]; } } if (!_gameRef->_fileManager->hasFile(filename)) { - if (filename) { - _gameRef->LOG(0, "Missing image: '%s'", filename); + if (filename.size()) { + _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); } if (_gameRef->_debugDebugMode) { return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 13c4deb3db..c09b0a30ab 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -44,7 +44,7 @@ public: //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); bool restoreAll(); - BaseSurface *addSurface(const char *filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + BaseSurface *addSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); bool removeSurface(BaseSurface *surface); BaseSurfaceStorage(BaseGame *inGame); virtual ~BaseSurfaceStorage(); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 5087f1752d..4a5cd31002 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -151,7 +151,7 @@ bool BaseFont::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const char *filename) { +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { if (isTrueType(gameRef, filename)) { BaseFontTT *font = new BaseFontTT(gameRef); if (font) { @@ -179,7 +179,7 @@ TOKEN_DEF(FONT) TOKEN_DEF(TTFONT) TOKEN_DEF_END ////////////////////////////////////////////////////////////////////////// -bool BaseFont::isTrueType(BaseGame *gameRef, const char *filename) { +bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_START(commands) TOKEN_TABLE(FONT) TOKEN_TABLE(TTFONT) diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 695bce2af3..f1dc962565 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -48,12 +48,12 @@ public: BaseFont(BaseGame *inGame); virtual ~BaseFont(); - static BaseFont *createFromFile(BaseGame *game, const char *filename); + static BaseFont *createFromFile(BaseGame *game, const Common::String &filename); private: //bool loadBuffer(byte * Buffer); //bool loadFile(const char* Filename); - static bool isTrueType(BaseGame *game, const char *filename); + static bool isTrueType(BaseGame *game, const Common::String &filename); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index e2c5fa881c..e7bf362b32 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -270,19 +270,19 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadFile(const char *filename) { +bool BaseFontBitmap::loadFile(const Common::String &filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; } bool ret; - setFilename(filename); + setFilename(filename.c_str()); if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); } delete[] buffer; diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index abf2d39aa0..fb992d2e9a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -38,7 +38,7 @@ class BaseFontBitmap : public BaseFont { public: DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) bool loadBuffer(byte *Buffer); - bool loadFile(const char *filename); + bool loadFile(const Common::String &filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index bc4152131f..0c34a8822a 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -71,13 +71,13 @@ bool BaseFontStorage::initLoop() { } ////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFontStorage::addFont(const char *filename) { - if (!filename) { +BaseFont *BaseFontStorage::addFont(const Common::String &filename) { + if (!filename.size()) { return NULL; } for (int i = 0; i < _fonts.getSize(); i++) { - if (scumm_stricmp(_fonts[i]->getFilename(), filename) == 0) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { _fonts[i]->_refCount++; return _fonts[i]; } diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 3af9244ffe..3a39617c32 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -43,7 +43,7 @@ public: DECLARE_PERSISTENT(BaseFontStorage, BaseClass) bool cleanup(bool warn = false); bool removeFont(BaseFont *font); - BaseFont *addFont(const char *filename); + BaseFont *addFont(const Common::String &filename); BaseFontStorage(BaseGame *inGame); virtual ~BaseFontStorage(); BaseArray _fonts; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 2dd436dc37..793c044839 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -292,19 +292,19 @@ int BaseFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadFile(const char *filename) { +bool BaseFontTT::loadFile(const Common::String &filename) { byte *buffer = _gameRef->_fileManager->readWholeFile(filename); if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename); + _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; } bool ret; - setFilename(filename); + setFilename(filename.c_str()); if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename); + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); } delete[] buffer; diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 20ef531a46..a893e70ec0 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -105,7 +105,7 @@ public: virtual int getLetterHeight(); bool loadBuffer(byte *buffer); - bool loadFile(const char *filename); + bool loadFile(const Common::String &filename); float getLineHeight() const { return _lineHeight; diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 62ddece47c..28ac4e6973 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -59,13 +59,6 @@ BaseSurface::~BaseSurface() { } } - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - return STATUS_FAILED; -} - - ////////////////////////////////////////////////////////////////////// bool BaseSurface::restore() { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 4f67f871dd..57a51ce3aa 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -56,7 +56,7 @@ public: virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; virtual bool restore(); - virtual bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; virtual bool create(int width, int height); virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index d3209cb1c0..642f2179e6 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -90,7 +90,7 @@ bool hasTransparency(Graphics::Surface *surf) { } ////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { +bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ _filename = filename; // const Graphics::Surface *surface = image->getSurface(); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 8e4370892b..fe1d055026 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -41,7 +41,7 @@ public: BaseSurfaceOSystem(BaseGame *inGame); ~BaseSurfaceOSystem(); - bool create(const char *filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); bool create(int width, int height); bool isTransparentAt(int x, int y); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index f8c0c1a5cf..7389885f5a 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -403,11 +403,11 @@ bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int } ////////////////////////////////////////////////////////////////////////// -PartForce *PartEmitter::addForceByName(const char *name) { +PartForce *PartEmitter::addForceByName(const Common::String &name) { PartForce *force = NULL; for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->getName()) == 0) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { force = _forces[i]; break; } @@ -415,7 +415,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { if (!force) { force = new PartForce(_gameRef); if (force) { - force->setName(name); + force->setName(name.c_str()); _forces.add(force); } } @@ -424,7 +424,7 @@ PartForce *PartEmitter::addForceByName(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { +bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { PartForce *force = addForceByName(name); if (!force) { return STATUS_FAILED; @@ -442,9 +442,9 @@ bool PartEmitter::addForce(const char *name, PartForce::TForceType type, int pos } ////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeForce(const char *name) { +bool PartEmitter::removeForce(const Common::String &name) { for (int i = 0; i < _forces.getSize(); i++) { - if (scumm_stricmp(name, _forces[i]->getName()) == 0) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { delete _forces[i]; _forces.remove_at(i); return STATUS_OK; diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 4e3b837a11..438dfff521 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -57,8 +57,8 @@ public: bool setBorder(int x, int y, int width, int height); bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - bool addForce(const char *name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const char *name); + bool addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const Common::String &name); BaseArray _forces; @@ -126,7 +126,7 @@ private: char *_emitEvent; BaseScriptHolder *_owner; - PartForce *addForceByName(const char *name); + PartForce *addForceByName(const Common::String &name); int static compareZ(const void *obj1, const void *obj2); bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); bool updateInternal(uint32 currentTime, uint32 timerDelta); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 0c0ec08ba9..2b05edd61f 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -70,8 +70,8 @@ PartParticle::~PartParticle(void) { } ////////////////////////////////////////////////////////////////////////// -bool PartParticle::setSprite(const char *filename) { - if (_sprite && _sprite->getFilename() && scumm_stricmp(filename, _sprite->getFilename()) == 0) { +bool PartParticle::setSprite(const Common::String &filename) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { _sprite->reset(); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 8b0c6eea36..44da85a559 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -72,7 +72,7 @@ public: bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); bool display(PartEmitter *emitter); - bool setSprite(const char *filename); + bool setSprite(const Common::String &filename); bool fadeIn(uint32 currentTime, int fadeTime); bool fadeOut(uint32 currentTime, int fadeTime); diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index d8d4bc66da..29185edce6 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -277,14 +277,14 @@ bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScrip ////////////////////////////////////////////////////////////////////////// -bool ScScript::createThread(ScScript *original, uint32 initIP, const char *eventName) { +bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { cleanup(); _thread = true; _methodThread = false; - _threadEvent = new char[strlen(eventName) + 1]; + _threadEvent = new char[eventName.size() + 1]; if (_threadEvent) { - strcpy(_threadEvent, eventName); + strcpy(_threadEvent, eventName.c_str()); } // copy filename @@ -329,7 +329,7 @@ bool ScScript::createThread(ScScript *original, uint32 initIP, const char *event ////////////////////////////////////////////////////////////////////////// -bool ScScript::createMethodThread(ScScript *original, const char *methodName) { +bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { uint32 ip = original->getMethodPos(methodName); if (ip == 0) { return STATUS_FAILED; @@ -339,9 +339,9 @@ bool ScScript::createMethodThread(ScScript *original, const char *methodName) { _thread = true; _methodThread = true; - _threadEvent = new char[strlen(methodName) + 1]; + _threadEvent = new char[methodName.size() + 1]; if (_threadEvent) { - strcpy(_threadEvent, methodName); + strcpy(_threadEvent, methodName.c_str()); } // copy filename @@ -1149,9 +1149,9 @@ bool ScScript::executeInstruction() { ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getFuncPos(const char *name) { +uint32 ScScript::getFuncPos(const Common::String &name) { for (uint32 i = 0; i < _numFunctions; i++) { - if (strcmp(name, _functions[i].name) == 0) { + if (name == _functions[i].name) { return _functions[i].pos; } } @@ -1160,9 +1160,9 @@ uint32 ScScript::getFuncPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getMethodPos(const char *name) { +uint32 ScScript::getMethodPos(const Common::String &name) { for (uint32 i = 0; i < _numMethods; i++) { - if (strcmp(name, _methods[i].name) == 0) { + if (name == _methods[i].name) { return _methods[i].pos; } } @@ -1357,7 +1357,7 @@ bool ScScript::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// -ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) { +ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { //if (_state!=SCRIPT_PERSISTENT) return NULL; uint32 pos = getEventPos(eventName); @@ -1371,7 +1371,7 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName); + _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str()); return thread; } else { delete thread; @@ -1385,9 +1385,9 @@ ScScript *ScScript::invokeEventHandler(const char *eventName, bool unbreakable) ////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getEventPos(const char *name) { +uint32 ScScript::getEventPos(const Common::String &name) { for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name, _events[i].name) == 0) { + if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { return _events[i].pos; } } @@ -1396,13 +1396,13 @@ uint32 ScScript::getEventPos(const char *name) { ////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleEvent(const char *eventName) { +bool ScScript::canHandleEvent(const Common::String &eventName) { return getEventPos(eventName) != 0; } ////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleMethod(const char *methodName) { +bool ScScript::canHandleMethod(const Common::String &methodName) { return getMethodPos(methodName) != 0; } diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 2ee1319acb..6b5fa1733b 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -62,11 +62,11 @@ public: bool _freezable; bool resume(); bool pause(); - bool canHandleEvent(const char *eventName); - bool canHandleMethod(const char *methodName); - bool createThread(ScScript *original, uint32 initIP, const char *eventName); - bool createMethodThread(ScScript *original, const char *methodName); - ScScript *invokeEventHandler(const char *eventName, bool unbreakable = false); + bool canHandleEvent(const Common::String &eventName); + bool canHandleMethod(const Common::String &methodName); + bool createThread(ScScript *original, uint32 initIP, const Common::String &eventName); + bool createMethodThread(ScScript *original, const Common::String &methodName); + ScScript *invokeEventHandler(const Common::String &eventName, bool unbreakable = false); uint32 _timeSlice; DECLARE_PERSISTENT(ScScript, BaseClass) void runtimeError(const char *fmt, ...); @@ -82,9 +82,9 @@ public: TScriptState _state; TScriptState _origState; ScValue *getVar(char *name); - uint32 getFuncPos(const char *name); - uint32 getEventPos(const char *name); - uint32 getMethodPos(const char *name); + uint32 getFuncPos(const Common::String &name); + uint32 getEventPos(const Common::String &name); + uint32 getMethodPos(const Common::String &name); typedef struct { uint32 magic; uint32 version; diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 6151128624..7e32552d08 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -35,10 +35,9 @@ namespace WinterMute { IMPLEMENT_PERSISTENT(BaseSound, false) -////////////////////////////////////////////////////////////////////////// BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sound = NULL; - _soundFilename = NULL; + _soundFilename = ""; _soundType = Audio::Mixer::kSFXSoundType; _soundStreamed = false; @@ -54,32 +53,23 @@ BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; } - -////////////////////////////////////////////////////////////////////////// BaseSound::~BaseSound() { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); } _sound = NULL; - - delete[] _soundFilename; - _soundFilename = NULL; } - -////////////////////////////////////////////////////////////////////////// -bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { if (_sound) { _gameRef->_soundMgr->removeSound(_sound); _sound = NULL; } - delete[] _soundFilename; - _soundFilename = NULL; + _soundFilename = Common::String(); // Set empty _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); if (_sound) { - _soundFilename = new char[strlen(filename) + 1]; - strcpy(_soundFilename, filename); + _soundFilename = filename; _soundType = type; _soundStreamed = streamed; @@ -90,8 +80,6 @@ bool BaseSound::setSound(const char *filename, Audio::Mixer::SoundType type, boo } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::setSoundSimple() { _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); if (_sound) { @@ -112,9 +100,6 @@ bool BaseSound::setSoundSimple() { } } - - -////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getLength() { if (_sound) { return _sound->getLength(); @@ -123,8 +108,6 @@ uint32 BaseSound::getLength() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::play(bool looping) { if (_sound) { _soundPaused = false; @@ -134,8 +117,6 @@ bool BaseSound::play(bool looping) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::stop() { if (_sound) { _soundPaused = false; @@ -145,8 +126,6 @@ bool BaseSound::stop() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::pause(bool freezePaused) { if (_sound) { _soundPaused = true; @@ -159,8 +138,6 @@ bool BaseSound::pause(bool freezePaused) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::resume() { if (_sound && _soundPaused) { _soundPaused = false; @@ -170,8 +147,6 @@ bool BaseSound::resume() { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::persist(BasePersistenceManager *persistMgr) { if (persistMgr->getIsSaving() && _sound) { _soundPlaying = _sound->isPlaying(); @@ -205,20 +180,14 @@ bool BaseSound::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::isPlaying() { return _sound && _sound->isPlaying(); } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::isPaused() { return _sound && _soundPaused; } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPositionTime(uint32 time) { if (!_sound) { return STATUS_FAILED; @@ -231,8 +200,6 @@ bool BaseSound::setPositionTime(uint32 time) { return ret; } - -////////////////////////////////////////////////////////////////////////// uint32 BaseSound::getPositionTime() { if (!_sound) { return 0; @@ -245,7 +212,6 @@ uint32 BaseSound::getPositionTime() { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolumePercent(int percent) { if (!_sound) { return STATUS_FAILED; @@ -254,7 +220,6 @@ bool BaseSound::setVolumePercent(int percent) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setVolume(int volume) { if (!_sound) { return STATUS_FAILED; @@ -263,7 +228,6 @@ bool BaseSound::setVolume(int volume) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPrivateVolume(int volume) { if (!_sound) { return STATUS_FAILED; @@ -273,7 +237,6 @@ bool BaseSound::setPrivateVolume(int volume) { } } -////////////////////////////////////////////////////////////////////////// int BaseSound::getVolumePercent() { if (!_sound) { return 0; @@ -282,7 +245,6 @@ int BaseSound::getVolumePercent() { } } -////////////////////////////////////////////////////////////////////////// int BaseSound::getVolume() { if (!_sound) { return 0; @@ -291,7 +253,6 @@ int BaseSound::getVolume() { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setLoopStart(uint32 pos) { if (!_sound) { return STATUS_FAILED; @@ -301,7 +262,6 @@ bool BaseSound::setLoopStart(uint32 pos) { } } -////////////////////////////////////////////////////////////////////////// bool BaseSound::setPan(float pan) { if (_sound) { return _sound->setPan(pan); @@ -310,8 +270,6 @@ bool BaseSound::setPan(float pan) { } } - -////////////////////////////////////////////////////////////////////////// bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { if (!_sound) { return STATUS_OK; diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index 7ea9f38f6c..cadba77bc8 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -40,7 +40,6 @@ class BaseSoundBuffer; class BaseSound : public BaseClass { public: bool setPan(float pan); - int _soundPrivateVolume; int getVolume(); int getVolumePercent(); bool setVolumePercent(int percent); @@ -49,31 +48,32 @@ public: bool setLoopStart(uint32 pos); uint32 getPositionTime(); bool setPositionTime(uint32 time); - bool _soundPaused; - bool _soundFreezePaused; bool isPlaying(); bool isPaused(); - bool _soundPlaying; - bool _soundLooping; - uint32 _soundLoopStart; - uint32 _soundPosition; DECLARE_PERSISTENT(BaseSound, BaseClass) bool resume(); bool pause(bool freezePaused = false); bool stop(); bool play(bool looping = false); uint32 getLength(); - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - char *_soundFilename; + const char *getFilename() { return _soundFilename.c_str(); } bool setSoundSimple(); - bool setSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); BaseSound(BaseGame *inGame); virtual ~BaseSound(); bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); - private: + Common::String _soundFilename; + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + int _soundPrivateVolume; + uint32 _soundLoopStart; + uint32 _soundPosition; + bool _soundPlaying; + bool _soundLooping; + bool _soundPaused; + bool _soundFreezePaused; TSFXType _sFXType; float _sFXParam1; float _sFXParam2; diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index ed667592e9..5f36eb96d4 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -56,7 +56,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { // _sync = NULL; _streamed = false; - _filename = NULL; + _filename = ""; _file = NULL; _privateVolume = 255; _volume = 255; @@ -82,9 +82,6 @@ BaseSoundBuffer::~BaseSoundBuffer() { } delete _stream; _stream = NULL; - - delete[] _filename; - _filename = NULL; } @@ -95,13 +92,13 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block ////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { - debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename, forceReload); +bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { + debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = _gameRef->_fileManager->openFile(filename, true, false); if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename); + _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); return STATUS_FAILED; } Common::String strFilename(filename); @@ -118,16 +115,16 @@ bool BaseSoundBuffer::loadFromFile(const char *filename, bool forceReload) { _file = new Common::SeekableSubReadStream(_file, 0, waveSize); _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); } else { - error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename, waveType); + error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType); } } } else { - error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename); + error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str()); } if (!_stream) { return STATUS_FAILED; } - BaseUtils::setString(&_filename, filename); + _filename = filename; return STATUS_OK; } diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 107ceb87d7..7aec144283 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -72,7 +72,7 @@ public: void setType(Audio::Mixer::SoundType Type); - bool loadFromFile(const char *filename, bool forceReload = false); + bool loadFromFile(const Common::String &filename, bool forceReload = false); void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); @@ -89,7 +89,7 @@ public: int _privateVolume; private: uint32 _startPos; - char *_filename; + Common::String _filename; bool _streamed; Common::SeekableReadStream *_file; int _volume; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 4659c35ff7..8df9f299ef 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -89,13 +89,14 @@ bool BaseSoundMgr::initialize() { } ////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::SoundType type, bool streamed) { +BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { if (!_soundAvailable) { return NULL; } BaseSoundBuffer *sound; + Common::String useFilename = filename; // try to switch WAV to OGG file (if available) AnsiString ext = PathUtil::getExtension(filename); if (StringUtil::compareNoCase(ext, "wav")) { @@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun AnsiString newFile = PathUtil::combine(path, name + "ogg"); if (_gameRef->_fileManager->hasFile(newFile)) { - filename = newFile.c_str(); + useFilename = newFile; } } @@ -117,9 +118,9 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const char *filename, Audio::Mixer::Soun sound->setType(type); - bool res = sound->loadFromFile(filename); + bool res = sound->loadFromFile(useFilename); if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", filename); + _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); delete sound; return NULL; } diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index 464330c733..a2b8f2c9e9 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -53,7 +53,7 @@ public: uint32 _volumeOriginal; int _volumeMaster; bool removeSound(BaseSoundBuffer *sound); - BaseSoundBuffer *addSound(const char *filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); bool initialize(); bool _soundAvailable; -- cgit v1.2.3 From b214041539559e65b89b3270439970fd7173dcbe Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 00:58:15 +0200 Subject: WINTERMUTE: Remove static function variable from SXArray --- engines/wintermute/base/scriptables/script_ext_array.cpp | 5 +++-- engines/wintermute/base/scriptables/script_ext_array.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 79303723e0..a422d6d8a5 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -75,7 +75,7 @@ SXArray::~SXArray() { ////////////////////////////////////////////////////////////////////////// const char *SXArray::scToString() { - static char dummy[32768]; // TODO: Get rid of static. + char dummy[32768]; strcpy(dummy, ""); char propName[20]; for (int i = 0; i < _length; i++) { @@ -91,7 +91,8 @@ const char *SXArray::scToString() { strcat(dummy, ","); } } - return dummy; + _strRep = dummy; + return _strRep.c_str(); } diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 67a1104b46..f2718f4ea2 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -48,6 +48,7 @@ public: private: int _length; ScValue *_values; + Common::String _strRep; }; } // end of namespace WinterMute -- cgit v1.2.3 From 9b5cf8f1bafd5aa0dba9194a8f04e58724652891 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 02:30:26 +0200 Subject: WINTERMUTE: Introduce a Singleton-class for holding registry/filemanager. --- engines/wintermute/base/base.cpp | 2 +- engines/wintermute/base/base_dynamic_buffer.cpp | 10 +- engines/wintermute/base/base_dynamic_buffer.h | 2 +- engines/wintermute/base/base_engine.cpp | 108 +++++++++++++++++++++ engines/wintermute/base/base_engine.h | 59 +++++++++++ engines/wintermute/base/base_file_manager.cpp | 28 ++++-- engines/wintermute/base/base_file_manager.h | 5 +- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_game.cpp | 61 +++++------- engines/wintermute/base/base_game.h | 2 - engines/wintermute/base/base_parser.cpp | 5 +- engines/wintermute/base/base_parser.h | 5 +- .../wintermute/base/base_persistence_manager.cpp | 11 ++- engines/wintermute/base/base_persistence_manager.h | 2 +- engines/wintermute/base/base_region.cpp | 4 +- engines/wintermute/base/base_registry.cpp | 8 +- engines/wintermute/base/base_registry.h | 9 +- engines/wintermute/base/base_save_thumb_helper.cpp | 2 +- engines/wintermute/base/base_script_holder.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 8 +- engines/wintermute/base/base_string_table.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/file/base_file.cpp | 2 +- engines/wintermute/base/file/base_file.h | 4 +- .../wintermute/base/file/base_save_thumb_file.cpp | 6 +- .../wintermute/base/file/base_save_thumb_file.h | 2 +- engines/wintermute/base/font/base_font.cpp | 9 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 +- .../wintermute/base/font/base_font_truetype.cpp | 10 +- engines/wintermute/base/gfx/base_image.cpp | 4 +- engines/wintermute/base/gfx/base_image.h | 2 +- .../base/gfx/osystem/base_render_osystem.cpp | 9 +- .../base/gfx/osystem/base_surface_osystem.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 +- .../wintermute/base/particles/part_particle.cpp | 3 +- .../wintermute/base/scriptables/script_engine.cpp | 13 +-- .../base/scriptables/script_ext_file.cpp | 6 +- .../wintermute/base/sound/base_sound_buffer.cpp | 2 +- .../wintermute/base/sound/base_sound_manager.cpp | 7 +- 40 files changed, 301 insertions(+), 129 deletions(-) create mode 100644 engines/wintermute/base/base_engine.cpp create mode 100644 engines/wintermute/base/base_engine.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 074bd0db68..8fa26f04a6 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -101,7 +101,7 @@ bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 949548b68b..d953483be8 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -26,13 +26,13 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_dynamic_buffer.h" namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) : BaseClass(inGame) { +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { _buffer = NULL; _size = 0; _realSize = 0; @@ -80,7 +80,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) { _buffer = (byte *)malloc(initSize); if (!_buffer) { - _gameRef->LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); + BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); return STATUS_FAILED; } @@ -101,7 +101,7 @@ bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { _realSize += _growBy; _buffer = (byte *)realloc(_buffer, _realSize); if (!_buffer) { - _gameRef->LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); return STATUS_FAILED; } } @@ -121,7 +121,7 @@ bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { } if (_offset + size > _size) { - _gameRef->LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); + BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); return STATUS_FAILED; } diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 0567f874df..ff3897e71b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -34,7 +34,7 @@ namespace WinterMute { -class BaseDynamicBuffer : public BaseClass { +class BaseDynamicBuffer { public: bool _initialized; void putText(const char *fmt, ...); diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp new file mode 100644 index 0000000000..cd6e9c9e3b --- /dev/null +++ b/engines/wintermute/base/base_engine.cpp @@ -0,0 +1,108 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/wintermute.h" +#include "common/system.h" + +namespace WinterMute { + +BaseEngine *BaseEngine::_instance = 0; + /* +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; +public: + ~BaseEngine(); + BaseEngine *getInstance(); + BaseFileManager *getFileMan() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } +};*/ +BaseEngine::BaseEngine() { + +} + +void BaseEngine::init() { + _registry = new BaseRegistry(); + // File-manager depends on registry. + _fileManager = new BaseFileManager(); +} + +BaseEngine::~BaseEngine() { + delete _fileManager; + delete _registry; +} + +BaseEngine *BaseEngine::getInstance() { + if (!_instance) + assert(0); + return _instance; +} + +void BaseEngine::createInstance(const Common::String &gameid) { + if (_instance) { + delete _instance; + _instance = NULL; + } + _instance = new BaseEngine(); + _instance->_gameId = gameid; + _instance->init(); +} + +void BaseEngine::destroyInstance() { + delete _instance; + _instance = NULL; +} + +void BaseEngine::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + if (_instance && _instance->_gameRef) { + _instance->_gameRef->LOG("%s", buff); + } else { + debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + } +} + +} // end of namespace WinterMute \ No newline at end of file diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h new file mode 100644 index 0000000000..5782c012d8 --- /dev/null +++ b/engines/wintermute/base/base_engine.h @@ -0,0 +1,59 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + + #include "common/str.h" + +namespace WinterMute { + +class BaseFileManager; +class BaseRegistry; +class BaseGame; +class BaseEngine { + static BaseEngine *_instance; + BaseEngine(); + void init(); + BaseFileManager *_fileManager; + BaseRegistry *_registry; + Common::String _gameId; + BaseGame *_gameRef; +public: + ~BaseEngine(); + static void createInstance(const Common::String &gameid); + static BaseEngine *getInstance(); + static void destroyInstance(); + + void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } + + BaseGame *getGameRef() { return _gameRef; } + BaseFileManager *getFileManager() { return _fileManager; } + BaseRegistry *getRegistry() { return _registry; } + static void LOG(bool res, const char *fmt, ...); + const char *getGameId() { return _gameId.c_str(); } +}; + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 7fe7b3ab98..83047ca75c 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -27,13 +27,15 @@ */ #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/file/base_disk_file.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" #include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" +#include "common/debug.h" #include "common/str.h" #include "common/tokenizer.h" #include "common/textconsole.h" @@ -52,7 +54,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(BaseGame *inGame) : _gameRef(inGame) { +BaseFileManager::BaseFileManager() { initPaths(); registerPackages(); } @@ -145,14 +147,15 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!_gameRef) { // This function only works when the game-registry is loaded + BaseEngine *enginePtr = BaseEngine::getInstance(); + if (!enginePtr) { // This function only works when the game-registry is loaded return STATUS_FAILED; } AnsiString pathList; // single files paths - pathList = _gameRef->_registry->readString("Resource", "CustomPaths", ""); + pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", ""); Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); // numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); while (!entries->empty()) { @@ -169,7 +172,7 @@ bool BaseFileManager::initPaths() { const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = _gameRef->_registry->readString("Resource", "PackagePaths", ""); + pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", ""); entries = new Common::StringTokenizer(pathList, ";"); while (!entries->empty()) { Common::String path = entries->nextToken(); @@ -268,7 +271,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(_gameRef); + BasePersistenceManager pm(BaseEngine::getInstance()->getGameId()); if (filename.size() <= 9) { return false; } @@ -320,10 +323,10 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!_gameRef) { - error("Attempt to load filename: %s without BaseGame-object, this is unsupported", filename.c_str()); + if (!BaseEngine::getInstance()) { + error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); } - BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(_gameRef); + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); if (DID_SUCCEED(saveThumbFile->open(filename))) { ret = saveThumbFile->getMemStream(); } @@ -350,4 +353,11 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return NULL; } +BaseFileManager *BaseFileManager::getEngineInstance() { + if (BaseEngine::getInstance()) { + return BaseEngine::getInstance()->getFileManager(); + } + return NULL; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index c49bbe3815..23032ca65a 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -35,7 +35,6 @@ #include "common/file.h" namespace WinterMute { -class BaseGame; class BaseFileManager { public: bool cleanup(); @@ -45,10 +44,11 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(BaseGame *inGame = NULL); + BaseFileManager(); virtual ~BaseFileManager(); // Used only for detection bool registerPackages(const Common::FSList &fslist); + static BaseFileManager *getEngineInstance(); private: typedef enum { PATH_PACKAGE, @@ -67,7 +67,6 @@ private: Common::Array _openFiles; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: - BaseGame *_gameRef; }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 27e07790bb..87213b1421 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -162,7 +162,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index fdf638f94f..687e394920 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -27,6 +27,7 @@ */ #include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_file_manager.h" @@ -94,7 +95,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _fontStorage = NULL; _renderer = NULL; _soundMgr = NULL; - _fileManager = NULL; _transMgr = NULL; _debugMgr = NULL; _scEngine = NULL; @@ -144,7 +144,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _useD3D = false; - _registry = new BaseRegistry(this); _stringTable = new BaseStringTable(this); for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { @@ -280,7 +279,7 @@ BaseGame::~BaseGame() { getDebugMgr()->onGameShutdown(); - _registry->writeBool("System", "LastRun", true); + BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -304,8 +303,6 @@ BaseGame::~BaseGame() { //SAFE_DELETE(_keyboardState); delete _renderer; - delete _fileManager; - delete _registry; delete _stringTable; _localSaveDir = NULL; @@ -327,8 +324,6 @@ BaseGame::~BaseGame() { _debugMgr = NULL; _renderer = NULL; - _fileManager = NULL; - _registry = NULL; _stringTable = NULL; DEBUG_DebugDisable(); @@ -429,11 +424,6 @@ bool BaseGame::initialize1() { break; } - _fileManager = new BaseFileManager(this); - if (_fileManager == NULL) { - break; - } - _soundMgr = new BaseSoundMgr(this); if (_soundMgr == NULL) { break; @@ -487,7 +477,6 @@ bool BaseGame::initialize1() { delete _surfaceStorage; delete _fontStorage; delete _soundMgr; - delete _fileManager; delete _scEngine; delete _videoPlayer; return STATUS_FAILED; @@ -701,7 +690,7 @@ void BaseGame::getOffset(int *offsetX, int *offsetY) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -809,7 +798,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { @@ -1560,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - _registry->writeInt("PrivateSettings", key, val); + BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1572,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(_registry->readInt("PrivateSettings", key, initVal)); + stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal)); return STATUS_OK; } @@ -1583,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - _registry->writeString("PrivateSettings", key, val); + BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1595,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = _registry->readString("PrivateSettings", key, initVal); + AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return STATUS_OK; } @@ -1818,7 +1807,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(1); const char *filename = stack->pop()->getString(); - bool exists = _fileManager->hasFile(filename); // Had absPathWarning = false + bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false stack->pushBool(exists); return STATUS_OK; } @@ -2190,7 +2179,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack const char *filename = stack->pop()->getString(); bool asHex = stack->pop()->getBool(false); - Common::SeekableReadStream *file = _fileManager->openFile(filename, false); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false); if (file) { crc remainder = crc_initialize(); byte buf[1024]; @@ -2214,7 +2203,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->pushInt(checksum); } - _fileManager->closeFile(file); + BaseFileManager::getEngineInstance()->closeFile(file); file = NULL; } else { stack->pushNULL(); @@ -2653,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(_registry->readInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -3342,7 +3331,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initSave(desc))) { if (!quickSave) { delete _saveLoadImage; @@ -3360,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - _registry->writeInt("System", "MostRecentSaveSlot", slot); + BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); } } } @@ -3412,7 +3401,7 @@ bool BaseGame::loadGame(const char *filename) { _loadInProgress = true; _indicatorDisplay = true; _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initLoad(filename))) { //if (DID_SUCCEED(ret = cleanup())) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { @@ -3628,7 +3617,7 @@ bool BaseGame::loadSettings(const char *filename) { TOKEN_TABLE_END - byte *origBuffer = _gameRef->_fileManager->readWholeFile(filename); + byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (origBuffer == NULL) { _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); return STATUS_FAILED; @@ -3639,7 +3628,7 @@ bool BaseGame::loadSettings(const char *filename) { byte *buffer = origBuffer; byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); @@ -3699,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - _registry->setBasePath((char *)params); + BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3723,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = _registry->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = _registry->readBool("Debug", "CompressedSavegames", _compressedSavegames); + _settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; delete[] origBuffer; @@ -4004,7 +3993,7 @@ void BaseGame::setWindowTitle() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); Common::String filename = pm->getFilenameForSlot(slot); delete pm; strcpy(buffer, filename.c_str()); @@ -4018,7 +4007,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); if (!pm) { return STATUS_FAILED; } @@ -4039,7 +4028,7 @@ bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { bool BaseGame::isSaveSlotUsed(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); bool ret = pm->getSaveExists(slot); delete pm; return ret; @@ -4050,7 +4039,7 @@ bool BaseGame::isSaveSlotUsed(int slot) { bool BaseGame::emptySaveSlot(int slot) { char filename[MAX_PATH_LENGTH + 1]; getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(this); + BasePersistenceManager *pm = new BasePersistenceManager(); g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return STATUS_OK; @@ -4724,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - _registry->saveValues(); + BaseEngine::getInstance()->getRegistry()->saveValues(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 9adca0743c..40c9e254c4 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -135,7 +135,6 @@ public: bool initialize1(); bool initialize2(); bool initialize3(); - BaseFileManager *_fileManager; BaseTransitionMgr *_transMgr; BaseDebugger *getDebugMgr(); @@ -205,7 +204,6 @@ public: bool loadSettings(const char *filename); bool displayWindows(bool inGame = false); - BaseRegistry *_registry; bool _useD3D; virtual bool cleanup(); virtual bool loadGame(int slot); diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 3bd4f0441f..5dba8f9317 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" #include "common/util.h" @@ -42,7 +43,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser(BaseGame *inGame) : BaseClass(inGame) { +BaseParser::BaseParser() { _whiteSpace = new char [strlen(WHITESPACE) + 1]; strcpy(_whiteSpace, WHITESPACE); } @@ -122,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } - _gameRef->miniUpdate(); + BaseEngine::getInstance()->getGameRef()->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 03ca71b48d..3b1979efa1 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -52,12 +52,11 @@ #define PARSERR_EOF -2 #define PARSERR_TOKENNOTFOUND -1 -#include "engines/wintermute/base/base.h" #include "engines/wintermute/coll_templ.h" namespace WinterMute { -class BaseParser : public BaseClass { +class BaseParser { public: struct TokenDesc { int32 id; @@ -67,7 +66,7 @@ public: public: int scanStr(const char *in, const char *format, ...); int32 getCommand(char **buf, TokenDesc *tokens, char **params); - BaseParser(BaseGame *inGame = NULL); + BaseParser(); virtual ~BaseParser(); private: char *getLastOffender(); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index ce7c66b7dd..2d30395928 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/dcgf.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/platform_osystem.h" @@ -52,14 +53,18 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(BaseGame *inGame, const char *savePrefix) { +BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { _saving = false; // _buffer = NULL; // _bufferSize = 0; _offset = 0; _saveStream = NULL; _loadStream = NULL; - _gameRef = inGame; + if (BaseEngine::getInstance()) { + _gameRef = BaseEngine::getInstance()->getGameRef(); + } else { + _gameRef = NULL; + } _richBuffer = NULL; _richBufferSize = 0; @@ -263,7 +268,7 @@ bool BasePersistenceManager::readHeader(const Common::String &filename) { _saving = false; _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = _gameRef->_fileManager->readWholeFile(filename, &_bufferSize); + //_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize); if (_loadStream) { uint32 magic; magic = getDWORD(); diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index cdb29fde6b..30fac6e191 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -87,7 +87,7 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - BasePersistenceManager(BaseGame *inGame = NULL, const char *savePrefix = NULL); + BasePersistenceManager(const char *savePrefix = NULL); virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 7335d904c7..82dc359eb0 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -102,7 +102,7 @@ bool BaseRegion::pointInRegion(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::loadFile(const char *filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -150,7 +150,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index afaa01f06d..495f68b486 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -27,7 +27,7 @@ */ #include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" @@ -40,7 +40,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry(BaseGame *inGame) : BaseClass(inGame) { +BaseRegistry::BaseRegistry() { _iniName = NULL; setIniName("./wme.ini"); @@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - Common::String filename = Common::String(_gameRef->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; saveXml(filename, _values); } diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h index 1d67c18e85..5e235c2a68 100644 --- a/engines/wintermute/base/base_registry.h +++ b/engines/wintermute/base/base_registry.h @@ -29,11 +29,14 @@ #ifndef WINTERMUTE_BREGISTRY_H #define WINTERMUTE_BREGISTRY_H -#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" +#include "common/hashmap.h" +#include "common/hash-str.h" +#include "common/str.h" namespace WinterMute { -class BaseRegistry : public BaseClass { +class BaseRegistry { public: void setIniName(const char *name); char *getIniName(); @@ -43,7 +46,7 @@ public: int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - BaseRegistry(BaseGame *inGame); + BaseRegistry(); virtual ~BaseRegistry(); void setBasePath(const char *basePath); diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 8b71c73818..0d580e8db3 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -66,7 +66,7 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { // normal thumbnail if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(_gameRef->_fileManager); + _thumbnail = new BaseImage(); _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); } diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 51d1b32814..614ee7c7b8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -380,7 +380,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (complete) { if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6ab8e60a17..bc2167c618 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -125,7 +125,7 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa ////////////////////////////////////////////////////////////////////// bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(filename); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); if (!file) { _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); if (_gameRef->_debugDebugMode) { @@ -134,7 +134,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC return loadFile("invalid.bmp", lifeTime, cacheType); } } else { - _gameRef->_fileManager->closeFile(file); + BaseFileManager::getEngineInstance()->closeFile(file); file = NULL; } @@ -158,7 +158,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC ret = STATUS_OK; } } else { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); @@ -213,7 +213,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa byte *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; cleanup(); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8dc9e25e4b..8fa69e5288 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -193,7 +193,7 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { } uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); if (buffer == NULL) { _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); return STATUS_FAILED; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 6ce8c78b3b..333e2f4f9c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -110,7 +110,7 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; Rect32 rect; int r = 255, g = 255, b = 255; int ar = 255, ag = 255, ab = 255, alpha = 255; diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 7d6f499012..e3c3692892 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -108,7 +108,7 @@ BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool } } - if (!_gameRef->_fileManager->hasFile(filename)) { + if (!BaseFileManager::getEngineInstance()->hasFile(filename)) { if (filename.size()) { _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); } diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 11d095e70b..185a21ad57 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -37,7 +37,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile(BaseGame *inGame) : BaseClass(inGame) { +BaseFile::BaseFile() { _pos = 0; _size = 0; } diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 1a144414fc..0c1ab2a045 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -40,7 +40,7 @@ class SeekableReadStream; namespace WinterMute { -class BaseFile : public BaseClass { +class BaseFile { protected: uint32 _pos; uint32 _size; @@ -56,7 +56,7 @@ public: virtual bool close() = 0; virtual bool open(const Common::String &filename) = 0; virtual bool isEOF(); - BaseFile(BaseGame *inGame); + BaseFile(); virtual ~BaseFile(); // Temporary solution to allow usage in ScummVM-code: virtual Common::SeekableReadStream *getMemStream(); diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index a285a93923..1f7288a6ff 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -26,7 +26,7 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" @@ -38,7 +38,7 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile(BaseGame *inGame) : BaseFile(inGame) { +BaseSaveThumbFile::BaseSaveThumbFile() { _data = NULL; } @@ -70,7 +70,7 @@ bool BaseSaveThumbFile::open(const Common::String &filename) { int slot = atoi(tempFilename); delete[] tempFilename; - BasePersistenceManager *pm = new BasePersistenceManager(_gameRef); + BasePersistenceManager *pm = new BasePersistenceManager(); Common::String slotFilename = pm->getFilenameForSlot(slot); if (!pm) { return STATUS_FAILED; diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 6065f10f81..d95958d95f 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -37,7 +37,7 @@ namespace WinterMute { //TODO: Get rid of this class BaseSaveThumbFile : public BaseFile { public: - BaseSaveThumbFile(BaseGame *Game); + BaseSaveThumbFile(); virtual ~BaseSaveThumbFile(); virtual bool seek(uint32 pos, int whence = SEEK_SET); virtual bool read(void *buffer, uint32 size); diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 4a5cd31002..fa9242366e 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -31,7 +31,6 @@ #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_game.h" namespace WinterMute { @@ -72,7 +71,7 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// bool BaseFont::loadFile(const char * Filename) { - BYTE* Buffer = _gameRef->_fileManager->readWholeFile(filename); + BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (Buffer==NULL){ _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); return STATUS_FAILED; @@ -103,7 +102,7 @@ bool BaseFont::loadBuffer(byte * Buffer) char* params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ _gameRef->LOG(0, "'FONT' keyword expected."); @@ -186,7 +185,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { TOKEN_TABLE_END - byte *buffer = gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { return false; } @@ -194,7 +193,7 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { byte *workBuffer = buffer; char *params; - BaseParser parser(gameRef); + BaseParser parser; bool ret = false; if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index e7bf362b32..6585d7cb0a 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -271,7 +271,7 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { ////////////////////////////////////////////////////////////////////// bool BaseFontBitmap::loadFile(const Common::String &filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -332,7 +332,7 @@ bool BaseFontBitmap::loadBuffer(byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { _gameRef->LOG(0, "'FONT' keyword expected."); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 793c044839..a141c68db7 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -293,7 +293,7 @@ int BaseFontTT::getLetterHeight() { ////////////////////////////////////////////////////////////////////// bool BaseFontTT::loadFile(const Common::String &filename) { - byte *buffer = _gameRef->_fileManager->readWholeFile(filename); + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); if (buffer == NULL) { _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); return STATUS_FAILED; @@ -348,7 +348,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { _gameRef->LOG(0, "'TTFONT' keyword expected."); @@ -451,7 +451,7 @@ bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { char *params; int cmd; - BaseParser parser(_gameRef); + BaseParser parser; while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { switch (cmd) { @@ -538,13 +538,13 @@ bool BaseFontTT::initFont() { return STATUS_FAILED; } - Common::SeekableReadStream *file = _gameRef->_fileManager->openFile(_fontFile); + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile); if (!file) { //TODO: Try to fallback from Arial to FreeSans /* // the requested font file is not in wme file space; try loading a system font AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = _gameRef->_fileManager->openFile(fontFileName.c_str(), false); + file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false); if (!file) { _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); //return STATUS_FAILED; diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 1fff59d85b..2167503dc8 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -42,8 +42,8 @@ namespace WinterMute { ////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage(BaseFileManager *fileManager) { - _fileManager = fileManager; +BaseImage::BaseImage() { + _fileManager = BaseFileManager::getEngineInstance(); _palette = NULL; _surface = NULL; _decoder = NULL; diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index ed0142ea95..76a389977d 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -42,7 +42,7 @@ class BaseFileManager; class BaseImage { public: - BaseImage(BaseFileManager *fileManager); + BaseImage(); ~BaseImage(); bool loadFile(const Common::String &filename); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 58839d5ffe..51b0c2dd36 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -126,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = _gameRef->_registry->readInt("Debug", "ForceResWidth", _width); - _realHeight = _gameRef->_registry->readInt("Debug", "ForceResHeight", _height); + _realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width); + _realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; @@ -152,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = _gameRef->_registry->readBool("Video", "Windowed", true); TODO + //_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); @@ -496,7 +497,7 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Clip by viewport. warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); - BaseImage *screenshot = new BaseImage(_gameRef->_fileManager); + BaseImage *screenshot = new BaseImage(); screenshot->copyFrom(_renderSurface); return screenshot; } diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 642f2179e6..c449f6471c 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -119,7 +119,7 @@ bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, } bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(_gameRef->_fileManager); + BaseImage *image = new BaseImage(); if (!image->loadFile(_filename)) { return false; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 7389885f5a..ced01b7fd9 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -128,12 +128,12 @@ bool PartEmitter::addSprite(const char *filename) { } // check if file exists - Common::SeekableReadStream *File = _gameRef->_fileManager->openFile(filename); + Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); if (!File) { _gameRef->LOG(0, "Sprite '%s' not found", filename); return STATUS_FAILED; } else { - _gameRef->_fileManager->closeFile(File); + BaseFileManager::getEngineInstance()->closeFile(File); } char *str = new char[strlen(filename) + 1]; diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 2b05edd61f..1a449a50a5 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/particles/part_particle.h" #include "engines/wintermute/base/particles/part_emitter.h" #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_game.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" @@ -80,7 +79,7 @@ bool PartParticle::setSprite(const Common::String &filename) { _sprite = NULL; SystemClassRegistry::getInstance()->_disabled = true; - _sprite = new BaseSprite(_gameRef, _gameRef); + _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { SystemClassRegistry::getInstance()->_disabled = false; return STATUS_OK; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 01f647c110..9e11a7c5b4 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -33,6 +33,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_ext_math.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_file_manager.h" @@ -128,7 +129,7 @@ bool ScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { BaseGame *gameRef = (BaseGame *)data; - return gameRef->_fileManager->readWholeFile(filename, size); + return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); } @@ -200,7 +201,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig uint32 size; - byte *buffer = _gameRef->_fileManager->readWholeFile(filename, &size); + byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size); if (!buffer) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; @@ -689,10 +690,10 @@ bool ScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - _gameRef->_registry->writeString("Debug", key, text); + BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text); } } - _gameRef->_registry->writeInt("Debug", "NumBreakpoints", count); + BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count); return STATUS_OK; } @@ -705,11 +706,11 @@ bool ScEngine::loadBreakpoints() { char key[100]; - int count = _gameRef->_registry->readInt("Debug", "NumBreakpoints", 0); + int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = _gameRef->_registry->readString("Debug", key, ""); + AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, ""); char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 5743722d6f..50d89921e1 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -82,7 +82,7 @@ void SXFile::cleanup() { ////////////////////////////////////////////////////////////////////////// void SXFile::close() { if (_readFile) { - _gameRef->_fileManager->closeFile(_readFile); + BaseFileManager::getEngineInstance()->closeFile(_readFile); _readFile = NULL; } if (_writeFile) { @@ -130,7 +130,7 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, _mode = 1; } if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); if (!_readFile) { //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); close(); @@ -785,7 +785,7 @@ bool SXFile::persist(BasePersistenceManager *persistMgr) { if (_mode != 0) { // open for reading if (_mode == 1) { - _readFile = _gameRef->_fileManager->openFile(_filename); + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); if (!_readFile) { close(); } diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 5f36eb96d4..ac329704bc 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -96,7 +96,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. - _file = _gameRef->_fileManager->openFile(filename, true, false); + _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); if (!_file) { _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); return STATUS_FAILED; diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 8df9f299ef..61c7376c79 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_registry.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_game.h" @@ -71,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - _gameRef->_registry->writeInt("Audio", "MasterVolume", _volumeMaster); + BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); } } @@ -82,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = _gameRef->_registry->readInt("Audio", "MasterVolume", 255); + _volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; return STATUS_OK; @@ -104,7 +105,7 @@ BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::M AnsiString name = PathUtil::getFileNameWithoutExtension(filename); AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (_gameRef->_fileManager->hasFile(newFile)) { + if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { useFilename = newFile; } } -- cgit v1.2.3 From 482a5fb467e6694fb54c75f718563992657edf97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 02:59:14 +0200 Subject: WINTERMUTE: Make the BaseEngine-singleton use Common::Singleton as super-class --- engines/wintermute/base/base_engine.cpp | 47 ++++++---------------- engines/wintermute/base/base_engine.h | 9 ++--- engines/wintermute/base/base_file_manager.cpp | 15 ++++--- engines/wintermute/base/base_game.cpp | 22 +++++----- engines/wintermute/base/base_parser.cpp | 2 +- .../wintermute/base/base_persistence_manager.cpp | 9 +++-- engines/wintermute/base/base_persistence_manager.h | 3 +- engines/wintermute/base/base_registry.cpp | 4 +- .../base/gfx/osystem/base_render_osystem.cpp | 6 +-- .../wintermute/base/scriptables/script_engine.cpp | 11 +++-- .../wintermute/base/sound/base_sound_manager.cpp | 4 +- 11 files changed, 54 insertions(+), 78 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index cd6e9c9e3b..0185d973fa 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -32,24 +32,17 @@ #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" +namespace Common { +DECLARE_SINGLETON(WinterMute::BaseEngine); +} namespace WinterMute { -BaseEngine *BaseEngine::_instance = 0; - /* -class BaseEngine { - static BaseEngine *_instance; - BaseEngine(); - BaseFileManager *_fileManager; - BaseRegistry *_registry; -public: - ~BaseEngine(); - BaseEngine *getInstance(); - BaseFileManager *getFileMan() { return _fileManager; } - BaseRegistry *getRegistry() { return _registry; } -};*/ BaseEngine::BaseEngine() { - + _fileManager = NULL; + _registry = NULL; + _gameRef = NULL; + _gameId = ""; } void BaseEngine::init() { @@ -63,25 +56,9 @@ BaseEngine::~BaseEngine() { delete _registry; } -BaseEngine *BaseEngine::getInstance() { - if (!_instance) - assert(0); - return _instance; -} - void BaseEngine::createInstance(const Common::String &gameid) { - if (_instance) { - delete _instance; - _instance = NULL; - } - _instance = new BaseEngine(); - _instance->_gameId = gameid; - _instance->init(); -} - -void BaseEngine::destroyInstance() { - delete _instance; - _instance = NULL; + instance()._gameId = gameid; + instance().init(); } void BaseEngine::LOG(bool res, const char *fmt, ...) { @@ -98,11 +75,11 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { vsprintf(buff, fmt, va); va_end(va); - if (_instance && _instance->_gameRef) { - _instance->_gameRef->LOG("%s", buff); + if (instance()._gameRef) { + instance()._gameRef->LOG("%s", buff); } else { debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); } } -} // end of namespace WinterMute \ No newline at end of file +} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 5782c012d8..d45d979f25 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -27,26 +27,23 @@ */ #include "common/str.h" + #include "common/singleton.h" namespace WinterMute { class BaseFileManager; class BaseRegistry; class BaseGame; -class BaseEngine { - static BaseEngine *_instance; - BaseEngine(); +class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; BaseRegistry *_registry; Common::String _gameId; BaseGame *_gameRef; public: + BaseEngine(); ~BaseEngine(); static void createInstance(const Common::String &gameid); - static BaseEngine *getInstance(); - static void destroyInstance(); - void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } BaseGame *getGameRef() { return _gameRef; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 83047ca75c..801729c5e8 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -147,15 +147,14 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - BaseEngine *enginePtr = BaseEngine::getInstance(); - if (!enginePtr) { // This function only works when the game-registry is loaded + if (!BaseEngine::instance().getRegistry()) { // This function only works when the game-registry is loaded return STATUS_FAILED; } AnsiString pathList; // single files paths - pathList = enginePtr->getRegistry()->readString("Resource", "CustomPaths", ""); + pathList = BaseEngine::instance().getRegistry()->readString("Resource", "CustomPaths", ""); Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); // numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); while (!entries->empty()) { @@ -172,7 +171,7 @@ bool BaseFileManager::initPaths() { const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = enginePtr->getRegistry()->readString("Resource", "PackagePaths", ""); + pathList = BaseEngine::instance().getRegistry()->readString("Resource", "PackagePaths", ""); entries = new Common::StringTokenizer(pathList, ";"); while (!entries->empty()) { Common::String path = entries->nextToken(); @@ -271,7 +270,7 @@ Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &f bool BaseFileManager::hasFile(const Common::String &filename) { if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(BaseEngine::getInstance()->getGameId()); + BasePersistenceManager pm(BaseEngine::instance().getGameId()); if (filename.size() <= 9) { return false; } @@ -323,7 +322,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f Common::SeekableReadStream *ret = NULL; if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!BaseEngine::getInstance()) { + if (!BaseEngine::instance().getGameRef()) { error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); } BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); @@ -354,8 +353,8 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f } BaseFileManager *BaseFileManager::getEngineInstance() { - if (BaseEngine::getInstance()) { - return BaseEngine::getInstance()->getFileManager(); + if (BaseEngine::instance().getFileManager()) { + return BaseEngine::instance().getFileManager(); } return NULL; } diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 687e394920..6fea190e01 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -279,7 +279,7 @@ BaseGame::~BaseGame() { getDebugMgr()->onGameShutdown(); - BaseEngine::getInstance()->getRegistry()->writeBool("System", "LastRun", true); + BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -1549,7 +1549,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - BaseEngine::getInstance()->getRegistry()->writeInt("PrivateSettings", key, val); + BaseEngine::instance().getRegistry()->writeInt("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1561,7 +1561,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(BaseEngine::getInstance()->getRegistry()->readInt("PrivateSettings", key, initVal)); + stack->pushInt(BaseEngine::instance().getRegistry()->readInt("PrivateSettings", key, initVal)); return STATUS_OK; } @@ -1572,7 +1572,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - BaseEngine::getInstance()->getRegistry()->writeString("PrivateSettings", key, val); + BaseEngine::instance().getRegistry()->writeString("PrivateSettings", key, val); stack->pushNULL(); return STATUS_OK; } @@ -1584,7 +1584,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = BaseEngine::getInstance()->getRegistry()->readString("PrivateSettings", key, initVal); + AnsiString val = BaseEngine::instance().getRegistry()->readString("PrivateSettings", key, initVal); stack->pushString(val.c_str()); return STATUS_OK; } @@ -2642,7 +2642,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(BaseEngine::getInstance()->getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); + _scValue->setInt(BaseEngine::instance().getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); return _scValue; } @@ -3349,7 +3349,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - BaseEngine::getInstance()->getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); + BaseEngine::instance().getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); } } } @@ -3688,7 +3688,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - BaseEngine::getInstance()->getRegistry()->setBasePath((char *)params); + BaseEngine::instance().getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3712,8 +3712,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = BaseEngine::getInstance()->getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); + _settingsAllowWindowed = BaseEngine::instance().getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); + _compressedSavegames = BaseEngine::instance().getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); //_compressedSavegames = false; delete[] origBuffer; @@ -4713,7 +4713,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - BaseEngine::getInstance()->getRegistry()->saveValues(); + BaseEngine::instance().getRegistry()->saveValues(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 5dba8f9317..5d5a2d534d 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -123,7 +123,7 @@ int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } - BaseEngine::getInstance()->getGameRef()->miniUpdate(); + BaseEngine::instance().getGameRef()->miniUpdate(); char *name; return getObject(buf, tokens, &name, params); } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 2d30395928..ddc5e15d92 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -53,15 +53,16 @@ namespace WinterMute { #define SAVE_MAGIC_2 0x32564153 ////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { +BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { _saving = false; // _buffer = NULL; // _bufferSize = 0; _offset = 0; _saveStream = NULL; _loadStream = NULL; - if (BaseEngine::getInstance()) { - _gameRef = BaseEngine::getInstance()->getGameRef(); + _deleteSingleton = deleteSingleton; + if (BaseEngine::instance().getGameRef()) { + _gameRef = BaseEngine::instance().getGameRef(); } else { _gameRef = NULL; } @@ -89,6 +90,8 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix) { ////////////////////////////////////////////////////////////////////////// BasePersistenceManager::~BasePersistenceManager() { cleanup(); + if (_deleteSingleton) + BaseEngine::destroy(); } diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 30fac6e191..87892b42f3 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -87,7 +87,7 @@ public: bool transfer(const char *name, Common::String *val); bool transfer(const char *name, Vector2 *val); bool transfer(const char *name, AnsiStringArray &Val); - BasePersistenceManager(const char *savePrefix = NULL); + BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); virtual ~BasePersistenceManager(); bool checkVersion(byte verMajor, byte verMinor, byte verBuild); @@ -95,6 +95,7 @@ public: byte *_thumbnailData; Common::String getFilenameForSlot(int slot) const; private: + bool _deleteSingleton; bool readHeader(const Common::String &filename); TimeDate getTimeDate(); bool putTimeDate(const TimeDate &t); diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp index 495f68b486..d03691ea42 100644 --- a/engines/wintermute/base/base_registry.cpp +++ b/engines/wintermute/base/base_registry.cpp @@ -175,13 +175,13 @@ char *BaseRegistry::getIniName() { ////////////////////////////////////////////////////////////////////////// void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; loadXml(filename, _values); } ////////////////////////////////////////////////////////////////////////// void BaseRegistry::saveValues() { - Common::String filename = Common::String(BaseEngine::getInstance()->getGameId()) + "-settings.xml"; + Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; saveXml(filename, _values); } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 51b0c2dd36..6e18aaba29 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -127,8 +127,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResWidth", _width); - _realHeight = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "ForceResHeight", _height); + _realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); + _realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; @@ -153,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = BaseEngine::getInstance()->getRegistry()->readBool("Video", "Windowed", true); TODO + //_windowed = BaseEngine::instance().getRegistry()->readBool("Video", "Windowed", true); TODO Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 9e11a7c5b4..96250dbb90 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -128,7 +128,6 @@ bool ScEngine::cleanup() { ////////////////////////////////////////////////////////////////////////// byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { - BaseGame *gameRef = (BaseGame *)data; return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); } @@ -201,7 +200,7 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig uint32 size; - byte *buffer = BaseEngine::getInstance()->getFileManager()->readWholeFile(filename, &size); + byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); if (!buffer) { _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); return NULL; @@ -690,10 +689,10 @@ bool ScEngine::saveBreakpoints() { sprintf(key, "Breakpoint%d", count); sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - BaseEngine::getInstance()->getRegistry()->writeString("Debug", key, text); + BaseEngine::instance().getRegistry()->writeString("Debug", key, text); } } - BaseEngine::getInstance()->getRegistry()->writeInt("Debug", "NumBreakpoints", count); + BaseEngine::instance().getRegistry()->writeInt("Debug", "NumBreakpoints", count); return STATUS_OK; } @@ -706,11 +705,11 @@ bool ScEngine::loadBreakpoints() { char key[100]; - int count = BaseEngine::getInstance()->getRegistry()->readInt("Debug", "NumBreakpoints", 0); + int count = BaseEngine::instance().getRegistry()->readInt("Debug", "NumBreakpoints", 0); for (int i = 1; i <= count; i++) { /* uint32 bufSize = 512; */ sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = BaseEngine::getInstance()->getRegistry()->readString("Debug", key, ""); + AnsiString breakpoint = BaseEngine::instance().getRegistry()->readString("Debug", key, ""); char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 61c7376c79..03f6fffb58 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -72,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - BaseEngine::getInstance()->getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); + BaseEngine::instance().getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); } } @@ -83,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = BaseEngine::getInstance()->getRegistry()->readInt("Audio", "MasterVolume", 255); + _volumeMaster = BaseEngine::instance().getRegistry()->readInt("Audio", "MasterVolume", 255); _soundAvailable = true; return STATUS_OK; -- cgit v1.2.3 From 3a218180017e97e4b9dceca3bf25a232f271c6b9 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 03:41:45 +0200 Subject: WINTERMUTE: Make BaseSubFrame load lazily. --- engines/wintermute/base/base_frame.cpp | 2 +- engines/wintermute/base/base_sprite.cpp | 2 +- engines/wintermute/base/base_sub_frame.cpp | 43 ++++++++++++++++++++------- engines/wintermute/base/base_sub_frame.h | 8 ++++- engines/wintermute/base/gfx/base_renderer.cpp | 8 ++--- 5 files changed, 45 insertions(+), 18 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 87213b1421..5473419f22 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -321,7 +321,7 @@ bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (BasePlatform::isRectEmpty(&rect)) { sub->setDefaultRect(); } else { - sub->_rect = rect; + sub->setRect(rect); } sub->_hotspotX = hotspotX; diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index bc2167c618..bc42f81dd4 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -151,7 +151,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC delete frame; delete subframe; } else { - BasePlatform::setRect(&subframe->_rect, 0, 0, subframe->_surface->getWidth(), subframe->_surface->getHeight()); + subframe->setDefaultRect(); frame->_subframes.add(subframe); _frames.add(frame); _currentFrame = 0; diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 333e2f4f9c..006f15fa2c 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -48,6 +48,7 @@ BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { _alpha = 0xFFFFFFFF; _transparent = 0xFFFF00FF; + _wantsDefaultRect = false; BasePlatform::setRectEmpty(&_rect); _editorSelected = false; @@ -205,12 +206,25 @@ bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { if (BasePlatform::isRectEmpty(&rect)) { setDefaultRect(); } else { - _rect = rect; + setRect(rect); } return STATUS_OK; } +Rect32 BaseSubFrame::getRect() { + if (_wantsDefaultRect && _surface) { + BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _wantsDefaultRect = false; + } + return _rect; +} + +void BaseSubFrame::setRect(Rect32 rect) { + _wantsDefaultRect = false; + _rect = rect; +} + ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { @@ -220,9 +234,9 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl if (registerOwner != NULL && !_decoration) { if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + _rect.left, y - _hotspotY + _rect.top, _rect.right - _rect.left, _rect.bottom - _rect.top, zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise)); } else { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + _rect.left) * (zoomX / 100)), (int)(y - (_hotspotY + _rect.top) * (zoomY / 100)), (int)((_rect.right - _rect.left) * (zoomX / 100)), (int)((_rect.bottom - _rect.top) * (zoomY / 100)), zoomX, zoomY, precise)); + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise)); } } if (_gameRef->_suspendedRendering) { @@ -237,12 +251,12 @@ bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, fl } if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, _rect, zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); } else { if (zoomX == 100 && zoomY == 100) { - res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, _rect, alpha, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY); } else { - res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _rect, zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); } } @@ -262,8 +276,8 @@ bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, flo BasePlatform::setRect(rect, (int)(x - _hotspotX * ratioX), (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (_rect.right - _rect.left) * ratioX), - (int)(y - _hotspotY * ratioY + (_rect.bottom - _rect.top) * ratioY)); + (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), + (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); return true; } @@ -287,8 +301,8 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple if (_surface) { BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); } - if (!(rect == _rect)) { - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", _rect.left, _rect.top, _rect.right, _rect.bottom); + if (!(rect == getRect())) { + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", getRect().left, getRect().top, getRect().right, getRect().bottom); } if (_hotspotX != 0 || _hotspotY != 0) { @@ -338,8 +352,9 @@ bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool comple ////////////////////////////////////////////////////////////////////////// void BaseSubFrame::setDefaultRect() { if (_surface) { - BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _wantsDefaultRect = true; } else { + _wantsDefaultRect = false; BasePlatform::setRectEmpty(&_rect); } } @@ -350,6 +365,12 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); + if (persistMgr->getIsSaving()) { + getRect(); // To make sure it gets updated if it was never loaded. + } else { + _wantsDefaultRect = false; + } + persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); persistMgr->transfer(TMEMBER(_alpha)); diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 023e306706..d8027d3ce9 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -58,8 +58,14 @@ public: int _hotspotX; int _hotspotY; uint32 _alpha; + // These two setters and getters are rather usefull, as they allow _rect to be lazily defined + // Thus we don't need to load the actual graphics before the rect is actually needed. + Rect32 getRect(); + void setRect(Rect32 rect); +private: + bool _wantsDefaultRect; Rect32 _rect; - +public: bool _cKDefault; byte _cKRed; byte _cKGreen; diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index ab5111332e..cc6167a749 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -76,16 +76,16 @@ BaseObject *BaseRenderer::getObjectAt(int x, int y) { if (_rectList[i]->_precise) { // frame if (_rectList[i]->_frame) { - int xx = (int)((_rectList[i]->_frame->_rect.left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int yy = (int)((_rectList[i]->_frame->_rect.top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + int xx = (int)((_rectList[i]->_frame->getRect().left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->getRect().top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); if (_rectList[i]->_frame->_mirrorX) { - int width = _rectList[i]->_frame->_rect.right - _rectList[i]->_frame->_rect.left; + int width = _rectList[i]->_frame->getRect().right - _rectList[i]->_frame->getRect().left; xx = width - xx; } if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->_rect.bottom - _rectList[i]->_frame->_rect.top; + int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().top; yy = height - yy; } -- cgit v1.2.3 From 1f5288d8c17bb65d623e96ab66833ba548c26e70 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 15:03:54 +0200 Subject: WINTERMUTE: Use ConfMan instead of registry. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 3 ++- engines/wintermute/base/sound/base_sound_manager.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 6e18aaba29..8e6c6bb83c 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -38,6 +38,7 @@ #include "common/system.h" #include "engines/wintermute/graphics/transparent_surface.h" #include "common/queue.h" +#include "common/config-manager.h" namespace WinterMute { @@ -153,7 +154,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - //_windowed = BaseEngine::instance().getRegistry()->readBool("Video", "Windowed", true); TODO + _windowed = !ConfMan.getBool("fullscreen"); Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); g_system->beginGFXTransaction(); diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 03f6fffb58..43109443a7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -72,7 +72,7 @@ bool BaseSoundMgr::cleanup() { ////////////////////////////////////////////////////////////////////////// void BaseSoundMgr::saveSettings() { if (_soundAvailable) { - BaseEngine::instance().getRegistry()->writeInt("Audio", "MasterVolume", _volumeMaster); + ConfMan.setInt("master_volume", _volumeMaster); } } @@ -83,7 +83,7 @@ bool BaseSoundMgr::initialize() { if (!g_system->getMixer()->isReady()) { return STATUS_FAILED; } - _volumeMaster = BaseEngine::instance().getRegistry()->readInt("Audio", "MasterVolume", 255); + _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); _soundAvailable = true; return STATUS_OK; -- cgit v1.2.3 From aa3467ddaa4b1df72398a1545c9d8b1c89dad6ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 15:30:44 +0200 Subject: WINTERMUTE: Remove the debugger. --- engines/wintermute/base/base_debugger.cpp | 203 --------------------- engines/wintermute/base/base_debugger.h | 95 ---------- engines/wintermute/base/base_game.cpp | 34 ---- engines/wintermute/base/base_game.h | 3 - engines/wintermute/base/base_script_holder.cpp | 3 - engines/wintermute/base/base_scriptable.cpp | 13 -- engines/wintermute/base/base_scriptable.h | 9 +- engines/wintermute/base/scriptables/script.cpp | 115 ------------ engines/wintermute/base/scriptables/script.h | 13 +- .../wintermute/base/scriptables/script_engine.cpp | 181 +----------------- .../wintermute/base/scriptables/script_engine.h | 14 -- .../wintermute/base/scriptables/script_value.cpp | 136 -------------- engines/wintermute/base/scriptables/script_value.h | 30 +-- 13 files changed, 4 insertions(+), 845 deletions(-) delete mode 100644 engines/wintermute/base/base_debugger.cpp delete mode 100644 engines/wintermute/base/base_debugger.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_debugger.cpp b/engines/wintermute/base/base_debugger.cpp deleted file mode 100644 index ef4f1ce686..0000000000 --- a/engines/wintermute/base/base_debugger.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_debugger.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -BaseDebugger::BaseDebugger(BaseGame *inGame) : BaseClass(inGame) { - _enabled = false; -} - -////////////////////////////////////////////////////////////////////////// -BaseDebugger::~BaseDebugger(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::initialize() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::shutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameInit() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameShutdown() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onGameTick() { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onLog(unsigned int errorCode, const char *text) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptInit(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptShutdown(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptChangeLine(ScScript *script, int Line) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptChangeScope(ScScript *script, ScValue *scope) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptShutdownScope(ScScript *script, ScValue *scope) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onVariableChangeValue(ScValue *var, ScValue *value) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::onScriptHitBreakpoint(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugServer interface implementation -bool BaseDebugger::attachClient(IWmeDebugClient *client) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::detachClient(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::queryData(IWmeDebugClient *client) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseDebugger::getPropInt(const char *propName) { - return 0; -} - -////////////////////////////////////////////////////////////////////////// -double BaseDebugger::getPropFloat(const char *propName) { - return 0.0; -} - -////////////////////////////////////////////////////////////////////////// -const char *BaseDebugger::getPropString(const char *propName) { - return ""; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::getPropBool(const char *propName) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, int propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, double propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, const char *propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::setProp(const char *propName, bool propValue) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::addBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::removeBreakpoint(const char *scriptFilename, int line) { - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseDebugger::continueExecution() { - return false; -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_debugger.h b/engines/wintermute/base/base_debugger.h deleted file mode 100644 index 7266e073d8..0000000000 --- a/engines/wintermute/base/base_debugger.h +++ /dev/null @@ -1,95 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BDEBUGGER_H -#define WINTERMUTE_BDEBUGGER_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/wme_debugger.h" - -// TODO: The entire debugger should possibly be removed - -namespace WinterMute { -class ScScript; -class ScValue; -class BaseDebugger : public BaseClass, public IWmeDebugServer { -public: - BaseDebugger(BaseGame *inGame); - virtual ~BaseDebugger(void); - - // initialization - bool _enabled; - bool initialize(); - bool shutdown(); - - // internal interface - bool onGameInit(); - bool onGameShutdown(); - bool onGameTick(); - bool onLog(unsigned int errorCode, const char *text); - bool onScriptInit(ScScript *script); - bool onScriptEventThreadInit(ScScript *script, ScScript *parentScript, const char *name); - bool onScriptMethodThreadInit(ScScript *script, ScScript *parentScript, const char *name); - - bool onScriptShutdown(ScScript *script); - bool onScriptChangeLine(ScScript *script, int line); - bool onScriptChangeScope(ScScript *script, ScValue *scope); - bool onScriptShutdownScope(ScScript *script, ScValue *scope); - bool onVariableInit(EWmeDebuggerVariableType type, ScScript *script, ScValue *scope, ScValue *var, const char *variableName); - bool onVariableChangeValue(ScValue *var, ScValue *value); - - bool onScriptHitBreakpoint(ScScript *script); - - // IWmeDebugServer interface - virtual bool attachClient(IWmeDebugClient *client); - virtual bool detachClient(IWmeDebugClient *client); - virtual bool queryData(IWmeDebugClient *client); - - virtual int getPropInt(const char *propName); - virtual double getPropFloat(const char *propName); - virtual const char *getPropString(const char *propName); - virtual bool getPropBool(const char *propName); - - virtual bool setProp(const char *propName, int propValue); - virtual bool setProp(const char *propName, double propValue); - virtual bool setProp(const char *propName, const char *propValue); - virtual bool setProp(const char *propName, bool propValue); - - virtual bool resolveFilename(const char *relativeFilename, char *absFilenameBuf, int absBufSize); - - virtual bool addBreakpoint(const char *scriptFilename, int line); - virtual bool removeBreakpoint(const char *scriptFilename, int line); - - virtual bool continueExecution(); -private: -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 6fea190e01..062f92ccae 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -96,7 +96,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _renderer = NULL; _soundMgr = NULL; _transMgr = NULL; - _debugMgr = NULL; _scEngine = NULL; _keyboardState = NULL; @@ -277,8 +276,6 @@ BaseGame::~BaseGame() { LOG(0, ""); LOG(0, "Shutting down..."); - getDebugMgr()->onGameShutdown(); - BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); cleanup(); @@ -299,7 +296,6 @@ BaseGame::~BaseGame() { delete _videoPlayer; delete _theoraPlayer; delete _soundMgr; - delete _debugMgr; //SAFE_DELETE(_keyboardState); delete _renderer; @@ -321,7 +317,6 @@ BaseGame::~BaseGame() { _videoPlayer = NULL; _theoraPlayer = NULL; _soundMgr = NULL; - _debugMgr = NULL; _renderer = NULL; _stringTable = NULL; @@ -429,11 +424,6 @@ bool BaseGame::initialize1() { break; } - _debugMgr = new BaseDebugger(this); - if (_debugMgr == NULL) { - break; - } - _mathClass = new SXMath(this); if (_mathClass == NULL) { break; @@ -473,7 +463,6 @@ bool BaseGame::initialize1() { delete _mathClass; delete _keyboardState; delete _transMgr; - delete _debugMgr; delete _surfaceStorage; delete _fontStorage; delete _soundMgr; @@ -578,9 +567,6 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { if (_engineLogCallback) { _engineLogCallback(buff, res, _engineLogCallbackData); } - if (_debugMgr) { - _debugMgr->onLog(res, buff); - } debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); @@ -604,7 +590,6 @@ bool BaseGame::initLoop() { _currentTime = g_system->getMillis(); - getDebugMgr()->onGameTick(); _renderer->initLoop(); updateMusicCrossfade(); @@ -3234,11 +3219,6 @@ bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "Debug") == 0) { stack->correctParams(0); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(script); - script->sleep(0); - } stack->pushNULL(); } @@ -3382,7 +3362,6 @@ bool BaseGame::loadGame(int slot) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadGame(const char *filename) { LOG(0, "Loading game '%s'...", filename); - getDebugMgr()->onGameShutdown(); bool ret; @@ -3413,8 +3392,6 @@ bool BaseGame::loadGame(const char *filename) { displayContent(true, false); //_renderer->flip(); - - getDebugMgr()->onGameInit(); } } } @@ -3440,8 +3417,6 @@ bool BaseGame::initAfterLoad() { SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); - _scEngine->refreshScriptBreakpoints(); - return STATUS_OK; } @@ -4613,15 +4588,6 @@ bool BaseGame::displayDebugInfo() { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -BaseDebugger *BaseGame::getDebugMgr() { - if (!_debugMgr) { - _debugMgr = new BaseDebugger(this); - } - return _debugMgr; -} - - ////////////////////////////////////////////////////////////////////////// void BaseGame::getMousePos(Point32 *pos) { BasePlatform::getCursorPos(pos); diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 40c9e254c4..fd20608a42 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BGAME_H #define WINTERMUTE_BGAME_H -#include "engines/wintermute/base/base_debugger.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/persistent.h" @@ -136,7 +135,6 @@ public: bool initialize2(); bool initialize3(); BaseTransitionMgr *_transMgr; - BaseDebugger *getDebugMgr(); void LOG(bool res, const char *fmt, ...); @@ -354,7 +352,6 @@ private: bool isVideoPlaying(); bool stopVideo(); - BaseDebugger *_debugMgr; BaseArray _quickMessages; BaseArray _windows; BaseArray _viewportStack; diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 614ee7c7b8..19bd82f2b0 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -319,7 +319,6 @@ bool BaseScriptHolder::addScript(const char *filename) { scr->_owner = this; _scripts.add(scr); _gameRef->_scEngine->_scripts.add(scr); - _gameRef->getDebugMgr()->onScriptInit(scr); return STATUS_OK; } @@ -469,8 +468,6 @@ ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { bool ret = thread->createMethodThread(_scripts[i], methodName); if (DID_SUCCEED(ret)) { _scripts[i]->_engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptMethodThreadInit(thread, _scripts[i], methodName); - return thread; } else { delete thread; diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 743805cad7..11092427be 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -188,17 +188,4 @@ ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugObject -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptable::dbgGetNativeClass() { - return getClassName(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugProp *BaseScriptable::dbgGetProperty(const char *name) { - return scGetProperty(name); -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index b9283ed349..6227b84649 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -31,7 +31,6 @@ #include "engines/wintermute/base/base_named_object.h" -#include "engines/wintermute/wme_debugger.h" #include "engines/wintermute/persistent.h" namespace WinterMute { @@ -40,7 +39,7 @@ class ScValue; class ScStack; class ScScript; -class BaseScriptable : public BaseNamedObject, public IWmeDebugObject { +class BaseScriptable : public BaseNamedObject { public: virtual ScScript *invokeMethodThread(const char *methodName); DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) @@ -67,12 +66,6 @@ public: int _refCount; ScValue *_scValue; ScValue *_scProp; - -public: - // IWmeDebugObject - const char *dbgGetNativeClass(); - IWmeDebugProp *dbgGetProperty(const char *name); - }; // Implemented in their respective .cpp-files diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 29185edce6..fb77225700 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -152,10 +152,6 @@ bool ScScript::initScript() { _scriptStream->seek(_iP); _currentLine = 0; - // init breakpoints - _engine->refreshScriptBreakpoints(this); - - // ready to rumble... _state = SCRIPT_RUNNING; @@ -531,14 +527,8 @@ bool ScScript::executeInstruction() { dw = getDWORD(); if (_scopeStack->_sP < 0) { _globals->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCRIPT, this, NULL, _globals->getProp(_symbols[dw]), _symbols[dw]); - } } else { _scopeStack->getTop()->setProp(_symbols[dw], _operand); - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_SCOPE, this, _scopeStack->getTop(), _scopeStack->getTop()->getProp(_symbols[dw]), _symbols[dw]); - } } break; @@ -551,26 +541,14 @@ bool ScScript::executeInstruction() { if (!_engine->_globals->propExists(_symbols[dw])) { _operand->setNULL(); _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableInit(WME_DBGVAR_GLOBAL, this, NULL, _engine->_globals->getProp(_symbols[dw]), _symbols[dw]); - } } break; } case II_RET: if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _gameRef->getDebugMgr()->onScriptShutdownScope(this, _scopeStack->getTop()); - _scopeStack->pop(); _iP = (uint32)_callStack->pop()->getInt(); - - if (_scopeStack->_sP < 0) { - _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - } else { - _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } } else { if (_thread) { _state = SCRIPT_THREAD_FINISHED; @@ -695,13 +673,6 @@ bool ScScript::executeInstruction() { case II_SCOPE: _operand->setNULL(); _scopeStack->push(_operand); - - if (_scopeStack->_sP < 0) { - _gameRef->getDebugMgr()->onScriptChangeScope(this, NULL); - } else { - _gameRef->getDebugMgr()->onScriptChangeScope(this, _scopeStack->getTop()); - } - break; case II_CORRECT_STACK: @@ -754,10 +725,6 @@ bool ScScript::executeInstruction() { var->copy(val); } } - - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableChangeValue(var, val); - } } break; @@ -827,10 +794,6 @@ bool ScScript::executeInstruction() { var->setProp(str, val); } - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onVariableChangeValue(var, NULL); - } - break; } @@ -1117,21 +1080,6 @@ bool ScScript::executeInstruction() { int newLine = getDWORD(); if (newLine != _currentLine) { _currentLine = newLine; - if (_gameRef->getDebugMgr()->_enabled) { - _gameRef->getDebugMgr()->onScriptChangeLine(this, _currentLine); - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (_breakpoints[i] == _currentLine) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } - if (_tracingMode) { - _gameRef->getDebugMgr()->onScriptHitBreakpoint(this); - sleep(0); - break; - } - } } break; @@ -1371,7 +1319,6 @@ ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unb if (DID_SUCCEED(ret)) { thread->_unbreakable = unbreakable; _engine->_scripts.add(thread); - _gameRef->getDebugMgr()->onScriptEventThreadInit(thread, this, eventName.c_str()); return thread; } else { delete thread; @@ -1497,68 +1444,6 @@ const char *ScScript::dbgGetFilename() { return _filename; } - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSendScript(IWmeDebugClient *client) { - if (_methodThread) { - client->onScriptMethodThreadInit(this, _parentScript, _threadEvent); - } else if (_thread) { - client->onScriptEventThreadInit(this, _parentScript, _threadEvent); - } else { - client->onScriptInit(this); - } - - return dbgSendVariables(client); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSendVariables(IWmeDebugClient *client) { - // send script globals - _globals->dbgSendVariables(client, WME_DBGVAR_SCRIPT, this, 0); - - // send scope variables - if (_scopeStack->_sP >= 0) { - for (int i = 0; i <= _scopeStack->_sP; i++) { - // ScValue *Scope = _scopeStack->GetAt(i); - //Scope->DbgSendVariables(Client, WME_DBGVAR_SCOPE, this, (unsigned int)Scope); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -TScriptState ScScript::dbgGetState() { - return _state; -} - -////////////////////////////////////////////////////////////////////////// -int ScScript::dbgGetNumBreakpoints() { - return _breakpoints.getSize(); -} - -////////////////////////////////////////////////////////////////////////// -int ScScript::dbgGetBreakpoint(int index) { - if (index >= 0 && index < _breakpoints.getSize()) { - return _breakpoints[index]; - } else { - return -1; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgSetTracingMode(bool isTracing) { - _tracingMode = isTracing; - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScScript::dbgGetTracingMode() { - return _tracingMode; -} - - ////////////////////////////////////////////////////////////////////////// void ScScript::afterLoad() { if (_buffer == NULL) { diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 6b5fa1733b..1cd5c2dc1e 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -34,18 +34,13 @@ #include "engines/wintermute/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/wme_debugger.h" - namespace WinterMute { class BaseScriptHolder; class BaseObject; class ScEngine; class ScStack; -class ScScript : public BaseClass, public IWmeDebugScript { +class ScScript : public BaseClass { public: - bool dbgSendScript(IWmeDebugClient *client); - bool dbgSendVariables(IWmeDebugClient *client); - BaseArray _breakpoints; bool _tracingMode; @@ -172,12 +167,6 @@ private: public: virtual int dbgGetLine(); virtual const char *dbgGetFilename(); - virtual TScriptState dbgGetState(); - virtual int dbgGetNumBreakpoints(); - virtual int dbgGetBreakpoint(int Index); - - virtual bool dbgSetTracingMode(bool IsTracing); - virtual bool dbgGetTracingMode(); }; } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 96250dbb90..06f584c9bb 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -88,17 +88,10 @@ ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { ////////////////////////////////////////////////////////////////////////// ScEngine::~ScEngine() { _gameRef->LOG(0, "Shutting down scripting engine"); - saveBreakpoints(); disableProfiling(); cleanup(); - - for (int i = 0; i < _breakpoints.getSize(); i++) { - delete _breakpoints[i]; - _breakpoints[i] = NULL; - } - _breakpoints.clear(); } @@ -174,7 +167,6 @@ ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { script->_globals->setProp("this", &val); _scripts.add(script); - _gameRef->getDebugMgr()->onScriptInit(script); return script; } @@ -402,7 +394,7 @@ bool ScEngine::removeFinishedScripts() { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); } - _gameRef->getDebugMgr()->onScriptShutdown(_scripts[i]); + delete _scripts[i]; _scripts.remove_at(i); i--; @@ -556,177 +548,6 @@ bool ScEngine::clearGlobals(bool includingNatives) { return STATUS_OK; } -////////////////////////////////////////////////////////////////////////// -bool ScEngine::dbgSendScripts(IWmeDebugClient *client) { - // send global variables - _globals->dbgSendVariables(client, WME_DBGVAR_GLOBAL, NULL, 0); - - // process normal scripts first - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) { - continue; - } - _scripts[i]->dbgSendScript(client); - } - - // and threads later - for (int i = 0; i < _scripts.getSize(); i++) { - if (_scripts[i]->_thread || _scripts[i]->_methodThread) { - _scripts[i]->dbgSendScript(client); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::addBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - CScBreakpoint *bp = NULL; - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - bp = _breakpoints[i]; - break; - } - } - if (bp == NULL) { - bp = new CScBreakpoint(scriptFilename); - _breakpoints.add(bp); - } - - for (int i = 0; i < bp->_lines.getSize(); i++) { - if (bp->_lines[i] == line) { - return STATUS_OK; - } - } - bp->_lines.add(line); - - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::removeBreakpoint(const char *scriptFilename, int line) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), scriptFilename) == 0) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - if (_breakpoints[i]->_lines[j] == line) { - _breakpoints[i]->_lines.remove_at(j); - if (_breakpoints[i]->_lines.getSize() == 0) { - delete _breakpoints[i]; - _breakpoints.remove_at(i); - } - // refresh changes - refreshScriptBreakpoints(); - - return STATUS_OK; - } - } - break; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::refreshScriptBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - for (int i = 0; i < _scripts.getSize(); i++) { - refreshScriptBreakpoints(_scripts[i]); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::refreshScriptBreakpoints(ScScript *script) { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - if (!script || !script->_filename) { - return STATUS_FAILED; - } - - for (int i = 0; i < _breakpoints.getSize(); i++) { - if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), script->_filename) == 0) { - script->_breakpoints.copy(_breakpoints[i]->_lines); - return STATUS_OK; - } - } - if (script->_breakpoints.getSize() > 0) { - script->_breakpoints.clear(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::saveBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - - char text[512]; - char key[100]; - - int count = 0; - for (int i = 0; i < _breakpoints.getSize(); i++) { - for (int j = 0; j < _breakpoints[i]->_lines.getSize(); j++) { - count++; - sprintf(key, "Breakpoint%d", count); - sprintf(text, "%s:%d", _breakpoints[i]->_filename.c_str(), _breakpoints[i]->_lines[j]); - - BaseEngine::instance().getRegistry()->writeString("Debug", key, text); - } - } - BaseEngine::instance().getRegistry()->writeInt("Debug", "NumBreakpoints", count); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::loadBreakpoints() { - if (!_gameRef->getDebugMgr()->_enabled) { - return STATUS_OK; - } - - char key[100]; - - int count = BaseEngine::instance().getRegistry()->readInt("Debug", "NumBreakpoints", 0); - for (int i = 1; i <= count; i++) { - /* uint32 bufSize = 512; */ - sprintf(key, "Breakpoint%d", i); - AnsiString breakpoint = BaseEngine::instance().getRegistry()->readString("Debug", key, ""); - - char *path = BaseUtils::strEntry(0, breakpoint.c_str(), ':'); - char *line = BaseUtils::strEntry(1, breakpoint.c_str(), ':'); - - if (path != NULL && line != NULL) { - addBreakpoint(path, atoi(line)); - } - delete[] path; - delete[] line; - path = NULL; - line = NULL; - } - - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// void ScEngine::addScriptTime(const char *filename, uint32 time) { if (!_isProfiling) { diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index fcfaa51971..9aae8be85b 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -32,7 +32,6 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -#include "engines/wintermute/wme_debugger.h" namespace WinterMute { @@ -81,20 +80,7 @@ public: BaseArray _lines; }; - - - public: - bool dbgSendScripts(IWmeDebugClient *client); - - BaseArray _breakpoints; - bool addBreakpoint(const char *scriptFilename, int line); - bool removeBreakpoint(const char *scriptFilename, int line); - bool refreshScriptBreakpoints(); - bool refreshScriptBreakpoints(ScScript *script); - bool saveBreakpoints(); - bool loadBreakpoints(); - bool clearGlobals(bool includingNatives = false); bool tickUnbreakable(); bool removeFinishedScripts(); diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 456f93507e..d35f85f9a1 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -950,18 +950,6 @@ int ScValue::compareStrict(ScValue *val1, ScValue *val2) { } } - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - client->onVariableInit(type, script, scopeID, _valIter->_value, _valIter->_key.c_str()); - _valIter++; - } - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool ScValue::setProperty(const char *propName, int value) { ScValue *val = new ScValue(_gameRef, value); @@ -1004,128 +992,4 @@ bool ScValue::setProperty(const char *propName) { return ret; } - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugProp -////////////////////////////////////////////////////////////////////////// -EWmeDebuggerPropType ScValue::dbgGetType() { - switch (getType()) { - case VAL_NULL: - return WME_DBGPROP_NULL; - case VAL_STRING: - return WME_DBGPROP_STRING; - case VAL_INT: - return WME_DBGPROP_INT; - case VAL_BOOL: - return WME_DBGPROP_BOOL; - case VAL_FLOAT: - return WME_DBGPROP_FLOAT; - case VAL_OBJECT: - return WME_DBGPROP_OBJECT; - case VAL_NATIVE: - return WME_DBGPROP_NATIVE; - default: - return WME_DBGPROP_UNKNOWN; - } -} - -////////////////////////////////////////////////////////////////////////// -int ScValue::dbgGetValInt() { - return getInt(); -} - -////////////////////////////////////////////////////////////////////////// -double ScValue::dbgGetValFloat() { - return getFloat(); -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetValBool() { - return getBool(); -} - -////////////////////////////////////////////////////////////////////////// -const char *ScValue::dbgGetValString() { - return getString(); -} - -////////////////////////////////////////////////////////////////////////// -IWmeDebugObject *ScValue::dbgGetValNative() { - return getNative(); -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(int value) { - setInt(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(double value) { - setFloat(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(bool value) { - setBool(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal(const char *value) { - setString(value); - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgSetVal() { - setNULL(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int ScValue::dbgGetNumProperties() { - if (_valNative && _valNative->_scProp) { - return _valNative->_scProp->dbgGetNumProperties(); - } else { - return _valObject.size(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetProperty(int index, const char **name, IWmeDebugProp **value) { - if (_valNative && _valNative->_scProp) { - return _valNative->_scProp->dbgGetProperty(index, name, value); - } else { - int count = 0; - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (count == index) { - *name = _valIter->_key.c_str(); - *value = _valIter->_value; - return true; - } - _valIter++; - count++; - } - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::dbgGetDescription(char *buf, int bufSize) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->dbgGetDescription(buf, bufSize); - } - - if (_type == VAL_NATIVE) { - _valNative->scDebuggerDesc(buf, bufSize); - } else { - strncpy(buf, getString(), bufSize); - } - return true; -} - } // end of namespace WinterMute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 069c36bd47..8fced06972 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -33,7 +33,6 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/dcscript.h" // Added by ClassView -#include "engines/wintermute/wme_debugger.h" #include "common/str.h" namespace WinterMute { @@ -41,10 +40,8 @@ namespace WinterMute { class ScScript; class BaseScriptable; -class ScValue : public BaseClass, public IWmeDebugProp { +class ScValue : public BaseClass { public: - bool dbgSendVariables(IWmeDebugClient *client, EWmeDebuggerVariableType type, ScScript *script, unsigned int scopeID); - static int compare(ScValue *val1, ScValue *val2); static int compareStrict(ScValue *val1, ScValue *val2); TValType getTypeTolerant(); @@ -109,31 +106,6 @@ public: bool setProperty(const char *propName, double value); bool setProperty(const char *propName, bool value); bool setProperty(const char *propName); - - -// IWmeDebugProp interface implementation -public: - virtual EWmeDebuggerPropType dbgGetType(); - - // getters - virtual int dbgGetValInt(); - virtual double dbgGetValFloat(); - virtual bool dbgGetValBool(); - virtual const char *dbgGetValString(); - virtual IWmeDebugObject *dbgGetValNative(); - - // setters - virtual bool dbgSetVal(int value); - virtual bool dbgSetVal(double value); - virtual bool dbgSetVal(bool value); - virtual bool dbgSetVal(const char *value); - virtual bool dbgSetVal(); - - // properties - virtual int dbgGetNumProperties(); - virtual bool dbgGetProperty(int index, const char **mame, IWmeDebugProp **value); - - virtual bool dbgGetDescription(char *buf, int bufSize); }; } // end of namespace WinterMute -- cgit v1.2.3 From 2e7d21fc525a5b0451274d3844e3d6a1de1f6cb2 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 17:53:44 +0200 Subject: WINTERMUTE: Replace BaseRegistry with ConfMan --- engines/wintermute/base/base_engine.cpp | 5 - engines/wintermute/base/base_engine.h | 2 - engines/wintermute/base/base_file_manager.cpp | 33 +-- engines/wintermute/base/base_game.cpp | 43 ++-- engines/wintermute/base/base_registry.cpp | 279 --------------------- engines/wintermute/base/base_registry.h | 79 ------ .../base/gfx/osystem/base_render_osystem.cpp | 6 +- .../wintermute/base/scriptables/script_engine.cpp | 1 - .../wintermute/base/sound/base_sound_manager.cpp | 1 - 9 files changed, 32 insertions(+), 417 deletions(-) delete mode 100644 engines/wintermute/base/base_registry.cpp delete mode 100644 engines/wintermute/base/base_registry.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 0185d973fa..8e3e6cf0e0 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/system.h" @@ -40,20 +39,16 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; - _registry = NULL; _gameRef = NULL; _gameId = ""; } void BaseEngine::init() { - _registry = new BaseRegistry(); - // File-manager depends on registry. _fileManager = new BaseFileManager(); } BaseEngine::~BaseEngine() { delete _fileManager; - delete _registry; } void BaseEngine::createInstance(const Common::String &gameid) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index d45d979f25..30f241ecc6 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -37,7 +37,6 @@ class BaseGame; class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; - BaseRegistry *_registry; Common::String _gameId; BaseGame *_gameRef; public: @@ -48,7 +47,6 @@ public: BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } - BaseRegistry *getRegistry() { return _registry; } static void LOG(bool res, const char *fmt, ...); const char *getGameId() { return _gameId.c_str(); } }; diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 801729c5e8..d5071ccf48 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -32,7 +32,6 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/base/file/base_package.h" #include "engines/wintermute/base/file/base_resources.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" #include "common/debug.h" @@ -147,42 +146,12 @@ bool BaseFileManager::reloadPaths() { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::initPaths() { - if (!BaseEngine::instance().getRegistry()) { // This function only works when the game-registry is loaded - return STATUS_FAILED; - } - - AnsiString pathList; - - // single files paths - pathList = BaseEngine::instance().getRegistry()->readString("Resource", "CustomPaths", ""); - Common::StringTokenizer *entries = new Common::StringTokenizer(pathList, ";"); -// numPaths = BaseUtils::strNumEntries(pathList.c_str(), ';'); - while (!entries->empty()) { - Common::String path = entries->nextToken(); - if (path.size() > 0) { - error("BaseFileManager::initPaths - Game wants to add customPath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); - } - } - delete entries; - entries = NULL; + // Removed: Config-based file-path choice. // package files paths const Common::FSNode gameData(ConfMan.get("path")); addPath(PATH_PACKAGE, gameData); - pathList = BaseEngine::instance().getRegistry()->readString("Resource", "PackagePaths", ""); - entries = new Common::StringTokenizer(pathList, ";"); - while (!entries->empty()) { - Common::String path = entries->nextToken(); - if (path.size() > 0) { - error("BaseFileManager::initPaths - Game wants to add packagePath: %s", path.c_str()); // TODO - // addPath(PATH_SINGLE, path); - } - } - delete entries; - entries = NULL; - Common::FSNode dataSubFolder = gameData.getChild("data"); if (dataSubFolder.exists()) { addPath(PATH_PACKAGE, dataSubFolder); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 062f92ccae..0453222e24 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -39,7 +39,6 @@ #include "engines/wintermute/base/base_keyboard_state.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_quick_msg.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/base_sprite.h" @@ -64,6 +63,7 @@ #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" +#include "common/config-manager.h" #include "common/savefile.h" #include "common/textconsole.h" #include "common/util.h" @@ -276,7 +276,7 @@ BaseGame::~BaseGame() { LOG(0, ""); LOG(0, "Shutting down..."); - BaseEngine::instance().getRegistry()->writeBool("System", "LastRun", true); + ConfMan.setBool("last_run", true); cleanup(); @@ -1534,7 +1534,8 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int val = stack->pop()->getInt(); - BaseEngine::instance().getRegistry()->writeInt("PrivateSettings", key, val); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + ConfMan.setInt(privKey, val); stack->pushNULL(); return STATUS_OK; } @@ -1546,7 +1547,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); int initVal = stack->pop()->getInt(); - stack->pushInt(BaseEngine::instance().getRegistry()->readInt("PrivateSettings", key, initVal)); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + int result = initVal; + if (ConfMan.hasKey(privKey)) { + result = ConfMan.getInt(privKey); + } + stack->pushInt(result); return STATUS_OK; } @@ -1557,7 +1563,9 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *val = stack->pop()->getString(); - BaseEngine::instance().getRegistry()->writeString("PrivateSettings", key, val); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String privVal = StringUtil::encodeSetting(val); + ConfMan.set(privKey, privVal); stack->pushNULL(); return STATUS_OK; } @@ -1569,8 +1577,12 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack stack->correctParams(2); const char *key = stack->pop()->getString(); const char *initVal = stack->pop()->getString(); - AnsiString val = BaseEngine::instance().getRegistry()->readString("PrivateSettings", key, initVal); - stack->pushString(val.c_str()); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String result = initVal; + if (ConfMan.hasKey(privKey)) { + result = StringUtil::decodeSetting(ConfMan.get(key)); + } + stack->pushString(result.c_str()); return STATUS_OK; } @@ -2627,7 +2639,11 @@ ScValue *BaseGame::scGetProperty(const char *name) { // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "MostRecentSaveSlot") == 0) { - _scValue->setInt(BaseEngine::instance().getRegistry()->readInt("System", "MostRecentSaveSlot", -1)); + if (!ConfMan.hasKey("most_recent_saveslot")) { + _scValue->setInt(-1); + } else { + _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); + } return _scValue; } @@ -3329,7 +3345,7 @@ bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = pm->saveFile(filename))) { - BaseEngine::instance().getRegistry()->writeInt("System", "MostRecentSaveSlot", slot); + ConfMan.setInt("most_recent_saveslot", slot); } } } @@ -3663,7 +3679,7 @@ bool BaseGame::loadSettings(const char *filename) { break; case TOKEN_REGISTRY_PATH: - BaseEngine::instance().getRegistry()->setBasePath((char *)params); + //BaseEngine::instance().getRegistry()->setBasePath((char *)params); break; case TOKEN_RICH_SAVED_GAMES: @@ -3687,9 +3703,8 @@ bool BaseGame::loadSettings(const char *filename) { ret = STATUS_FAILED; } - _settingsAllowWindowed = BaseEngine::instance().getRegistry()->readBool("Debug", "AllowWindowed", _settingsAllowWindowed); - _compressedSavegames = BaseEngine::instance().getRegistry()->readBool("Debug", "CompressedSavegames", _compressedSavegames); - //_compressedSavegames = false; + _settingsAllowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. + _compressedSavegames = true; delete[] origBuffer; @@ -4679,7 +4694,7 @@ bool BaseGame::isDoubleClick(int buttonIndex) { ////////////////////////////////////////////////////////////////////////// void BaseGame::autoSaveOnExit() { _soundMgr->saveSettings(); - BaseEngine::instance().getRegistry()->saveValues(); + ConfMan.flushToDisk(); if (!_autoSaveOnExit) { return; diff --git a/engines/wintermute/base/base_registry.cpp b/engines/wintermute/base/base_registry.cpp deleted file mode 100644 index d03691ea42..0000000000 --- a/engines/wintermute/base/base_registry.cpp +++ /dev/null @@ -1,279 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/tinyxml/tinyxml.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/wintermute.h" -#include "common/savefile.h" -#include "common/config-manager.h" -#include "common/file.h" - -namespace WinterMute { - -////////////////////////////////////////////////////////////////////////// -BaseRegistry::BaseRegistry() { - _iniName = NULL; - - setIniName("./wme.ini"); - loadValues(true); -} - - -////////////////////////////////////////////////////////////////////////// -BaseRegistry::~BaseRegistry() { - saveValues(); - delete[] _iniName; - _iniName = NULL; -} - - - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseRegistry::readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init) { - AnsiString ret = ""; - - bool found = false; - ret = getValue(_localValues, subKey, key, found); - if (!found) { - ret = getValue(_values, subKey, key, found); - } - if (!found) { - ret = init; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value) { - _values[subKey][key] = value; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseRegistry::readInt(const AnsiString &subKey, const AnsiString &key, int init) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - if (ConfMan.hasKey("master_volume")) { - return ConfMan.getInt("master_volume"); - } else { - return init; - } - } else if (key == "SFXVolume") { - if (ConfMan.hasKey("sfx_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "SpeechVolume") { - if (ConfMan.hasKey("speech_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } else if (key == "MusicVolume") { - if (ConfMan.hasKey("music_volume")) { - error("This key shouldn't be read by the scripts"); - } else { - return init; - } - } - } - AnsiString val = readString(subKey, key, ""); - if (val.empty()) { - return init; - } else { - return atoi(val.c_str()); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeInt(const AnsiString &subKey, const AnsiString &key, int value) { - if (subKey == "Audio") { - if (key == "MasterVolume") { - ConfMan.setInt("master_volume", value); - return true; - } else if (key == "SFXVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "SpeechVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } else if (key == "MusicVolume") { - error("This key shouldn't be read by the scripts"); - return true; - } - } - writeString(subKey, key, StringUtil::toString(value)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::readBool(const AnsiString &subKey, const AnsiString &key, bool init) { - return (readInt(subKey, key, (int)init) != 0); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegistry::writeBool(const AnsiString &subKey, const AnsiString &key, bool value) { - return writeInt(subKey, key, (int)value); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::setIniName(const char *name) { - delete[] _iniName; - _iniName = NULL; - - if (strchr(name, '\\') == NULL && strchr(name, '/') == NULL) { - _iniName = new char [strlen(name) + 3]; - sprintf(_iniName, "./%s", name); - } else { - _iniName = new char [strlen(name) + 1]; - strcpy(_iniName, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseRegistry::getIniName() { - return _iniName; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::loadValues(bool local) { - Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; - loadXml(filename, _values); -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::saveValues() { - Common::String filename = Common::String(BaseEngine::instance().getGameId()) + "-settings.xml"; - saveXml(filename, _values); -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::setBasePath(const char *basePath) { - _basePath = PathUtil::getFileNameWithoutExtension(basePath); - - loadValues(false); -} - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseRegistry::getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found) { - found = false; - PathValueMap::iterator it = values.find(path); - if (it == values.end()) { - return ""; - } - - KeyValuePair pairs = (*it)._value; - KeyValuePair::iterator keyIt = pairs.find(key); - if (keyIt == pairs.end()) { - return ""; - } else { - found = true; - return (*keyIt)._value; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::loadXml(const AnsiString fileName, PathValueMap &values) { - Common::SeekableReadStream *stream = g_wintermute->getSaveFileMan()->openForLoading(fileName); - if (!stream) { - return; - } - char *data = new char[stream->size()]; - stream->read(data, stream->size()); - TiXmlDocument doc; - doc.Parse(data); - delete[] data; - - TiXmlElement *rootElem = doc.RootElement(); - if (!rootElem || Common::String(rootElem->Value()) != "Settings") { // TODO: Avoid this strcmp-use. (Hack for now, since we might drop TinyXML all together) - return; - } - - for (TiXmlElement *pathElem = rootElem->FirstChildElement(); pathElem != NULL; pathElem = pathElem->NextSiblingElement()) { - for (TiXmlElement *keyElem = pathElem->FirstChildElement(); keyElem != NULL; keyElem = keyElem->NextSiblingElement()) { - values[Common::String(pathElem->Value())][Common::String(keyElem->Value())] = keyElem->GetText(); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegistry::saveXml(const AnsiString fileName, PathValueMap &values) { - BaseUtils::createPath(fileName.c_str()); - - TiXmlDocument doc; - doc.LinkEndChild(new TiXmlDeclaration("1.0", "utf-8", "")); - - TiXmlElement *root = new TiXmlElement("Settings"); - doc.LinkEndChild(root); - - PathValueMap::iterator pathIt; - for (pathIt = _values.begin(); pathIt != _values.end(); ++pathIt) { - TiXmlElement *pathElem = new TiXmlElement((*pathIt)._key.c_str()); - root->LinkEndChild(pathElem); - - - KeyValuePair pairs = (*pathIt)._value; - KeyValuePair::iterator keyIt; - for (keyIt = pairs.begin(); keyIt != pairs.end(); ++keyIt) { - TiXmlElement *keyElem = new TiXmlElement((*keyIt)._key.c_str()); - pathElem->LinkEndChild(keyElem); - - keyElem->LinkEndChild(new TiXmlText((*keyIt)._value.c_str())); - } - } - - - TiXmlPrinter printer; - doc.Accept(&printer); - - Common::WriteStream *stream = g_wintermute->getSaveFileMan()->openForSaving(fileName); - - if (!stream) { - return; - } else { - stream->write(printer.CStr(), printer.Size()); - stream->finalize(); - delete stream; - } -} - -} // end of namespace WinterMute diff --git a/engines/wintermute/base/base_registry.h b/engines/wintermute/base/base_registry.h deleted file mode 100644 index 5e235c2a68..0000000000 --- a/engines/wintermute/base/base_registry.h +++ /dev/null @@ -1,79 +0,0 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BREGISTRY_H -#define WINTERMUTE_BREGISTRY_H - -#include "engines/wintermute/dctypes.h" -#include "common/hashmap.h" -#include "common/hash-str.h" -#include "common/str.h" - -namespace WinterMute { - -class BaseRegistry { -public: - void setIniName(const char *name); - char *getIniName(); - bool writeBool(const AnsiString &subKey, const AnsiString &key, bool Value); - bool readBool(const AnsiString &subKey, const AnsiString &key, bool init = false); - bool writeInt(const AnsiString &subKey, const AnsiString &key, int value); - int readInt(const AnsiString &subKey, const AnsiString &key, int init = 0); - bool writeString(const AnsiString &subKey, const AnsiString &key, const AnsiString &value); - AnsiString readString(const AnsiString &subKey, const AnsiString &key, const AnsiString &init = ""); - BaseRegistry(); - virtual ~BaseRegistry(); - - void setBasePath(const char *basePath); - AnsiString getBasePath() const { - return _basePath; - } - - void loadValues(bool local); - void saveValues(); - -private: - char *_iniName; - - typedef Common::HashMap KeyValuePair; - typedef Common::HashMap PathValueMap; - - PathValueMap _localValues; - PathValueMap _values; - - AnsiString _basePath; - - void loadXml(const AnsiString fileName, PathValueMap &values); - void saveXml(const AnsiString fileName, PathValueMap &values); - - AnsiString getValue(PathValueMap &values, const AnsiString path, const AnsiString &key, bool &found); -}; - -} // end of namespace WinterMute - -#endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 8e6c6bb83c..f407a871b0 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -27,8 +27,6 @@ */ #include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/base_registry.h" -#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_image.h" @@ -128,8 +126,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - _realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); - _realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); + //_realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); + //_realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); float origAspect = (float)_width / (float)_height; float realAspect = (float)_realWidth / (float)_realHeight; diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 06f584c9bb..e5d965a4b1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -32,7 +32,6 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" #include "engines/wintermute/base/scriptables/script_ext_math.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 43109443a7..ed475ec31c 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/base_registry.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" -- cgit v1.2.3 From 20e2ec4ff4d869ba54edf5b930d84340245292b6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 18:00:15 +0200 Subject: WINTERMUTE: Remove unused functions from StringUtil:: --- engines/wintermute/base/base_persistence_manager.cpp | 1 - engines/wintermute/base/base_sprite.cpp | 6 ++++-- engines/wintermute/base/base_string_table.cpp | 1 - engines/wintermute/base/gfx/base_image.cpp | 3 +-- engines/wintermute/base/scriptables/script_engine.cpp | 1 - 5 files changed, 5 insertions(+), 7 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index ddc5e15d92..b6cd59328d 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -34,7 +34,6 @@ #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/wintermute.h" diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index bc42f81dd4..6c66b808b7 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" @@ -140,8 +139,11 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC bool ret; + AnsiString filePrefix = filename; AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::startsWith(filename, "savegame:", true) || StringUtil::compareNoCase(ext, "bmp") || StringUtil::compareNoCase(ext, "tga") || StringUtil::compareNoCase(ext, "png") || StringUtil::compareNoCase(ext, "jpg")) { + ext.toLowercase(); + filePrefix.toLowercase(); + if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) { BaseFrame *frame = new BaseFrame(_gameRef); BaseSubFrame *subframe = new BaseSubFrame(_gameRef); subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 8fa69e5288..2e8774020d 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -30,7 +30,6 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_string_table.h" -#include "engines/wintermute/utils/string_util.h" #include "common/str.h" namespace WinterMute { diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 2167503dc8..9203b62734 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/graphics/transparent_surface.h" -#include "engines/wintermute/utils/string_util.h" #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" @@ -63,7 +62,7 @@ BaseImage::~BaseImage() { bool BaseImage::loadFile(const Common::String &filename) { _filename = filename; _filename.toLowercase(); - if (StringUtil::startsWith(filename, "savegame:", true)) { + if (filename.hasPrefix("savegame:")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".png")) { _decoder = new Graphics::PNGDecoder(); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index e5d965a4b1..a1f246c4bc 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -27,7 +27,6 @@ */ #include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -- cgit v1.2.3 From 6b07218eb24e91865eee277758112e5bb4fecd97 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 18:22:10 +0200 Subject: WINTERMUTE: Remove statics and silence spam in debug console. --- engines/wintermute/base/base_parser.cpp | 21 +++++++++++---------- engines/wintermute/base/base_parser.h | 8 ++++---- engines/wintermute/base/font/base_font_truetype.cpp | 7 +------ .../base/gfx/osystem/base_render_osystem.cpp | 21 ++++++++------------- .../base/gfx/osystem/base_render_osystem.h | 2 +- 5 files changed, 25 insertions(+), 34 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 5d5a2d534d..1b39b55768 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -64,7 +64,7 @@ char *BaseParser::getLastOffender() { ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **data) { +int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, char **data) { skipCharacters(buf, _whiteSpace); // skip comment lines. @@ -119,7 +119,7 @@ int32 BaseParser::getObject(char **buf, TokenDesc *tokens, char **name, char **d ////////////////////////////////////////////////////////////////////// -int32 BaseParser::getCommand(char **buf, TokenDesc *tokens, char **params) { +int32 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { if (!*buf) { return PARSERR_TOKENNOTFOUND; } @@ -205,12 +205,10 @@ char *BaseParser::getAssignmentText(char **buf) { return result; } - -////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -char *BaseParser::getToken(char **buf) { - static char token[100]; - char *b = *buf, * t = token; +Common::String BaseParser::getToken(char **buf) { + char token[100]; // TODO: Remove static + char *b = *buf, *t = token; while (true) { while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { b++; @@ -265,7 +263,8 @@ char *BaseParser::getToken(char **buf) { ////////////////////////////////////////////////////////////////////// float BaseParser::getTokenFloat(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { // Error situation. We handle this by return 0. return 0.; @@ -277,7 +276,8 @@ float BaseParser::getTokenFloat(char **buf) { ////////////////////////////////////////////////////////////////////// int BaseParser::getTokenInt(char **buf) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (!((*t >= '0' && *t <= '9') || *t == '-')) { // Error situation. We handle this by return 0. return 0; @@ -289,7 +289,8 @@ int BaseParser::getTokenInt(char **buf) { ////////////////////////////////////////////////////////////////////// void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { - char *t = getToken(buf); + Common::String token = getToken(buf); + const char *t = token.c_str(); if (strcmp(t, tok)) { return; // Error } diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 3b1979efa1..34266bd5bd 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -40,7 +40,7 @@ TOKEN_TOTAL_COUNT \ }; #define TOKEN_TABLE_START(name) \ - static BaseParser::TokenDesc name [] = \ + static const BaseParser::TokenDesc name [] = \ { #define TOKEN_TABLE(name) \ { TOKEN_ ## name, #name }, @@ -65,7 +65,7 @@ public: public: int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, TokenDesc *tokens, char **params); + int32 getCommand(char **buf, const TokenDesc *tokens, char **params); BaseParser(); virtual ~BaseParser(); private: @@ -73,11 +73,11 @@ private: void skipToken(char **buf, char *tok, char *msg = NULL); int getTokenInt(char **buf); float getTokenFloat(char **buf); - char *getToken(char **buf); + Common::String getToken(char **buf); char *getAssignmentText(char **buf); char *getSubText(char **buf, char open, char close); void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, TokenDesc *tokens, char **name, char **data); + int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data); int _parserLine; char _lastOffender[255]; char *_whiteSpace; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index a141c68db7..b80bbdc41d 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -568,12 +568,7 @@ bool BaseFontTT::initFont() { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { //TextLineList lines; - // TODO: This function gets called a lot, so warnings like these drown out the usefull information - static bool hasWarned = false; - if (!hasWarned) { - hasWarned = true; - warning("Todo: Test Mesuretext"); - } + if (maxWidth >= 0) { Common::Array lines; _font->wordWrapText(text, maxWidth, lines); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index f407a871b0..fa0663dc65 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -105,7 +105,6 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { setAlphaMod(255); setColorMod(255, 255, 255); _dirtyRect = NULL; - _disableDirtyRects = true; } ////////////////////////////////////////////////////////////////////////// @@ -232,12 +231,10 @@ void BaseRenderOSystem::fade(uint16 alpha) { void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - } - hasWarned = true; + + // TODO: Add fading with dirty rects. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); } Common::Rect fillRect; @@ -461,13 +458,11 @@ void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::R ////////////////////////////////////////////////////////////////////////// bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - static bool hasWarned = false; - if (!hasWarned) { - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); - } - hasWarned = true; + + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); } + byte r = RGBCOLGetR(color); byte g = RGBCOLGetG(color); byte b = RGBCOLGetB(color); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index dfffc68c17..2b6b5943c2 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -115,7 +115,7 @@ private: int _borderRight; int _borderBottom; - bool _disableDirtyRects; + static const bool _disableDirtyRects = true; float _ratioX; float _ratioY; uint32 _colorMod; -- cgit v1.2.3 From 80a67a70cdaad254185ffd9b2042a710e4a6e338 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 19:09:37 +0200 Subject: WINTERMUTE: Add header-guards to BaseEngine --- engines/wintermute/base/base_engine.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 30f241ecc6..b9dcfcb845 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -26,6 +26,9 @@ * Copyright (c) 2011 Jan Nedoma */ +#ifndef WINTERMUTE_BASE_ENGINE_H +#define WINTERMUTE_BASE_ENGINE_H + #include "common/str.h" #include "common/singleton.h" @@ -52,3 +55,5 @@ public: }; } // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 85ce9340bcb425a6c5e8dbcacff5a7fa2fb4c817 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 29 Jul 2012 21:35:11 +0200 Subject: WINTERMUTE: Separate out SaveGame-code from BaseGame --- engines/wintermute/base/base_game.cpp | 342 +++++--------------------- engines/wintermute/base/base_game.h | 36 +-- engines/wintermute/base/gfx/base_renderer.cpp | 129 ++++++++++ engines/wintermute/base/gfx/base_renderer.h | 30 +++ engines/wintermute/base/saveload.cpp | 198 +++++++++++++++ engines/wintermute/base/saveload.h | 57 +++++ 6 files changed, 475 insertions(+), 317 deletions(-) create mode 100644 engines/wintermute/base/saveload.cpp create mode 100644 engines/wintermute/base/saveload.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 0453222e24..b92da4c11b 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -49,10 +49,7 @@ #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/base/saveload.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_engine.h" #include "engines/wintermute/base/scriptables/script_stack.h" @@ -61,6 +58,10 @@ #include "engines/wintermute/video/video_player.h" #include "engines/wintermute/video/video_theora_player.h" #include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/ui/ui_window.h" #include "engines/wintermute/wintermute.h" #include "engines/wintermute/platform_osystem.h" #include "common/config-manager.h" @@ -195,13 +196,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _thumbnailWidth = _thumbnailHeight = 0; - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; _richSavedGames = false; _savedGameExt = NULL; BaseUtils::setString(&_savedGameExt, "dsv"); @@ -213,13 +207,6 @@ BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gam _musicCrossfadeChannel2 = -1; _musicCrossfadeSwap = false; - _loadImageName = NULL; - _saveImageName = NULL; - _saveLoadImage = NULL; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - _localSaveDir = NULL; BaseUtils::setString(&_localSaveDir, "saves"); _saveDirChecked = false; @@ -286,7 +273,6 @@ BaseGame::~BaseGame() { delete _cachedThumbnail; - delete _saveLoadImage; delete _mathClass; delete _transMgr; @@ -307,7 +293,6 @@ BaseGame::~BaseGame() { _cachedThumbnail = NULL; - _saveLoadImage = NULL; _mathClass = NULL; _transMgr = NULL; @@ -352,11 +337,6 @@ bool BaseGame::cleanup() { _windows.clear(); // refs only _focusedWindow = NULL; // ref only - delete[] _saveImageName; - delete[] _loadImageName; - _saveImageName = NULL; - _loadImageName = NULL; - delete _cursorNoninteractive; delete _cursor; delete _activeCursor; @@ -488,17 +468,7 @@ bool BaseGame::initialize2() { // we know whether we are going to be accelerated bool BaseGame::initialize3() { // renderer is initialized _posX = _renderer->_width / 2; _posY = _renderer->_height / 2; - - if (_indicatorY == -1) { - _indicatorY = _renderer->_height - _indicatorHeight; - } - if (_indicatorX == -1) { - _indicatorX = 0; - } - if (_indicatorWidth == -1) { - _indicatorWidth = _renderer->_width; - } - + _renderer->initIndicator(); return STATUS_OK; } @@ -780,6 +750,20 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(LOCAL_SAVE_DIR) TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) TOKEN_TABLE_END + + // Declare a few variables necessary for moving data from these settings over to the renderer: + // The values are the same as the defaults set in BaseRenderer. + int loadImageX = 0; + int loadImageY = 0; + int saveImageX = 0; + int saveImageY = 0; + int indicatorX = -1; + int indicatorY = -1; + int indicatorWidth = -1; + int indicatorHeight = 8; + uint32 indicatorColor = BYTETORGBA(255, 0, 0, 128); + Common::String loadImageName = ""; + Common::String saveImageName = ""; byte *params; int cmd; @@ -896,50 +880,50 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { break; case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &_indicatorX); + parser.scanStr((char *)params, "%d", &indicatorX); break; case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &_indicatorY); + parser.scanStr((char *)params, "%d", &indicatorY); break; case TOKEN_INDICATOR_COLOR: { int r, g, b, a; parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - _indicatorColor = BYTETORGBA(r, g, b, a); + indicatorColor = BYTETORGBA(r, g, b, a); } break; case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &_indicatorWidth); + parser.scanStr((char *)params, "%d", &indicatorWidth); break; case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &_indicatorHeight); + parser.scanStr((char *)params, "%d", &indicatorHeight); break; case TOKEN_SAVE_IMAGE: - BaseUtils::setString(&_saveImageName, (char *)params); + saveImageName = (char *) params; break; case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &_saveImageX); + parser.scanStr((char *)params, "%d", &saveImageX); break; case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_saveImageY); + parser.scanStr((char *)params, "%d", &saveImageY); break; case TOKEN_LOAD_IMAGE: - BaseUtils::setString(&_loadImageName, (char *)params); + loadImageName = (char *) params; break; case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &_loadImageX); + parser.scanStr((char *)params, "%d", &loadImageX); break; case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &_loadImageY); + parser.scanStr((char *)params, "%d", &loadImageY); break; case TOKEN_LOCAL_SAVE_DIR: @@ -952,6 +936,11 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { } } + _renderer->setIndicator(indicatorWidth, indicatorHeight, indicatorX, indicatorY, indicatorColor); + _renderer->initIndicator(); // In case we just reset the values. + _renderer->setSaveImage(saveImageName.c_str(), saveImageX, saveImageY); + _renderer->setLoadingScreen(loadImageName.c_str(), loadImageX, loadImageY); + if (!_systemFont) { _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); } @@ -1624,7 +1613,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "IsSaveSlotUsed") == 0) { stack->correctParams(1); int slot = stack->pop()->getInt(); - stack->pushBool(isSaveSlotUsed(slot)); + stack->pushBool(SaveLoad::isSaveSlotUsed(slot)); return STATUS_OK; } @@ -1636,7 +1625,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack int slot = stack->pop()->getInt(); char desc[512]; desc[0] = '\0'; - getSaveSlotDescription(slot, desc); + SaveLoad::getSaveSlotDescription(slot, desc); stack->pushString(desc); return STATUS_OK; } @@ -1647,7 +1636,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "EmptySaveSlot") == 0) { stack->correctParams(1); int slot = stack->pop()->getInt(); - emptySaveSlot(slot); + SaveLoad::emptySaveSlot(slot); stack->pushNULL(); return STATUS_OK; } @@ -1979,14 +1968,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "SetLoadingScreen") == 0) { stack->correctParams(3); ScValue *val = stack->pop(); - _loadImageX = stack->pop()->getInt(); - _loadImageY = stack->pop()->getInt(); + int loadImageX = stack->pop()->getInt(); + int loadImageY = stack->pop()->getInt(); if (val->isNULL()) { - delete[] _loadImageName; - _loadImageName = NULL; + _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); } else { - BaseUtils::setString(&_loadImageName, val->getString()); + _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); } stack->pushNULL(); return STATUS_OK; @@ -1998,14 +1986,13 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "SetSavingScreen") == 0) { stack->correctParams(3); ScValue *val = stack->pop(); - _saveImageX = stack->pop()->getInt(); - _saveImageY = stack->pop()->getInt(); + int saveImageX = stack->pop()->getInt(); + int saveImageY = stack->pop()->getInt(); if (val->isNULL()) { - delete[] _saveImageName; - _saveImageName = NULL; + _renderer->setSaveImage(NULL, saveImageX, saveImageY); } else { - BaseUtils::setString(&_saveImageName, val->getString()); + _renderer->setSaveImage(NULL, saveImageX, saveImageY); } stack->pushNULL(); return STATUS_OK; @@ -3316,48 +3303,7 @@ bool BaseGame::showCursor() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - - LOG(0, "Saving game '%s'...", filename); - - _gameRef->applyEvent("BeforeSave", true); - - bool ret; - - _indicatorDisplay = true; - _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(); - if (DID_SUCCEED(ret = pm->initSave(desc))) { - if (!quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } - - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(_gameRef, pm, quickSave))) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(_gameRef, pm, quickSave))) { - if (DID_SUCCEED(ret = pm->saveFile(filename))) { - ConfMan.setInt("most_recent_saveslot", slot); - } - } - } - } - - delete pm; - _indicatorDisplay = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - return ret; + return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); } @@ -3368,102 +3314,17 @@ bool BaseGame::loadGame(int slot) { _loading = false; _scheduledLoadSlot = -1; - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); + Common::String filename = SaveLoad::getSaveSlotFilename(slot); - return loadGame(filename); + return loadGame(filename.c_str()); } ////////////////////////////////////////////////////////////////////////// bool BaseGame::loadGame(const char *filename) { - LOG(0, "Loading game '%s'...", filename); - - bool ret; - - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName) { - _saveLoadImage = _renderer->createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - - - _loadInProgress = true; - _indicatorDisplay = true; - _indicatorProgress = 0; - BasePersistenceManager *pm = new BasePersistenceManager(); - if (DID_SUCCEED(ret = pm->initLoad(filename))) { - //if (DID_SUCCEED(ret = cleanup())) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(_gameRef, pm))) { - if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(_gameRef, pm))) { - // data initialization after load - initAfterLoad(); - - _gameRef->applyEvent("AfterLoad", true); - - displayContent(true, false); - //_renderer->flip(); - } - } - } - - _indicatorDisplay = false; - delete pm; - _loadInProgress = false; - - delete _saveLoadImage; - _saveLoadImage = NULL; - - //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::initAfterLoad() { - SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); - SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); - - return STATUS_OK; + return SaveLoad::loadGame(filename, _gameRef); } -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadRegion(void *region, void *data) { - ((BaseRegion *)region)->createRegion(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadSubFrame(void *subframe, void *data) { - ((BaseSubFrame *)subframe)->setSurfaceSimple(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadSound(void *sound, void *data) { - ((BaseSound *)sound)->setSoundSimple(); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadFont(void *font, void *data) { - ((BaseFont *)font)->afterLoad(); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::afterLoadScript(void *script, void *data) { - ((ScScript *)script)->afterLoad(); -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayWindows(bool inGame) { bool res; @@ -3773,13 +3634,8 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); + + _renderer->persistSaveLoadImages(persistMgr); persistMgr->transfer(TMEMBER_INT(_textEncoding)); persistMgr->transfer(TMEMBER(_textRTL)); @@ -3907,13 +3763,13 @@ void BaseGame::handleKeyRelease(Common::Event *event) { ////////////////////////////////////////////////////////////////////////// -bool BaseGame::handleMouseWheel(int Delta) { +bool BaseGame::handleMouseWheel(int delta) { bool handled = false; if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(Delta); + handled = _gameRef->_focusedWindow->handleMouseWheel(delta); if (!handled) { - if (Delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + if (delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); handled = true; } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { @@ -3925,7 +3781,7 @@ bool BaseGame::handleMouseWheel(int Delta) { } if (!handled) { - if (Delta < 0) { + if (delta < 0) { applyEvent("MouseWheelDown"); } else { applyEvent("MouseWheelUp"); @@ -3981,61 +3837,6 @@ void BaseGame::setWindowTitle() { } -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getSaveSlotFilename(int slot, char *buffer) { - BasePersistenceManager *pm = new BasePersistenceManager(); - Common::String filename = pm->getFilenameForSlot(slot); - delete pm; - strcpy(buffer, filename.c_str()); - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, buffer); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getSaveSlotDescription(int slot, char *buffer) { - buffer[0] = '\0'; - - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - if (!pm) { - return STATUS_FAILED; - } - - if (DID_FAIL(pm->initLoad(filename))) { - delete pm; - return STATUS_FAILED; - } - - strcpy(buffer, pm->_savedDescription); - delete pm; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isSaveSlotUsed(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - bool ret = pm->getSaveExists(slot); - delete pm; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::emptySaveSlot(int slot) { - char filename[MAX_PATH_LENGTH + 1]; - getSaveSlotFilename(slot, filename); - BasePersistenceManager *pm = new BasePersistenceManager(); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); - delete pm; - return STATUS_OK; -} - - ////////////////////////////////////////////////////////////////////////// bool BaseGame::setActiveObject(BaseObject *obj) { // not-active when game is frozen @@ -4181,35 +3982,8 @@ bool BaseGame::displayContent(bool doUpdate, bool displayAll) { bool BaseGame::displayContentSimple() { // fill black _renderer->fill(0, 0, 0); - if (_indicatorDisplay) { - displayIndicator(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayIndicator() { - if (_saveLoadImage) { - Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) { - _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - } else { - _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { - return STATUS_OK; - } - _renderer->setupLines(); - for (int i = 0; i < _indicatorHeight; i++) { - _renderer->drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); - } + _renderer->displayIndicator(); - _renderer->setup2D(); return STATUS_OK; } diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index fd20608a42..8a587da3e3 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -109,8 +109,6 @@ public: void DEBUG_DumpClassRegistry(); bool setWaitCursor(const char *filename); - int _indicatorProgress; // TODO: Hide - int _thumbnailWidth; int _thumbnailHeight; @@ -204,9 +202,9 @@ public: bool displayWindows(bool inGame = false); bool _useD3D; virtual bool cleanup(); - virtual bool loadGame(int slot); - virtual bool loadGame(const char *filename); - virtual bool saveGame(int slot, const char *desc, bool quickSave = false); + bool loadGame(int slot); + bool loadGame(const char *filename); + bool saveGame(int slot, const char *desc, bool quickSave = false); virtual bool showCursor(); BaseObject *_activeObject; @@ -248,7 +246,6 @@ public: BaseSprite *_lastCursor; bool drawCursor(BaseSprite *Cursor); - virtual bool initAfterLoad(); BaseSaveThumbHelper *_cachedThumbnail; void addMem(int bytes); bool _touchInterface; @@ -261,18 +258,10 @@ protected: BaseFader *_fader; - bool _indicatorDisplay; - bool displayIndicator(); - int _freezeLevel; VideoPlayer *_videoPlayer; VideoTheoraPlayer *_theoraPlayer; - static void afterLoadRegion(void *region, void *data); private: - static void afterLoadSubFrame(void *subframe, void *data); - static void afterLoadSound(void *sound, void *data); - static void afterLoadFont(void *font, void *data); - static void afterLoadScript(void *script, void *data); bool _mouseRightDown; bool _mouseMidlleDown; bool _settingsRequireAcceleration; @@ -286,26 +275,11 @@ private: virtual bool invalidateDeviceObjects(); virtual bool restoreDeviceObjects(); - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - char *_localSaveDir; bool _saveDirChecked; bool _richSavedGames; char *_savedGameExt; - char *_loadImageName; - char *_saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - - BaseSurface *_saveLoadImage; - bool _reportTextureFormat; // FPS stuff @@ -324,10 +298,6 @@ private: bool _personalizedSave; - bool emptySaveSlot(int slot); - bool isSaveSlotUsed(int slot); - bool getSaveSlotDescription(int slot, char *buffer); - bool getSaveSlotFilename(int slot, char *buffer); void setWindowTitle(); bool resumeMusic(int channel); diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index cc6167a749..cd065f3436 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_persistence_manager.h" namespace WinterMute { @@ -44,6 +45,22 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _windowed = true; _forceAlphaColor = 0x00; + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + + _loadImageName = ""; + _saveImageName = ""; + _saveLoadImage = NULL; + _loadInProgress = false; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + _width = _height = _bPP = 0; BasePlatform::setRectEmpty(&_monitorRect); @@ -56,6 +73,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { BaseRenderer::~BaseRenderer() { deleteRectList(); unclipCursor(); + delete _saveLoadImage; } @@ -64,6 +82,90 @@ void BaseRenderer::initLoop() { deleteRectList(); } +void BaseRenderer::initIndicator() { + if (_indicatorY == -1) { + _indicatorY = _height - _indicatorHeight; + } + if (_indicatorX == -1) { + _indicatorX = 0; + } + if (_indicatorWidth == -1) { + _indicatorWidth = _width; + } +} + +void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 color) { + _indicatorWidth = width; + _indicatorHeight = height; + _indicatorX = x; + _indicatorY = y; + _indicatorColor = color; +} + +void BaseRenderer::setIndicatorVal(int value) { + _indicatorProgress = value; +} + +void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { + // TODO: Handle NULL + _loadImageName = filename; + _loadImageX = x; + _loadImageY = y; +} + +void BaseRenderer::setSaveImage(const char *filename, int x, int y) { + // TODO: Handle NULL + _saveImageName = filename; + _saveImageX = x; + _saveImageY = y; +} + +void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { + _indicatorDisplay = true; + _indicatorProgress = 0; + + if (isSaving && !quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } else { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + _loadInProgress = true; + } +} + +void BaseRenderer::endSaveLoad() { + _loadInProgress = false; + _indicatorDisplay = false; + + delete _saveLoadImage; + _saveLoadImage = NULL; +} + +void BaseRenderer::persistSaveLoadImages(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); +} ////////////////////////////////////////////////////////////////////// BaseObject *BaseRenderer::getObjectAt(int x, int y) { @@ -234,4 +336,31 @@ void BaseRenderer::addRectToList(BaseActiveRect *rect) { _rectList.push_back(rect); } +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::displayIndicator() { + if (!_indicatorDisplay) { + return STATUS_OK; + } + if (_saveLoadImage) { + Rect32 rc; + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + return STATUS_OK; + } + setupLines(); + for (int i = 0; i < _indicatorHeight; i++) { + drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + } + + setup2D(); + return STATUS_OK; +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 008db69713..a36a3ca9c0 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -40,6 +40,7 @@ class BaseImage; class BaseActiveRect; class BaseObject; class BaseSurface; +class BasePersistenceManager; /** * @class BaseRenderer a common interface for the rendering portion of WME @@ -166,6 +167,35 @@ public: uint32 _forceAlphaColor; void addRectToList(BaseActiveRect *rect); + + // Indicator & Save/Load-related functions + void initIndicator(); + void setIndicatorVal(int value); + void setIndicator(int width, int height, int x, int y, uint32 color); + void persistSaveLoadImages(BasePersistenceManager *persistMgr); + void initSaveLoad(bool isSaving, bool quickSave = false); + void endSaveLoad(); + void setLoadingScreen(const char *filename, int x, int y); + void setSaveImage(const char *filename, int x, int y); + + bool displayIndicator(); +private: + Common::String _loadImageName; + Common::String _saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + BaseSurface *_saveLoadImage; + + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + bool _loadInProgress; + bool _indicatorDisplay; + int _indicatorProgress; protected: uint32 _clipperWindow; diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp new file mode 100644 index 0000000000..aea474fd44 --- /dev/null +++ b/engines/wintermute/base/saveload.cpp @@ -0,0 +1,198 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/base/saveload.h" +#include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/base_game.h" // Temporary +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "common/savefile.h" +#include "common/config-manager.h" + +namespace WinterMute { + +bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { + gameRef->LOG(0, "Loading game '%s'...", filename.c_str()); + + bool ret; + + gameRef->_renderer->initSaveLoad(false); + + gameRef->_loadInProgress = true; + BasePersistenceManager *pm = new BasePersistenceManager(); + if (DID_SUCCEED(ret = pm->initLoad(filename))) { + //if (DID_SUCCEED(ret = cleanup())) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(gameRef, pm))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(gameRef, pm))) { + // data initialization after load + SaveLoad::initAfterLoad(); + + gameRef->applyEvent("AfterLoad", true); + + gameRef->displayContent(true, false); + //_renderer->flip(); + } + } + } + + delete pm; + gameRef->_loadInProgress = false; + + gameRef->_renderer->endSaveLoad(); + + //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); + // AdGame: + if (DID_SUCCEED(ret)) { + SystemClassRegistry::getInstance()->enumInstances(SaveLoad::afterLoadRegion, "AdRegion", NULL); + } + return ret; +} + +bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef) { + Common::String filename = SaveLoad::getSaveSlotFilename(slot); + + gameRef->LOG(0, "Saving game '%s'...", filename.c_str()); + + gameRef->applyEvent("BeforeSave", true); + + bool ret; + + BasePersistenceManager *pm = new BasePersistenceManager(); + if (DID_SUCCEED(ret = pm->initSave(desc))) { + gameRef->_renderer->initSaveLoad(true, quickSave); // TODO: The original code inited the indicator before the conditionals + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(gameRef, pm, quickSave))) { + if (DID_SUCCEED(ret = pm->saveFile(filename))) { + ConfMan.setInt("most_recent_saveslot", slot); + } + } + } + } + + delete pm; + + gameRef->_renderer->endSaveLoad(); + + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool SaveLoad::initAfterLoad() { + SystemClassRegistry::getInstance()->enumInstances(afterLoadRegion, "BaseRegion", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSubFrame, "BaseSubFrame", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadSound, "BaseSound", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadFont, "BaseFontTT", NULL); + SystemClassRegistry::getInstance()->enumInstances(afterLoadScript, "ScScript", NULL); + // AdGame: + SystemClassRegistry::getInstance()->enumInstances(afterLoadScene, "AdScene", NULL); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadScene(void *scene, void *data) { + ((AdScene *)scene)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadRegion(void *region, void *data) { + ((BaseRegion *)region)->createRegion(); +} + + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadSubFrame(void *subframe, void *data) { + ((BaseSubFrame *)subframe)->setSurfaceSimple(); +} + + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadSound(void *sound, void *data) { + ((BaseSound *)sound)->setSoundSimple(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadFont(void *font, void *data) { + ((BaseFont *)font)->afterLoad(); +} + +////////////////////////////////////////////////////////////////////////// +void SaveLoad::afterLoadScript(void *script, void *data) { + ((ScScript *)script)->afterLoad(); +} + +Common::String SaveLoad::getSaveSlotFilename(int slot) { + BasePersistenceManager *pm = new BasePersistenceManager(); + Common::String filename = pm->getFilenameForSlot(slot); + delete pm; + debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); + return filename; +} + +bool SaveLoad::getSaveSlotDescription(int slot, char *buffer) { + buffer[0] = '\0'; + + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + if (!pm) { + return false; + } + + if (!(pm->initLoad(filename))) { + delete pm; + return false; + } + + strcpy(buffer, pm->_savedDescription); + delete pm; + + return true; +} + +bool SaveLoad::isSaveSlotUsed(int slot) { + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + bool ret = pm->getSaveExists(slot); + delete pm; + return ret; +} + +bool SaveLoad::emptySaveSlot(int slot) { + Common::String filename = getSaveSlotFilename(slot); + BasePersistenceManager *pm = new BasePersistenceManager(); + g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + delete pm; + return true; +} + + +} // end of namespace WinterMute diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h new file mode 100644 index 0000000000..59cdceb038 --- /dev/null +++ b/engines/wintermute/base/saveload.h @@ -0,0 +1,57 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SAVEGAME_H +#define WINTERMUTE_SAVEGAME_H + +#include "common/str.h" + +namespace WinterMute { +class BaseGame; +class SaveLoad { +public: + static bool emptySaveSlot(int slot); + static bool isSaveSlotUsed(int slot); + static bool getSaveSlotDescription(int slot, char *buffer); + static Common::String getSaveSlotFilename(int slot); + + static bool loadGame(const Common::String &filename, BaseGame *gameRef); + static bool saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef); + static bool initAfterLoad(); + static void afterLoadScene(void *scene, void *data); + static void afterLoadRegion(void *region, void *data); +private: + static void afterLoadSubFrame(void *subframe, void *data); + static void afterLoadSound(void *sound, void *data); + static void afterLoadFont(void *font, void *data); + static void afterLoadScript(void *script, void *data); +}; + +} // end of namespace WinterMute + +#endif -- cgit v1.2.3 From 43611724441e880b7283ae195d40f5e63aa6affd Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 19:41:44 +0200 Subject: WINTERMUTE: Redraw ONLY the indicator when saving/loading. --- engines/wintermute/base/base_sub_frame.cpp | 7 +------ engines/wintermute/base/gfx/base_renderer.cpp | 14 ++++++++++++-- engines/wintermute/base/gfx/base_renderer.h | 8 +++++++- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 7 ++++++- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 1 + 5 files changed, 27 insertions(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 006f15fa2c..7f527392dc 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -365,12 +365,6 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { BaseScriptable::persist(persistMgr); - if (persistMgr->getIsSaving()) { - getRect(); // To make sure it gets updated if it was never loaded. - } else { - _wantsDefaultRect = false; - } - persistMgr->transfer(TMEMBER(_2DOnly)); persistMgr->transfer(TMEMBER(_3DOnly)); persistMgr->transfer(TMEMBER(_alpha)); @@ -379,6 +373,7 @@ bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_hotspotX)); persistMgr->transfer(TMEMBER(_hotspotY)); persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_wantsDefaultRect)); persistMgr->transfer(TMEMBER(_surfaceFilename)); persistMgr->transfer(TMEMBER(_cKDefault)); diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index cd065f3436..5d81c44c25 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -52,6 +52,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _indicatorY = -1; _indicatorWidth = -1; _indicatorHeight = 8; + _indicatorWidthDrawn = 0; _loadImageName = ""; _saveImageName = ""; @@ -103,7 +104,10 @@ void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 colo } void BaseRenderer::setIndicatorVal(int value) { + bool redisplay = (_indicatorProgress != value); _indicatorProgress = value; + if (redisplay) + displayIndicator(); } void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { @@ -153,6 +157,7 @@ void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { void BaseRenderer::endSaveLoad() { _loadInProgress = false; _indicatorDisplay = false; + _indicatorWidthDrawn = 0; delete _saveLoadImage; _saveLoadImage = NULL; @@ -338,7 +343,7 @@ void BaseRenderer::addRectToList(BaseActiveRect *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::displayIndicator() { - if (!_indicatorDisplay) { + if (!_indicatorDisplay || !_indicatorProgress) { return STATUS_OK; } if (_saveLoadImage) { @@ -355,11 +360,16 @@ bool BaseRenderer::displayIndicator() { return STATUS_OK; } setupLines(); + int curWidth = (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)); for (int i = 0; i < _indicatorHeight; i++) { - drawLine(_indicatorX, _indicatorY + i, _indicatorX + (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)), _indicatorY + i, _indicatorColor); + drawLine(_indicatorX, _indicatorY + i, _indicatorX + curWidth, _indicatorY + i, _indicatorColor); } setup2D(); + _indicatorWidthDrawn = curWidth; + if (_indicatorWidthDrawn) { + indicatorFlip(); + } return STATUS_OK; } diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index a36a3ca9c0..49b5e187eb 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -110,6 +110,11 @@ public: * @return true if successfull, false on error. */ virtual bool flip() = 0; + /** + * Special flip for the indicator drawn during save/load + * essentially, just copies the region defined by the _indicator-variables. + */ + virtual bool indicatorFlip() = 0; virtual void initLoop(); virtual bool setup2D(bool force = false); virtual bool setupLines(); @@ -179,7 +184,7 @@ public: void setSaveImage(const char *filename, int x, int y); bool displayIndicator(); -private: +protected: Common::String _loadImageName; Common::String _saveImageName; int _saveImageX; @@ -188,6 +193,7 @@ private: int _loadImageY; BaseSurface *_saveLoadImage; + int _indicatorWidthDrawn; uint32 _indicatorColor; int _indicatorX; int _indicatorY; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index fa0663dc65..bc952b0b36 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -185,7 +185,12 @@ void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { _colorMod = BS_ARGB(alpha, r, g, b); } -////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::indicatorFlip() { + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_indicatorX, _indicatorY), _renderSurface->pitch, _indicatorX, _indicatorY, _indicatorWidthDrawn, _indicatorHeight); + g_system->updateScreen(); + return STATUS_OK; +} + bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 2b6b5943c2..08fd6cf9ab 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -66,6 +66,7 @@ public: bool initRenderer(int width, int height, bool windowed); bool flip(); + virtual bool indicatorFlip(); bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); Graphics::PixelFormat getPixelFormat() const; void fade(uint16 alpha); -- cgit v1.2.3 From 18409fe5c03264ca74902e263f80523692f76a77 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 19:43:55 +0200 Subject: WINTERMUTE: Fix a memory leak in BaseScriptHolder --- engines/wintermute/base/base_script_holder.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index 19bd82f2b0..b40647dc7b 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -287,9 +287,10 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { const char *name = getName(); persistMgr->transfer(TMEMBER(name)); } else { - const char *name; + char *name; persistMgr->transfer(TMEMBER(name)); setName(name); + delete[] name; } _scripts.persist(persistMgr); -- cgit v1.2.3 From 6330c1e5fdced523e1e245eac67754cd2b519c32 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 20:39:04 +0200 Subject: WINTERMUTE: Fix a few memory-leaks --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index c449f6471c..9f0e605f39 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -139,6 +139,7 @@ bool BaseSurfaceOSystem::finishLoad() { // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + _surface->free(); delete _surface; if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); @@ -412,6 +413,7 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { _loaded = true; + _surface->free(); _surface->copyFrom(surface); _hasAlpha = hasAlpha; BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); -- cgit v1.2.3 From 5a1fae94fb1e2d9f5caa21b7c9bad1457cbfc807 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 30 Jul 2012 23:46:46 +0200 Subject: WINTERMUTE: Implement load from GMM. --- engines/wintermute/base/base_persistence_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index b6cd59328d..4236203292 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -89,7 +89,7 @@ BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool dele ////////////////////////////////////////////////////////////////////////// BasePersistenceManager::~BasePersistenceManager() { cleanup(); - if (_deleteSingleton) + if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) BaseEngine::destroy(); } -- cgit v1.2.3 From e32b79bff1260f8d2853404f750acc22209a323b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 13:32:26 +0200 Subject: WINTERMUTE: Save the random-seed as well. --- engines/wintermute/base/base_engine.cpp | 7 +++++++ engines/wintermute/base/base_engine.h | 9 +++++++-- engines/wintermute/base/saveload.cpp | 5 +++++ 3 files changed, 19 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 8e3e6cf0e0..04088d299e 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -40,11 +40,14 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; _gameRef = NULL; + _rnd = NULL; _gameId = ""; } void BaseEngine::init() { _fileManager = new BaseFileManager(); + // Don't forget to register your random source + _rnd = new Common::RandomSource("WinterMute"); } BaseEngine::~BaseEngine() { @@ -77,4 +80,8 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { } } +uint32 BaseEngine::randInt(int from, int to) { + return _rnd->getRandomNumberRng(from, to); +} + } // end of namespace WinterMute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index b9dcfcb845..253ef048ab 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -29,8 +29,9 @@ #ifndef WINTERMUTE_BASE_ENGINE_H #define WINTERMUTE_BASE_ENGINE_H - #include "common/str.h" - #include "common/singleton.h" +#include "common/str.h" +#include "common/singleton.h" +#include "common/random.h" namespace WinterMute { @@ -42,12 +43,16 @@ class BaseEngine : public Common::Singleton { BaseFileManager *_fileManager; Common::String _gameId; BaseGame *_gameRef; + // We need random numbers + Common::RandomSource *_rnd; public: BaseEngine(); ~BaseEngine(); static void createInstance(const Common::String &gameid); void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } + Common::RandomSource *getRandomSource() { return _rnd; } + uint32 randInt(int from, int to); BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } static void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index aea474fd44..5b51749b43 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/wintermute.h" #include "engines/wintermute/base/saveload.h" #include "engines/wintermute/ad/ad_scene.h" +#include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" // Temporary #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_sub_frame.h" @@ -54,6 +55,9 @@ bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { //if (DID_SUCCEED(ret = cleanup())) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadTable(gameRef, pm))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->loadInstances(gameRef, pm))) { + // Restore random-seed: + BaseEngine::instance().getRandomSource()->setSeed(pm->getDWORD()); + // data initialization after load SaveLoad::initAfterLoad(); @@ -92,6 +96,7 @@ bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *ga gameRef->_renderer->initSaveLoad(true, quickSave); // TODO: The original code inited the indicator before the conditionals if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveTable(gameRef, pm, quickSave))) { if (DID_SUCCEED(ret = SystemClassRegistry::getInstance()->saveInstances(gameRef, pm, quickSave))) { + pm->putDWORD(BaseEngine::instance().getRandomSource()->getSeed()); if (DID_SUCCEED(ret = pm->saveFile(filename))) { ConfMan.setInt("most_recent_saveslot", slot); } -- cgit v1.2.3 From 6b159d71ab212feb4e93bae412a7352ead59241b Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 13:51:22 +0200 Subject: WINTERMUTE: Remove g_wintermute. --- engines/wintermute/base/base_engine.cpp | 6 ++++++ engines/wintermute/base/base_engine.h | 4 ++++ engines/wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/saveload.cpp | 2 +- engines/wintermute/base/sound/base_sound_manager.cpp | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 04088d299e..c31777c866 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -30,6 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/wintermute.h" +#include "engines/wintermute/system/sys_class_registry.h" #include "common/system.h" namespace Common { DECLARE_SINGLETON(WinterMute::BaseEngine); @@ -40,6 +41,7 @@ namespace WinterMute { BaseEngine::BaseEngine() { _fileManager = NULL; _gameRef = NULL; + _classReg = NULL; _rnd = NULL; _gameId = ""; } @@ -48,10 +50,14 @@ void BaseEngine::init() { _fileManager = new BaseFileManager(); // Don't forget to register your random source _rnd = new Common::RandomSource("WinterMute"); + _classReg = new SystemClassRegistry(); + _classReg->registerClasses(); } BaseEngine::~BaseEngine() { delete _fileManager; + delete _rnd; + delete _classReg; } void BaseEngine::createInstance(const Common::String &gameid) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 253ef048ab..04199715af 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -38,6 +38,7 @@ namespace WinterMute { class BaseFileManager; class BaseRegistry; class BaseGame; +class SystemClassRegistry; class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; @@ -45,6 +46,7 @@ class BaseEngine : public Common::Singleton { BaseGame *_gameRef; // We need random numbers Common::RandomSource *_rnd; + SystemClassRegistry *_classReg; public: BaseEngine(); ~BaseEngine(); @@ -53,6 +55,8 @@ public: Common::RandomSource *getRandomSource() { return _rnd; } uint32 randInt(int from, int to); + + SystemClassRegistry *getClassRegistry(){ return _classReg; } BaseGame *getGameRef() { return _gameRef; } BaseFileManager *getFileManager() { return _fileManager; } static void LOG(bool res, const char *fmt, ...); diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 4236203292..e6ed5cb7e0 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -371,7 +371,7 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); - Common::SaveFileManager *saveMan = g_wintermute->getSaveFileMan(); + Common::SaveFileManager *saveMan = ((WinterMuteEngine *)g_engine)->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(filename); file->write(prefixBuffer, prefixSize); file->write(buffer, bufferSize); diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index 5b51749b43..fe987c0b2a 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -194,7 +194,7 @@ bool SaveLoad::isSaveSlotUsed(int slot) { bool SaveLoad::emptySaveSlot(int slot) { Common::String filename = getSaveSlotFilename(slot); BasePersistenceManager *pm = new BasePersistenceManager(); - g_wintermute->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + ((WinterMuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return true; } diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index ed475ec31c..95b7d040ab 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -184,7 +184,7 @@ bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { case Audio::Mixer::kPlainSoundType: error("Plain sound type shouldn't be used in WME"); } - g_wintermute->syncSoundSettings(); + g_engine->syncSoundSettings(); return STATUS_OK; } -- cgit v1.2.3 From 52aeaf4ecee11074a3f1fe303aef862f1b6ac028 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 14:06:42 +0200 Subject: WINTERMUTE: Move dcscript.h into the proper folder. --- engines/wintermute/base/scriptables/dcscript.h | 141 +++++++++++++++++++++ engines/wintermute/base/scriptables/script.h | 2 +- engines/wintermute/base/scriptables/script_value.h | 2 +- 3 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 engines/wintermute/base/scriptables/dcscript.h (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h new file mode 100644 index 0000000000..9610ebf94c --- /dev/null +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -0,0 +1,141 @@ +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCSCRIPT_H +#define WINTERMUTE_DCSCRIPT_H + +namespace WinterMute { + +#define SCRIPT_MAGIC 0xDEC0ADDE +#define SCRIPT_VERSION 0x0102 + +// value types +typedef enum { + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF +} TValType; + + +// script states +typedef enum { + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED +} TScriptState; + +// opcodes +typedef enum { + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR +} TInstruction; + +// external data types +typedef enum { + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER +} TExternalType; + + +// call types +typedef enum { + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL +} TCallType; + +// element types +typedef enum { + ELEMENT_STRING = 0 +} TElementType; + +} // end of namespace WinterMute + +#endif diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 1cd5c2dc1e..9f49fac994 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" namespace WinterMute { diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index 8fced06972..c8d04168b3 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/persistent.h" -#include "engines/wintermute/dcscript.h" // Added by ClassView +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "common/str.h" namespace WinterMute { -- cgit v1.2.3 From 3abccb2e339144191553555756e3ff43222c3a36 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 14:56:06 +0200 Subject: WINTERMUTE: Change PixelFormat to ARGB (same as Sword25) Mainly a workaround for the OpenGL-backend. --- engines/wintermute/base/font/base_font_truetype.cpp | 4 ++-- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index b80bbdc41d..00b522c826 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -261,7 +261,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); if (_deletableFont) { // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8, 0)); + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); } else { // We are using a fallback, they can't do 32bpp surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); } @@ -274,7 +274,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, } BaseSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 24, 16, 8 , 0)); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); retSurface->putSurface(*convertedSurface, true); convertedSurface->free(); surface->free(); diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index bc952b0b36..f12478f7b3 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -153,7 +153,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _windowed = !ConfMan.getBool("fullscreen"); - Graphics::PixelFormat format(4, 8, 8, 8, 8, 24, 16, 8, 0); + Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); g_system->beginGFXTransaction(); g_system->initSize(_width, _height, &format); OSystem::TransactionError gfxError = g_system->endGFXTransaction(); -- cgit v1.2.3 From 8883a9ffd587de0cfca9a42925d2f1071d4ccb35 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:04:47 +0200 Subject: WINTERMUTE: Optimize blitting (Do opaque blits for opaque images, and do fill with memcpy) --- .../base/gfx/osystem/base_render_osystem.cpp | 40 ++++++++++++++++++---- .../base/gfx/osystem/base_render_osystem.h | 6 ++-- .../base/gfx/osystem/base_surface_osystem.cpp | 6 ++-- 3 files changed, 40 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index f12478f7b3..3ec04b1ab1 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -40,8 +40,8 @@ namespace WinterMute { -RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(true) { +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { _colorMod = 0; _mirror = TransparentSurface::FLIP_NONE; if (mirrorX) { @@ -97,6 +97,7 @@ BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { ////////////////////////////////////////////////////////////////////////// BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { _renderSurface = new Graphics::Surface(); + _blankSurface = new Graphics::Surface(); _drawNum = 1; _needsFlip = true; @@ -111,6 +112,8 @@ BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { BaseRenderOSystem::~BaseRenderOSystem() { _renderSurface->free(); delete _renderSurface; + _blankSurface->free(); + delete _blankSurface; } ////////////////////////////////////////////////////////////////////////// @@ -166,6 +169,8 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { g_system->showMouse(false); _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->fillRect(Common::Rect(0, 0, g_system->getHeight(), g_system->getWidth()), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); _active = true; _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); @@ -217,6 +222,11 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_OK; } if (!rect) { + if (r == 0 && g == 0 && b == 0) { + // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. + memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); + return STATUS_OK; + } rect = &_renderRect; } // TODO: This doesn't work with dirty rects @@ -281,12 +291,12 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { return _renderSurface->format; } -void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY) { +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); // HINT: The surface-data contains other info than it should. // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(renderTicket.getSurface(), &renderTicket._srcRect, &renderTicket._dstRect, NULL, renderTicket._mirror); + drawFromSurface(&renderTicket, NULL); return; } // Skip rects that are completely outside the screen: @@ -295,7 +305,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S } if (owner) { // Fade-tickets are owner-less - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); compare._colorMod = _colorMod; RenderQueueIterator it; for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { @@ -306,7 +316,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S } } } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY); + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); ticket->_colorMod = _colorMod; drawFromTicket(ticket); } @@ -445,6 +455,22 @@ void BaseRenderOSystem::drawTickets() { } // Replacement for SDL2's SDL_RenderCopy +void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect) { + TransparentSurface src(*ticket->getSurface(), false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(ticket->getSurface()->w); + clipRect->setHeight(ticket->getSurface()->h); + } + + src._enableAlphaBlit = ticket->_hasAlpha; + src.blit(*_renderSurface, ticket->_dstRect.left, ticket->_dstRect.top, ticket->_mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) { + delete clipRect; + } +} void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { TransparentSurface src(*surf, false); bool doDelete = false; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 08fd6cf9ab..070ddf9241 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -39,7 +39,7 @@ class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; public: - RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false); + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false); RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} ~RenderTicket(); const Graphics::Surface *getSurface() { return _surface; } @@ -97,11 +97,12 @@ public: return _ratioY; } - void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY); + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false); BaseSurface *createSurface(); private: void addDirtyRect(const Common::Rect &rect); void drawTickets(); + void drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect); void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); typedef Common::List::iterator RenderQueueIterator; Common::Rect *_dirtyRect; @@ -110,6 +111,7 @@ private: uint32 _drawNum; Common::Rect _renderRect; Graphics::Surface *_renderSurface; + Graphics::Surface *_blankSurface; int _borderLeft; int _borderTop; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 9f0e605f39..7845390871 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -396,17 +396,17 @@ bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, flo // But no checking is in place for that yet. // TODO: Optimize by not doing alpha-blits if we lack or disable alpha -/* bool hasAlpha; + bool hasAlpha; if (_hasAlpha && !alphaDisable) { hasAlpha = true; } else { hasAlpha = false; - }*/ + } if (alphaDisable) { warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); } - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY); + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); return STATUS_OK; } -- cgit v1.2.3 From 688f792c9f280a3cf1bb5b30149a05669ba4bfb5 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:28:44 +0200 Subject: WINTERMUTE: Cache scaled images, to avoid having to rescale every frame. --- .../base/gfx/osystem/base_render_osystem.cpp | 35 ++++++++++++++++------ 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 3ec04b1ab1..9cc94449ff 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -199,6 +199,20 @@ bool BaseRenderOSystem::indicatorFlip() { bool BaseRenderOSystem::flip() { if (!_disableDirtyRects) { drawTickets(); + } else { + // Clear the scale-buffered tickets that wasn't reused. + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false) { + RenderTicket *ticket = *it; + addDirtyRect((*it)->_dstRect); + it = _renderQueue.erase(it); + delete ticket; + } else { + (*it)->_wantsDraw = false; + it++; + } + } } if (_needsFlip || _disableDirtyRects) { if (_disableDirtyRects) { @@ -292,13 +306,6 @@ Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { } void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { - if (_disableDirtyRects) { - RenderTicket renderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - // HINT: The surface-data contains other info than it should. - // drawFromSurface(renderTicket._surface, srcRect, dstRect, NULL, mirrorX, mirrorY); - drawFromSurface(&renderTicket, NULL); - return; - } // Skip rects that are completely outside the screen: if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { return; @@ -311,14 +318,24 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { (*it)->_colorMod = _colorMod; - drawFromTicket(*it); + if (_disableDirtyRects) { + drawFromSurface(*it, NULL); + } else { + drawFromTicket(*it); + } return; } } } RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); ticket->_colorMod = _colorMod; - drawFromTicket(ticket); + if (!_disableDirtyRects) { + drawFromTicket(ticket); + } else { + ticket->_wantsDraw = true; + _renderQueue.push_back(ticket); + drawFromSurface(ticket, NULL); + } } void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { -- cgit v1.2.3 From d95a2ddef84bb786979affddd95074da79032560 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 7 Aug 2012 16:49:20 +0200 Subject: WINTERMUTE: Use only one scaler for blitting, the faster one. --- engines/wintermute/base/gfx/base_image.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 9203b62734..c1b6636237 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -120,7 +120,7 @@ bool BaseImage::resize(int newWidth, int newHeight) { delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); temp.free(); return true; } @@ -224,7 +224,7 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { delete _deletableSurface; _deletableSurface = NULL; } - _surface = _deletableSurface = temp.scaleSafe((uint16)newWidth, (uint16)newHeight); + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); return true; } -- cgit v1.2.3 From c422ae9d8a90aeb63da3e3fdf521323fe6769828 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:30:07 +0200 Subject: WINTERMUTE: Get rid of strncpy+manual termination. --- engines/wintermute/base/base_parser.cpp | 6 ++---- engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp | 3 +-- 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 1b39b55768..75268f6483 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -386,8 +386,7 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { in++; const char *in2 = strchr(in, '\''); if (in2) { - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; + Common::strlcpy(a, in, (int)(in2 - in) + 1); in = in2 + 1; } else { strcpy(a, in); @@ -395,8 +394,7 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { } } else { const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - strncpy(a, in, (int)(in2 - in)); - a[(int)(in2 - in)] = 0; + Common::strlcpy(a, in, (int)(in2 - in) + 1); in = in2; } in += strspn(in, " \t\n\f"); diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index afe5e65467..557d9b9b57 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -261,8 +261,7 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt stack->pushNULL(); } else { char *str = new char[length + 1]; - strncpy(str, (const char *)_buffer + start, length); - str[length] = '\0'; + Common::strlcpy(str, (const char *)_buffer + start, length + 1); stack->pushString(str); delete[] str; } -- cgit v1.2.3 From 9a5f363972759158a66b5c7c34726db4318b8092 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 02:34:06 +0200 Subject: WINTERMUTE: Make missing-file warnings a debugC The sound-system attempts to open files in various formats, some of which may not exist, no reason for these to fill the console with output. --- engines/wintermute/base/base_file_manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index d5071ccf48..c17a456f11 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -317,7 +317,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - warning("BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + debugC(kWinterMuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } -- cgit v1.2.3 From 5b3389672b6442dde3c32978afe912a07ed40c07 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 11 Aug 2012 03:15:51 +0200 Subject: WINTERMUTE: Silence a few float-cast warnings. --- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 9cc94449ff..dbcb329d64 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -573,23 +573,23 @@ Rect32 BaseRenderOSystem::getViewPort() { ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { - rect->left = MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); - rect->top = MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); - rect->setWidth(MathUtil::roundUp(rect->width() * _ratioX)); - rect->setHeight(MathUtil::roundUp(rect->height() * _ratioY)); + rect->left = (int16)MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); + rect->top = (int16)MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); + rect->setWidth((int16)MathUtil::roundUp(rect->width() * _ratioX)); + rect->setHeight((int16)MathUtil::roundUp(rect->height() * _ratioY)); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointFromScreen(Point32 *point) { - point->x = point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left; - point->y = point->y / _ratioY - _borderTop / _ratioY + _renderRect.top; + point->x = (int16)(point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left); + point->y = (int16)(point->y / _ratioY - _borderTop / _ratioY + _renderRect.top); } ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::pointToScreen(Point32 *point) { - point->x = MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; - point->y = MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; + point->x = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 30f35c4c3fce92cbdad38e5bfdeebc4e282d7b2e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 01:13:16 +0200 Subject: WINTERMUTE: Use 64k-tables for alpha-blitting. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index dbcb329d64..ab4e690458 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -114,6 +114,7 @@ BaseRenderOSystem::~BaseRenderOSystem() { delete _renderSurface; _blankSurface->free(); delete _blankSurface; + TransparentSurface::destroyLookup(); } ////////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From c1b5626bca1e0e08316353f1ead00ed763cd5380 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 01:14:05 +0200 Subject: WINTERMUTE: Apply color-key to RGB-images, and upconvert them to RGBA. --- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 7845390871..400bb1de41 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -149,8 +149,12 @@ bool BaseSurfaceOSystem::finishLoad() { _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); TransparentSurface trans(*_surface); trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } else if (image->getSurface()->format.bytesPerPixel == 4 && image->getSurface()->format != g_system->getScreenFormat()) { + } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + if (image->getSurface()->format.bytesPerPixel == 3) { + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } } else { _surface = new Graphics::Surface(); _surface->copyFrom(*image->getSurface()); -- cgit v1.2.3 From 61ddc77804279a28f3dc8ebef4c226c78816d689 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 02:13:26 +0200 Subject: WINTERMUTE: Use the correct DPI for TTF-fonts, and don't display overshooting lines. --- engines/wintermute/base/font/base_font_truetype.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 00b522c826..4fa5ac08ce 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -248,6 +248,13 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, Common::Array lines; _font->wordWrapText(text, width, lines); + while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) { + lines.pop_back(); + } + if (lines.size() == 0) { + return NULL; + } + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; if (align == TAL_LEFT) { alignment = Graphics::kTextAlignLeft; @@ -553,7 +560,7 @@ bool BaseFontTT::initFont() { if (file) { #ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, _fontHeight * 4 / 3); // Compensate for the difference in dpi (96 vs 72). + _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). _font = _deletableFont; #endif } -- cgit v1.2.3 From 4168b50fc3951cb716597ed8bf559d883828ff1a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 02:19:41 +0200 Subject: WINTERMUTE: Remove BPkgFile, as wrapCompressedStream can handle that job now. --- engines/wintermute/base/file/base_file_entry.cpp | 32 +----------------------- 1 file changed, 1 insertion(+), 31 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index da1bfa7ac8..a08d55db43 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -33,31 +33,6 @@ #include "common/zlib.h" namespace WinterMute { -// HACK: wrapCompressedStream might set the size to 0, so we need a way to override it. -class CBPkgFile : public Common::SeekableReadStream { - uint32 _size; - Common::SeekableReadStream *_stream; -public: - CBPkgFile(Common::SeekableReadStream *stream, uint32 knownLength) : _size(knownLength), _stream(stream) {} - virtual ~CBPkgFile() { - delete _stream; - } - virtual uint32 read(void *dataPtr, uint32 dataSize) { - return _stream->read(dataPtr, dataSize); - } - virtual bool eos() const { - return _stream->eos(); - } - virtual int32 pos() const { - return _stream->pos(); - } - virtual int32 size() const { - return _size; - } - virtual bool seek(int32 offset, int whence = SEEK_SET) { - return _stream->seek(offset, whence); - } -}; Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); @@ -65,18 +40,13 @@ Common::SeekableReadStream *BaseFileEntry::createReadStream() const { return NULL; } - bool compressed = (_compressedLength != 0); if (compressed) { - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES)); - // file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // TODO: Uncomment on merge + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // } else { file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); } - if (file->size() == 0) { // TODO: Cleanup on next merge (CBPkgFile is just a placeholder for the commented out wrap above. - file = new CBPkgFile(file, _length); - } file->seek(0); -- cgit v1.2.3 From fed19cb66ae5b56dd7dc81b90edd5a0d15986678 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 03:42:30 +0200 Subject: WINTERMUTE: WinterMute -> Wintermute --- engines/wintermute/base/base.cpp | 4 ++-- engines/wintermute/base/base.h | 4 ++-- engines/wintermute/base/base_active_rect.cpp | 4 ++-- engines/wintermute/base/base_active_rect.h | 4 ++-- engines/wintermute/base/base_dynamic_buffer.cpp | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 4 ++-- engines/wintermute/base/base_engine.cpp | 10 ++++----- engines/wintermute/base/base_engine.h | 6 +++--- engines/wintermute/base/base_fader.cpp | 4 ++-- engines/wintermute/base/base_fader.h | 4 ++-- engines/wintermute/base/base_file_manager.cpp | 24 +++++++++++----------- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/base_frame.cpp | 4 ++-- engines/wintermute/base/base_frame.h | 4 ++-- engines/wintermute/base/base_game.cpp | 8 ++++---- engines/wintermute/base/base_game.h | 4 ++-- engines/wintermute/base/base_keyboard_state.cpp | 4 ++-- engines/wintermute/base/base_keyboard_state.h | 4 ++-- engines/wintermute/base/base_named_object.cpp | 4 ++-- engines/wintermute/base/base_named_object.h | 4 ++-- engines/wintermute/base/base_object.cpp | 4 ++-- engines/wintermute/base/base_object.h | 4 ++-- engines/wintermute/base/base_parser.cpp | 4 ++-- engines/wintermute/base/base_parser.h | 4 ++-- .../wintermute/base/base_persistence_manager.cpp | 20 +++++++++--------- engines/wintermute/base/base_persistence_manager.h | 4 ++-- engines/wintermute/base/base_point.cpp | 4 ++-- engines/wintermute/base/base_point.h | 4 ++-- engines/wintermute/base/base_quick_msg.cpp | 4 ++-- engines/wintermute/base/base_quick_msg.h | 4 ++-- engines/wintermute/base/base_region.cpp | 4 ++-- engines/wintermute/base/base_region.h | 4 ++-- engines/wintermute/base/base_save_thumb_helper.cpp | 4 ++-- engines/wintermute/base/base_save_thumb_helper.h | 4 ++-- engines/wintermute/base/base_script_holder.cpp | 4 ++-- engines/wintermute/base/base_script_holder.h | 4 ++-- engines/wintermute/base/base_scriptable.cpp | 4 ++-- engines/wintermute/base/base_scriptable.h | 4 ++-- engines/wintermute/base/base_sprite.cpp | 4 ++-- engines/wintermute/base/base_sprite.h | 4 ++-- engines/wintermute/base/base_string_table.cpp | 4 ++-- engines/wintermute/base/base_string_table.h | 4 ++-- engines/wintermute/base/base_sub_frame.cpp | 4 ++-- engines/wintermute/base/base_sub_frame.h | 4 ++-- engines/wintermute/base/base_surface_storage.cpp | 4 ++-- engines/wintermute/base/base_surface_storage.h | 4 ++-- .../wintermute/base/base_transition_manager.cpp | 4 ++-- engines/wintermute/base/base_transition_manager.h | 4 ++-- engines/wintermute/base/base_viewport.cpp | 4 ++-- engines/wintermute/base/base_viewport.h | 4 ++-- engines/wintermute/base/file/base_disk_file.cpp | 4 ++-- engines/wintermute/base/file/base_disk_file.h | 4 ++-- engines/wintermute/base/file/base_file.cpp | 4 ++-- engines/wintermute/base/file/base_file.h | 4 ++-- engines/wintermute/base/file/base_file_entry.cpp | 4 ++-- engines/wintermute/base/file/base_file_entry.h | 4 ++-- engines/wintermute/base/file/base_package.cpp | 12 +++++------ engines/wintermute/base/file/base_package.h | 4 ++-- engines/wintermute/base/file/base_resources.cpp | 4 ++-- engines/wintermute/base/file/base_resources.h | 4 ++-- .../wintermute/base/file/base_save_thumb_file.cpp | 4 ++-- .../wintermute/base/file/base_save_thumb_file.h | 4 ++-- engines/wintermute/base/file/dcpackage.h | 4 ++-- engines/wintermute/base/font/base_font.cpp | 4 ++-- engines/wintermute/base/font/base_font.h | 4 ++-- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.h | 4 ++-- engines/wintermute/base/font/base_font_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font_storage.h | 4 ++-- .../wintermute/base/font/base_font_truetype.cpp | 8 ++++---- engines/wintermute/base/font/base_font_truetype.h | 4 ++-- engines/wintermute/base/gfx/base_image.cpp | 6 +++--- engines/wintermute/base/gfx/base_image.h | 4 ++-- engines/wintermute/base/gfx/base_renderer.cpp | 4 ++-- engines/wintermute/base/gfx/base_renderer.h | 4 ++-- engines/wintermute/base/gfx/base_surface.cpp | 4 ++-- engines/wintermute/base/gfx/base_surface.h | 4 ++-- .../base/gfx/osystem/base_render_osystem.cpp | 4 ++-- .../base/gfx/osystem/base_render_osystem.h | 4 ++-- .../base/gfx/osystem/base_surface_osystem.cpp | 4 ++-- .../base/gfx/osystem/base_surface_osystem.h | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.h | 4 ++-- engines/wintermute/base/particles/part_force.cpp | 4 ++-- engines/wintermute/base/particles/part_force.h | 4 ++-- .../wintermute/base/particles/part_particle.cpp | 4 ++-- engines/wintermute/base/particles/part_particle.h | 4 ++-- engines/wintermute/base/saveload.cpp | 8 ++++---- engines/wintermute/base/saveload.h | 4 ++-- engines/wintermute/base/scriptables/dcscript.h | 4 ++-- engines/wintermute/base/scriptables/script.cpp | 4 ++-- engines/wintermute/base/scriptables/script.h | 4 ++-- .../wintermute/base/scriptables/script_engine.cpp | 4 ++-- .../wintermute/base/scriptables/script_engine.h | 4 ++-- .../base/scriptables/script_ext_array.cpp | 4 ++-- .../wintermute/base/scriptables/script_ext_array.h | 4 ++-- .../base/scriptables/script_ext_date.cpp | 4 ++-- .../wintermute/base/scriptables/script_ext_date.h | 4 ++-- .../base/scriptables/script_ext_file.cpp | 4 ++-- .../wintermute/base/scriptables/script_ext_file.h | 4 ++-- .../base/scriptables/script_ext_math.cpp | 4 ++-- .../wintermute/base/scriptables/script_ext_math.h | 4 ++-- .../base/scriptables/script_ext_mem_buffer.cpp | 4 ++-- .../base/scriptables/script_ext_mem_buffer.h | 4 ++-- .../base/scriptables/script_ext_object.cpp | 4 ++-- .../base/scriptables/script_ext_object.h | 4 ++-- .../base/scriptables/script_ext_string.cpp | 4 ++-- .../base/scriptables/script_ext_string.h | 4 ++-- .../wintermute/base/scriptables/script_stack.cpp | 4 ++-- engines/wintermute/base/scriptables/script_stack.h | 4 ++-- .../wintermute/base/scriptables/script_value.cpp | 4 ++-- engines/wintermute/base/scriptables/script_value.h | 4 ++-- engines/wintermute/base/sound/base_sound.cpp | 4 ++-- engines/wintermute/base/sound/base_sound.h | 4 ++-- .../wintermute/base/sound/base_sound_buffer.cpp | 6 +++--- engines/wintermute/base/sound/base_sound_buffer.h | 4 ++-- .../wintermute/base/sound/base_sound_manager.cpp | 4 ++-- engines/wintermute/base/sound/base_sound_manager.h | 4 ++-- 118 files changed, 270 insertions(+), 270 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 8fa26f04a6..11f308a522 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_dynamic_buffer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseClass::BaseClass(BaseGame *gameOwner) { @@ -182,4 +182,4 @@ bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index dcd186be42..b1b184b2f4 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -35,7 +35,7 @@ #include "common/hashmap.h" #include "common/hash-str.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; class BaseDynamicBuffer; @@ -59,6 +59,6 @@ protected: std::map::iterator _editorPropsIter;*/ }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index a895735725..46870a0d29 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { @@ -107,4 +107,4 @@ void BaseActiveRect::clipRect() { BasePlatform::intersectRect(&_rect, &_rect, &rc); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 0885b0e13e..b446dadcce 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -32,7 +32,7 @@ #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion; class BaseSubFrame; class BaseObject; @@ -55,6 +55,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index d953483be8..0a7a214ba4 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_dynamic_buffer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { @@ -201,4 +201,4 @@ void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { putBytes((byte *)buff, strlen(buff)); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index ff3897e71b..8285b472b2 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseDynamicBuffer { public: @@ -61,6 +61,6 @@ private: void putTextForm(const char *format, va_list argptr); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index c31777c866..3447407866 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -33,10 +33,10 @@ #include "engines/wintermute/system/sys_class_registry.h" #include "common/system.h" namespace Common { -DECLARE_SINGLETON(WinterMute::BaseEngine); +DECLARE_SINGLETON(Wintermute::BaseEngine); } -namespace WinterMute { +namespace Wintermute { BaseEngine::BaseEngine() { _fileManager = NULL; @@ -49,7 +49,7 @@ BaseEngine::BaseEngine() { void BaseEngine::init() { _fileManager = new BaseFileManager(); // Don't forget to register your random source - _rnd = new Common::RandomSource("WinterMute"); + _rnd = new Common::RandomSource("Wintermute"); _classReg = new SystemClassRegistry(); _classReg->registerClasses(); } @@ -82,7 +82,7 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { if (instance()._gameRef) { instance()._gameRef->LOG("%s", buff); } else { - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); } } @@ -90,4 +90,4 @@ uint32 BaseEngine::randInt(int from, int to) { return _rnd->getRandomNumberRng(from, to); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 04199715af..32007ef571 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -33,13 +33,13 @@ #include "common/singleton.h" #include "common/random.h" -namespace WinterMute { +namespace Wintermute { class BaseFileManager; class BaseRegistry; class BaseGame; class SystemClassRegistry; -class BaseEngine : public Common::Singleton { +class BaseEngine : public Common::Singleton { void init(); BaseFileManager *_fileManager; Common::String _gameId; @@ -63,6 +63,6 @@ public: const char *getGameId() { return _gameId.c_str(); } }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 4bc166f841..580a7afeb4 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "common/util.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -191,4 +191,4 @@ bool BaseFader::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 4401bd0ebd..34d0e7d3da 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BaseFader : public BaseObject { public: @@ -58,6 +58,6 @@ private: uint32 _startTime; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index c17a456f11..f7a3b6a3fb 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -46,7 +46,7 @@ #include "common/savefile.h" #include "common/fs.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -88,20 +88,20 @@ byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *siz Common::SeekableReadStream *file = openFile(filename); if (!file) { if (mustExist) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error opening file '%s'", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error opening file '%s'", filename.c_str()); } return NULL; } buffer = new byte[file->size() + 1]; if (buffer == NULL) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); closeFile(file); return NULL; } if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Error reading file '%s'", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error reading file '%s'", filename.c_str()); closeFile(file); delete[] buffer; return NULL; @@ -165,7 +165,7 @@ bool BaseFileManager::initPaths() { bool BaseFileManager::registerPackages(const Common::FSList &fslist) { for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { - debugC(kWinterMuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it))) { addPath(PATH_PACKAGE, (*it)); @@ -177,13 +177,13 @@ bool BaseFileManager::registerPackages(const Common::FSList &fslist) { ////////////////////////////////////////////////////////////////////////// bool BaseFileManager::registerPackages() { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, "Scanning packages"); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Scanning packages"); // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { - debugC(kWinterMuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { if (!fileIt->getName().hasSuffix(".dcp")) { @@ -198,12 +198,12 @@ bool BaseFileManager::registerPackages() { continue; } } - debugC(kWinterMuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + debugC(kWintermuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); registerPackage((*fileIt)); } } -// debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); +// debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); return STATUS_OK; } @@ -263,7 +263,7 @@ Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &file if (strcmp(filename.c_str(), "") == 0) { return NULL; } - debugC(kWinterMuteDebugFileAccess, "Open file %s", filename.c_str()); + debugC(kWintermuteDebugFileAccess, "Open file %s", filename.c_str()); Common::SeekableReadStream *file = openFileRaw(filename); if (file && keepTrackOf) { @@ -317,7 +317,7 @@ Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &f return ret; } - debugC(kWinterMuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); return NULL; } @@ -328,4 +328,4 @@ BaseFileManager *BaseFileManager::getEngineInstance() { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 23032ca65a..91b1add1c8 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -34,7 +34,7 @@ #include "common/fs.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { class BaseFileManager { public: bool cleanup(); @@ -69,6 +69,6 @@ private: // the detector too, without launching the entire engine: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 5473419f22..1462f1430d 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -39,7 +39,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseFrame, false) @@ -757,4 +757,4 @@ const char *BaseFrame::scToString() { return "[frame]"; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index b019ebf7b6..b1eae6b659 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseSound; class BaseSubFrame; class BaseObject; @@ -68,6 +68,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index b92da4c11b..568e6dc6fd 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -72,7 +72,7 @@ #include "common/system.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -307,7 +307,7 @@ BaseGame::~BaseGame() { _stringTable = NULL; DEBUG_DebugDisable(); - debugC(kWinterMuteDebugLog, "--- shutting down normally ---\n"); + debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); } @@ -538,7 +538,7 @@ void BaseGame::LOG(bool res, const char *fmt, ...) { _engineLogCallback(buff, res, _engineLogCallbackData); } - debugCN(kWinterMuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); //fflush((FILE *)_debugLogFile); @@ -4490,4 +4490,4 @@ AnsiString BaseGame::getDeviceType() const { return "computer"; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8a587da3e3..43efad1482 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -36,7 +36,7 @@ #include "engines/wintermute/math/rect32.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); @@ -357,6 +357,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 01b5cea36d..70d92784a5 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -32,7 +32,7 @@ #include "common/system.h" #include "common/keyboard.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseKeyboardState, false) @@ -309,4 +309,4 @@ Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index 8c4b1afb59..382dd9fbce 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -35,7 +35,7 @@ #include "common/keyboard.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseKeyboardState : public BaseScriptable { public: @@ -70,6 +70,6 @@ private: Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index 0873f090d0..d95dd3e25b 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -28,7 +28,7 @@ #include "engines/wintermute/base/base_named_object.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { @@ -68,4 +68,4 @@ void BaseNamedObject::setName(const char *name) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index 32e4d561d7..cd856bb008 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseNamedObject : public BaseClass { char *_name; @@ -46,6 +46,6 @@ public: void setName(const char *name); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index 7d186c7f0a..ff8fcd0bf2 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_sprite.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseObject, false) @@ -1243,4 +1243,4 @@ bool BaseObject::afterMove() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index c1e3172a77..34d9ca89ca 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "common/events.h" -namespace WinterMute { +namespace Wintermute { class BaseSprite; class BaseSound; @@ -142,6 +142,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 75268f6483..bbbb5d69ba 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -35,7 +35,7 @@ #define WHITESPACE " \t\n\r" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -464,4 +464,4 @@ int BaseParser::scanStr(const char *in, const char *format, ...) { return num; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 34266bd5bd..3d63668059 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -54,7 +54,7 @@ #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseParser { public: @@ -83,6 +83,6 @@ private: char *_whiteSpace; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index e6ed5cb7e0..1beaeecdd7 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -43,7 +43,7 @@ #include "common/system.h" #include "common/savefile.h" -namespace WinterMute { +namespace Wintermute { #define SAVE_BUFFER_INIT_SIZE 100000 #define SAVE_BUFFER_GROW_BY 50000 @@ -134,7 +134,7 @@ Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { Common::String filename = getFilenameForSlot(slot); - debugC(kWinterMuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); + debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); if (DID_FAIL(readHeader(filename))) { warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); return; @@ -331,7 +331,7 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { _saving = false; if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); cleanup(); return STATUS_FAILED; } @@ -342,8 +342,8 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) ) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); - debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; } @@ -353,8 +353,8 @@ bool BasePersistenceManager::initLoad(const Common::String &filename) { (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) ) { - debugC(kWinterMuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - debugC(kWinterMuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); cleanup(); return STATUS_FAILED; @@ -371,7 +371,7 @@ bool BasePersistenceManager::saveFile(const Common::String &filename) { byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); - Common::SaveFileManager *saveMan = ((WinterMuteEngine *)g_engine)->getSaveFileMan(); + Common::SaveFileManager *saveMan = ((WintermuteEngine *)g_engine)->getSaveFileMan(); Common::OutSaveFile *file = saveMan->openForSaving(filename); file->write(prefixBuffer, prefixSize); file->write(buffer, bufferSize); @@ -792,7 +792,7 @@ bool BasePersistenceManager::transfer(const char *name, void *val) { if (_saving) { SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - debugC(kWinterMuteDebugSaveGame, "Warning: invalid instance '%s'", name); + debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); } _saveStream->writeUint32LE(classID); @@ -825,4 +825,4 @@ bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte ver return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 87892b42f3..fea8f231d1 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -38,7 +38,7 @@ #include "common/system.h" #include "common/rect.h" -namespace WinterMute { +namespace Wintermute { class Vector2; class BaseGame; @@ -113,6 +113,6 @@ private: BaseGame *_gameRef; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 99e8c609df..73e7e4690a 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BasePoint, false) @@ -60,4 +60,4 @@ bool BasePoint::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 35d310b8d9..68a37c0110 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -32,7 +32,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BasePoint: public BaseClass { public: @@ -45,6 +45,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index e9f3e430af..dfe25b474b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_quick_msg.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { @@ -54,4 +54,4 @@ char *BaseQuickMsg::getText() { return _text; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index f2f9144bc0..bef81827b0 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseQuickMsg : public BaseClass { public: @@ -43,6 +43,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 82dc359eb0..a781c7eeb7 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/platform_osystem.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseRegion, false) @@ -536,4 +536,4 @@ bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { return createRegion() ? STATUS_OK : STATUS_FAILED; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 7770d345f7..f456eb07fc 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion : public BaseObject { public: @@ -64,6 +64,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 0d580e8db3..8cd15ccf1d 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/gfx/base_image.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { @@ -77,4 +77,4 @@ bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index d0d0757fbf..4131cf89d4 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseImage; @@ -46,6 +46,6 @@ private: BaseImage *_richThumbnail; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index b40647dc7b..d57638a4a8 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseScriptHolder, false) @@ -501,4 +501,4 @@ bool BaseScriptHolder::sendEvent(const char *eventName) { return DID_SUCCEED(applyEvent(eventName)); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 4162936ded..4f3d5f4ef9 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -33,7 +33,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class BaseScriptHolder : public BaseScriptable { public: @@ -71,6 +71,6 @@ public: virtual bool sendEvent(const char *eventName); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 11092427be..6e5b30f7b6 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseScriptable, false) @@ -188,4 +188,4 @@ ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 6227b84649..2501f34561 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_named_object.h" #include "engines/wintermute/persistent.h" -namespace WinterMute { +namespace Wintermute { class ScValue; class ScStack; @@ -78,6 +78,6 @@ BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); BaseScriptable *makeSXStore(BaseGame *inGame); BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6c66b808b7..6fe5be9e11 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -41,7 +41,7 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSprite, false) @@ -812,4 +812,4 @@ bool BaseSprite::killAllSounds() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index 952bff0017..a02e69c63f 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base_script_holder.h" -namespace WinterMute { +namespace Wintermute { class BaseFrame; class BaseSurface; class BaseObject; @@ -85,6 +85,6 @@ public: virtual const char *scToString(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 2e8774020d..3b5e5e3774 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_string_table.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { @@ -252,4 +252,4 @@ bool BaseStringTable::loadFile(const char *filename, bool clearOld) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index 1bc9047f7f..c8df25810e 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -33,7 +33,7 @@ #include "common/hashmap.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseStringTable : public BaseClass { public: @@ -50,6 +50,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 7f527392dc..3ddfd1bb14 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSubFrame, false) @@ -652,4 +652,4 @@ bool BaseSubFrame::setSurfaceSimple() { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index d8027d3ce9..935fb667d4 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class BaseObject; class BaseSurface; class BaseSubFrame : public BaseScriptable { @@ -87,6 +87,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index e3c3692892..0ff325be7d 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { //IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); @@ -204,4 +204,4 @@ int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index c09b0a30ab..f1757b3a32 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface; class BaseSurfaceStorage : public BaseClass { public: @@ -52,6 +52,6 @@ public: Common::Array _surfaces; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 63a13309fb..d71bce1084 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { @@ -133,4 +133,4 @@ bool BaseTransitionMgr::update() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 104f327fb8..412361a543 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseTransitionMgr : public BaseClass { public: @@ -49,6 +49,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index a6c7eea96e..af36a4fdd7 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_viewport.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseViewport, false) @@ -95,4 +95,4 @@ int BaseViewport::getHeight() { return _rect.bottom - _rect.top; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 33e9448082..1080c1d806 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { class BaseObject; class BaseViewport : public BaseClass { public: @@ -50,6 +50,6 @@ private: Rect32 _rect; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 93533b4057..2f7450a999 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -37,7 +37,7 @@ #include "common/tokenizer.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { void correctSlashes(char *fileName) { for (size_t i = 0; i < strlen(fileName); i++) { @@ -196,4 +196,4 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 99a9e8b9a3..8be06199de 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -31,11 +31,11 @@ #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { Common::SeekableReadStream *openDiskFile(const Common::String &filename); bool diskFileExists(const Common::String &filename); -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index 185a21ad57..f2a347ee0f 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -29,7 +29,7 @@ #include "engines/wintermute/base/file/base_file.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -65,4 +65,4 @@ Common::SeekableReadStream *BaseFile::getMemStream() { } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 0c1ab2a045..f9947fe64f 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -38,7 +38,7 @@ namespace Common { class SeekableReadStream; } -namespace WinterMute { +namespace Wintermute { class BaseFile { protected: @@ -62,6 +62,6 @@ public: virtual Common::SeekableReadStream *getMemStream(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index a08d55db43..82ddf7c90e 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -32,7 +32,7 @@ #include "common/substream.h" #include "common/zlib.h" -namespace WinterMute { +namespace Wintermute { Common::SeekableReadStream *BaseFileEntry::createReadStream() const { Common::SeekableReadStream *file = _package->getFilePointer(); @@ -70,4 +70,4 @@ BaseFileEntry::~BaseFileEntry() { _package = NULL; // ref only } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index b94a6cd9fc..7e71a486ef 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -33,7 +33,7 @@ #include "common/str.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BasePackage; @@ -55,6 +55,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index ab74810d1d..a9fb7f9a68 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -34,7 +34,7 @@ #include "common/stream.h" #include "common/debug.h" -namespace WinterMute { +namespace Wintermute { BasePackage::BasePackage() { _name = ""; @@ -123,13 +123,13 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool TPackageHeader hdr; hdr.readFromStream(stream); if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); delete stream; return; } if (hdr._packageVersion != PACKAGE_VERSION) { - debugC(kWinterMuteDebugFileAccess | kWinterMuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); } _priority = hdr._priority; // new in v2 @@ -181,7 +181,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool ((byte *)name)[k] ^= 'D'; } } - debugC(kWinterMuteDebugFileAccess, "Package contains %s", name); + debugC(kWintermuteDebugFileAccess, "Package contains %s", name); Common::String upcName = name; upcName.toUppercase(); @@ -222,7 +222,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } } } - debugC(kWinterMuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + debugC(kWintermuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); delete stream; } @@ -273,4 +273,4 @@ Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common:: return NULL; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index a562229f65..676675b041 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -33,7 +33,7 @@ #include "common/stream.h" #include "common/fs.h" -namespace WinterMute { +namespace Wintermute { class BasePackage { public: Common::SeekableReadStream *getFilePointer(); @@ -85,6 +85,6 @@ private: Common::HashMap::iterator _filesIter; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index aac5436071..a8bda164dc 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -30,7 +30,7 @@ #include "common/str.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { unsigned char invalid[] = { 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, @@ -2827,4 +2827,4 @@ bool BaseResources::hasFile(const Common::String &filename) { return false; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 2ccab6996f..596ac64dd7 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -32,7 +32,7 @@ #include "common/stream.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class BaseResources { public: @@ -40,6 +40,6 @@ public: static bool hasFile(const Common::String &filename); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 1f7288a6ff..515d8870d7 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/file/base_save_thumb_file.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -151,4 +151,4 @@ bool BaseSaveThumbFile::seek(uint32 pos, int whence) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index d95958d95f..e68dc06904 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/file/base_file.h" -namespace WinterMute { +namespace Wintermute { //TODO: Get rid of this class BaseSaveThumbFile : public BaseFile { @@ -47,6 +47,6 @@ private: byte *_data; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index ccebc5909c..42c0b75e55 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -37,7 +37,7 @@ #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { struct TPackageHeader { uint32 _magic1; @@ -75,6 +75,6 @@ v2: uint32 TimeDate1 */ -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // _DCPACKAGE_H_ diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index fa9242366e..198b1ae308 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_file_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -204,4 +204,4 @@ bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { return ret; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index f1dc962565..e4413e3410 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -33,7 +33,7 @@ #define NUM_CHARACTERS 256 -namespace WinterMute { +namespace Wintermute { class BaseFont: public BaseObject { public: @@ -56,6 +56,6 @@ private: static bool isTrueType(BaseGame *game, const Common::String &filename); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 6585d7cb0a..0913ac9b53 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -38,7 +38,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -586,4 +586,4 @@ int BaseFontBitmap::getLetterHeight() { return _tileHeight; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index fb992d2e9a..0b873855bb 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/font/base_font.h" -namespace WinterMute { +namespace Wintermute { class BaseSubFrame; class BaseFontBitmap : public BaseFont { public: @@ -66,6 +66,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 0c34a8822a..bc7ab6f22c 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -139,4 +139,4 @@ bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 3a39617c32..498096a5a8 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseFont; @@ -50,6 +50,6 @@ public: bool initLoop(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 4fa5ac08ce..ced279dcc8 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -43,7 +43,7 @@ #include "graphics/fontman.h" #include -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseFontTT, false) @@ -198,7 +198,7 @@ void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, // not found, create one if (!surface) { - debugC(kWinterMuteDebugFont, "Draw text: %s", text); + debugC(kWintermuteDebugFont, "Draw text: %s", text); surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); if (surface) { // write surface to cache @@ -264,7 +264,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, alignment = Graphics::kTextAlignRight; } - debugC(kWinterMuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); + debugC(kWintermuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); // void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; Graphics::Surface *surface = new Graphics::Surface(); if (_deletableFont) { // We actually have a TTF @@ -602,4 +602,4 @@ void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight }*/ } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index a893e70ec0..fc4de30fc5 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -38,7 +38,7 @@ #define NUM_CACHED_TEXTS 30 -namespace WinterMute { +namespace Wintermute { class BaseFontTT : public BaseFont { private: @@ -147,6 +147,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index c1b6636237..ec52e26c00 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -38,7 +38,7 @@ #include "common/stream.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseImage::BaseImage() { @@ -69,7 +69,7 @@ bool BaseImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".tga")) { - _decoder = new WinterMute::TGA(); + _decoder = new Wintermute::TGA(); } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { @@ -228,4 +228,4 @@ bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 76a389977d..7bf901fe40 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -36,7 +36,7 @@ #include "common/str.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface; class BaseFileManager; class BaseImage { @@ -67,6 +67,6 @@ private: BaseFileManager *_fileManager; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 5d81c44c25..47a5462452 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { @@ -373,4 +373,4 @@ bool BaseRenderer::displayIndicator() { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 49b5e187eb..aa8812254d 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -34,7 +34,7 @@ #include "common/rect.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseImage; class BaseActiveRect; @@ -215,6 +215,6 @@ private: BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index 28ac4e6973..cbd665591a 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/base_surface.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { @@ -146,4 +146,4 @@ void BaseSurface::setSize(int width, int height) { _height = height; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 57a51ce3aa..3be61477ba 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -33,7 +33,7 @@ #include "engines/wintermute/math/rect32.h" #include "graphics/surface.h" -namespace WinterMute { +namespace Wintermute { class BaseSurface: public BaseClass { public: @@ -94,6 +94,6 @@ protected: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index ab4e690458..201c881122 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -38,7 +38,7 @@ #include "common/queue.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { @@ -602,4 +602,4 @@ BaseSurface *BaseRenderOSystem::createSurface() { return new BaseSurfaceOSystem(_gameRef); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 070ddf9241..5859fec74e 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -34,7 +34,7 @@ #include "graphics/surface.h" #include "common/list.h" -namespace WinterMute { +namespace Wintermute { class BaseSurfaceOSystem; class RenderTicket { Graphics::Surface *_surface; @@ -125,6 +125,6 @@ private: uint32 _clearColor; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_BRENDERER_SDL_H diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 400bb1de41..5b0f7c94c3 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -43,7 +43,7 @@ #include "common/stream.h" #include "common/system.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { @@ -426,4 +426,4 @@ bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAl return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index fe1d055026..27f9ad047e 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/gfx/base_surface.h" #include "common/list.h" -namespace WinterMute { +namespace Wintermute { struct TransparentSurface; class BaseImage; class BaseSurfaceOSystem : public BaseSurface { @@ -94,6 +94,6 @@ private: byte *_alphaMask; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif // WINTERMUTE_BSURFACESDL_H diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index ced01b7fd9..d6006528a2 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -40,7 +40,7 @@ #include "common/str.h" #include "common/math.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(PartEmitter, false) @@ -1253,4 +1253,4 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 438dfff521..dd02cf7f17 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/base/particles/part_force.h" -namespace WinterMute { +namespace Wintermute { class BaseRegion; class PartParticle; class PartEmitter : public BaseObject { @@ -135,6 +135,6 @@ private: BaseArray _sprites; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index 7b2f117b4f..abbaa2819d 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/particles/part_force.h" #include "engines/wintermute/base/base_persistence_manager.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { @@ -62,4 +62,4 @@ bool PartForce::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h index ec79ab7238..6903a919e9 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/base_named_object.h" #include "engines/wintermute/math/vector2.h" -namespace WinterMute { +namespace Wintermute { class PartForce : public BaseNamedObject { public: @@ -52,6 +52,6 @@ public: bool persist(BasePersistenceManager *PersistMgr); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 1a449a50a5..9247514ac3 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/platform_osystem.h" #include "common/str.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////////// PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { @@ -266,4 +266,4 @@ bool PartParticle::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 44da85a559..3c8fc2c68b 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -34,7 +34,7 @@ #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/math/vector2.h" -namespace WinterMute { +namespace Wintermute { class PartEmitter; class BaseSprite; @@ -85,6 +85,6 @@ private: int _fadeStartAlpha; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index fe987c0b2a..06e9fd2565 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -40,7 +40,7 @@ #include "common/savefile.h" #include "common/config-manager.h" -namespace WinterMute { +namespace Wintermute { bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { gameRef->LOG(0, "Loading game '%s'...", filename.c_str()); @@ -159,7 +159,7 @@ Common::String SaveLoad::getSaveSlotFilename(int slot) { BasePersistenceManager *pm = new BasePersistenceManager(); Common::String filename = pm->getFilenameForSlot(slot); delete pm; - debugC(kWinterMuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); + debugC(kWintermuteDebugSaveGame, "getSaveSlotFileName(%d) = %s", slot, filename.c_str()); return filename; } @@ -194,10 +194,10 @@ bool SaveLoad::isSaveSlotUsed(int slot) { bool SaveLoad::emptySaveSlot(int slot) { Common::String filename = getSaveSlotFilename(slot); BasePersistenceManager *pm = new BasePersistenceManager(); - ((WinterMuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); + ((WintermuteEngine *)g_engine)->getSaveFileMan()->removeSavefile(pm->getFilenameForSlot(slot)); delete pm; return true; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h index 59cdceb038..e448cc8814 100644 --- a/engines/wintermute/base/saveload.h +++ b/engines/wintermute/base/saveload.h @@ -31,7 +31,7 @@ #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class BaseGame; class SaveLoad { public: @@ -52,6 +52,6 @@ private: static void afterLoadScript(void *script, void *data); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index 9610ebf94c..db63ad2b87 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -29,7 +29,7 @@ #ifndef WINTERMUTE_DCSCRIPT_H #define WINTERMUTE_DCSCRIPT_H -namespace WinterMute { +namespace Wintermute { #define SCRIPT_MAGIC 0xDEC0ADDE #define SCRIPT_VERSION 0x0102 @@ -136,6 +136,6 @@ typedef enum { ELEMENT_STRING = 0 } TElementType; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index fb77225700..6c8a88adb0 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/scriptables/script_stack.h" #include "common/memstream.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScScript, false) @@ -1464,4 +1464,4 @@ void ScScript::afterLoad() { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 9f49fac994..132f1ce6c5 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -34,7 +34,7 @@ #include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "engines/wintermute/coll_templ.h" -namespace WinterMute { +namespace Wintermute { class BaseScriptHolder; class BaseObject; class ScEngine; @@ -169,6 +169,6 @@ public: virtual const char *dbgGetFilename(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index a1f246c4bc..8765fb9864 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -37,7 +37,7 @@ #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScEngine, true) @@ -608,4 +608,4 @@ void ScEngine::dumpStats() { }*/ } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index 9aae8be85b..f526353368 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -33,7 +33,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -namespace WinterMute { +namespace Wintermute { #define MAX_CACHED_SCRIPTS 20 class ScScript; @@ -130,6 +130,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index a422d6d8a5..c8d4f64ae9 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -32,7 +32,7 @@ #include "engines/wintermute/system/sys_instance.h" #include "engines/wintermute/base/scriptables/script_ext_array.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXArray, false) @@ -249,4 +249,4 @@ bool SXArray::push(ScValue *val) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index f2718f4ea2..614f829950 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -31,7 +31,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXArray : public BaseScriptable { public: @@ -51,6 +51,6 @@ private: Common::String _strRep; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 72f41c83cc..b5acc7d389 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_ext_date.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXDate, false) @@ -291,4 +291,4 @@ int SXDate::scCompare(BaseScriptable *Value) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 69fe1f1ae5..521b7a9f8a 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -32,7 +32,7 @@ #include "common/system.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXDate : public BaseScriptable { public: @@ -50,6 +50,6 @@ private: Common::String _strRep; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 50d89921e1..53d551119d 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -40,7 +40,7 @@ // Note: This code is completely untested, as I have yet to find a game that uses SXFile. -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXFile, false) @@ -826,4 +826,4 @@ Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool error("SXFile::openForAppend - WriteFiles not supported"); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index d083f96a4a..389974a48e 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -33,7 +33,7 @@ #include "engines/wintermute/base/base_scriptable.h" #include "common/stream.h" -namespace WinterMute { +namespace Wintermute { class BaseFile; @@ -61,6 +61,6 @@ private: Common::WriteStream *openForAppend(const Common::String &filename, bool binary); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 6b80da6389..906d807275 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -33,7 +33,7 @@ #include "common/math.h" #include -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -292,4 +292,4 @@ bool SXMath::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index 393342e5ca..b195c0785d 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXMath : public BaseScriptable { public: @@ -48,6 +48,6 @@ private: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 557d9b9b57..eef1931d8b 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -33,7 +33,7 @@ #include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" #include "common/file.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXMemBuffer, false) @@ -526,4 +526,4 @@ int SXMemBuffer::scCompare(BaseScriptable *val) { } } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index b5428b4bd9..0a16167b58 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXMemBuffer : public BaseScriptable { public: @@ -55,6 +55,6 @@ private: bool checkBounds(ScScript *script, int start, int length); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index ab7296b1ce..40c9b885cd 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -64,4 +64,4 @@ bool SXObject::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index f7d3a7bc0f..32aa00776e 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_object.h" -namespace WinterMute { +namespace Wintermute { class SXObject : public BaseObject { public: @@ -41,6 +41,6 @@ public: virtual ~SXObject(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index adbf16611c..9bcfe28bbf 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -35,7 +35,7 @@ #include "engines/wintermute/utils/string_util.h" #include "common/tokenizer.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(SXString, false) @@ -433,4 +433,4 @@ int SXString::scCompare(BaseScriptable *val) { return strcmp(_string, ((SXString *)val)->_string); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 9a3bbfc80b..c2de3860ed 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -32,7 +32,7 @@ #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { class SXString : public BaseScriptable { public: @@ -53,6 +53,6 @@ private: int _capacity; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 9b3a0201ac..7e81cdaf17 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -30,7 +30,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/base_game.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(ScStack, false) @@ -229,4 +229,4 @@ bool ScStack::persist(BasePersistenceManager *persistMgr) { return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 95839cc680..0e2adae518 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -34,7 +34,7 @@ #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/persistent.h" -namespace WinterMute { +namespace Wintermute { class ScValue; class BaseScriptable; @@ -61,6 +61,6 @@ public: }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index d35f85f9a1..03ca69ac7e 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -34,7 +34,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_scriptable.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -992,4 +992,4 @@ bool ScValue::setProperty(const char *propName) { return ret; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index c8d04168b3..af31014bac 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -35,7 +35,7 @@ #include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView #include "common/str.h" -namespace WinterMute { +namespace Wintermute { class ScScript; class BaseScriptable; @@ -108,6 +108,6 @@ public: bool setProperty(const char *propName); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index 7e32552d08..aac68baccd 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/sound/base_sound_buffer.h" -namespace WinterMute { +namespace Wintermute { IMPLEMENT_PERSISTENT(BaseSound, false) @@ -289,4 +289,4 @@ bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index cadba77bc8..fcc463ed06 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -34,7 +34,7 @@ #include "engines/wintermute/persistent.h" #include "audio/mixer.h" -namespace WinterMute { +namespace Wintermute { class BaseSoundBuffer; class BaseSound : public BaseClass { @@ -82,6 +82,6 @@ private: BaseSoundBuffer *_sound; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index ac329704bc..14bbcd9421 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -41,7 +41,7 @@ #include "common/system.h" #include "common/substream.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -93,7 +93,7 @@ void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 block ////////////////////////////////////////////////////////////////////////// bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { - debugC(kWinterMuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); + debugC(kWintermuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); // Load a file, but avoid having the File-manager handle the disposal of it. _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); @@ -290,4 +290,4 @@ bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float p return STATUS_OK; } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 7aec144283..3ec4d4d28b 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -39,7 +39,7 @@ class SeekableAudioStream; class SoundHandle; } -namespace WinterMute { +namespace Wintermute { class BaseFile; class BaseSoundBuffer : public BaseClass { @@ -95,6 +95,6 @@ private: int _volume; }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 95b7d040ab..2bfe0499f9 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -37,7 +37,7 @@ #include "common/config-manager.h" #include "audio/mixer.h" -namespace WinterMute { +namespace Wintermute { ////////////////////////////////////////////////////////////////////// // Construction/Destruction @@ -279,4 +279,4 @@ float BaseSoundMgr::posToPan(int x, int y) { return minPan + relPos * (maxPan - minPan); } -} // end of namespace WinterMute +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index a2b8f2c9e9..a0b9a4bc4b 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -34,7 +34,7 @@ #include "audio/mixer.h" #include "common/array.h" -namespace WinterMute { +namespace Wintermute { class BaseSoundBuffer; class BaseSoundMgr : public BaseClass { public: @@ -63,6 +63,6 @@ public: void saveSettings(); }; -} // end of namespace WinterMute +} // end of namespace Wintermute #endif -- cgit v1.2.3 From a3703506919a67173b3447115cdc85c0f1711ed6 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 03:54:34 +0200 Subject: WINTERMUTE: Readd support for save/load-images. --- engines/wintermute/base/gfx/base_renderer.cpp | 6 +++++- engines/wintermute/base/gfx/base_renderer.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 47a5462452..9e271fc32d 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -58,6 +58,7 @@ BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { _saveImageName = ""; _saveLoadImage = NULL; _loadInProgress = false; + _hasDrawnSaveLoadImage = false; _saveImageX = _saveImageY = 0; _loadImageX = _loadImageY = 0; @@ -127,6 +128,7 @@ void BaseRenderer::setSaveImage(const char *filename, int x, int y) { void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; + _hasDrawnSaveLoadImage = false; if (isSaving && !quickSave) { delete _saveLoadImage; @@ -346,7 +348,7 @@ bool BaseRenderer::displayIndicator() { if (!_indicatorDisplay || !_indicatorProgress) { return STATUS_OK; } - if (_saveLoadImage) { + if (_saveLoadImage && !_hasDrawnSaveLoadImage) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); if (_loadInProgress) { @@ -354,6 +356,8 @@ bool BaseRenderer::displayIndicator() { } else { _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); } + flip(); + _hasDrawnSaveLoadImage = true; } if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index aa8812254d..1b284b044d 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -192,6 +192,7 @@ protected: int _loadImageX; int _loadImageY; BaseSurface *_saveLoadImage; + bool _hasDrawnSaveLoadImage; int _indicatorWidthDrawn; uint32 _indicatorColor; -- cgit v1.2.3 From 101ad689c5063e3eb91a2255ba154348069b14ad Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Mon, 13 Aug 2012 04:37:07 +0200 Subject: WINTERMUTE: Add language-filtering for Czech, Italian, Polish and Russian. No detection-support is added for those languages at this point though. --- engines/wintermute/base/base_engine.cpp | 8 ++++---- engines/wintermute/base/base_engine.h | 5 +++-- engines/wintermute/base/base_file_manager.cpp | 15 ++++++++++++--- engines/wintermute/base/base_file_manager.h | 4 +++- 4 files changed, 22 insertions(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 3447407866..2368f8b106 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -46,8 +46,8 @@ BaseEngine::BaseEngine() { _gameId = ""; } -void BaseEngine::init() { - _fileManager = new BaseFileManager(); +void BaseEngine::init(Common::Language lang) { + _fileManager = new BaseFileManager(lang); // Don't forget to register your random source _rnd = new Common::RandomSource("Wintermute"); _classReg = new SystemClassRegistry(); @@ -60,9 +60,9 @@ BaseEngine::~BaseEngine() { delete _classReg; } -void BaseEngine::createInstance(const Common::String &gameid) { +void BaseEngine::createInstance(const Common::String &gameid, Common::Language lang) { instance()._gameId = gameid; - instance().init(); + instance().init(lang); } void BaseEngine::LOG(bool res, const char *fmt, ...) { diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 32007ef571..1cef7b33ba 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -32,6 +32,7 @@ #include "common/str.h" #include "common/singleton.h" #include "common/random.h" +#include "common/language.h" namespace Wintermute { @@ -40,7 +41,7 @@ class BaseRegistry; class BaseGame; class SystemClassRegistry; class BaseEngine : public Common::Singleton { - void init(); + void init(Common::Language lang); BaseFileManager *_fileManager; Common::String _gameId; BaseGame *_gameRef; @@ -50,7 +51,7 @@ class BaseEngine : public Common::Singleton { public: BaseEngine(); ~BaseEngine(); - static void createInstance(const Common::String &gameid); + static void createInstance(const Common::String &gameid, Common::Language lang); void setGameRef(BaseGame *gameRef) { _gameRef = gameRef; } Common::RandomSource *getRandomSource() { return _rnd; } diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f7a3b6a3fb..01b11352b5 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -53,7 +53,8 @@ namespace Wintermute { ////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager() { +BaseFileManager::BaseFileManager(Common::Language lang) { + _language = lang; initPaths(); registerPackages(); } @@ -191,10 +192,18 @@ bool BaseFileManager::registerPackages() { } // Avoid registering all the language files // TODO: Select based on the gameDesc. - if (fileIt->getParent().getName() == "language") { + if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { Common::String parentName = fileIt->getParent().getName(); Common::String dcpName = fileIt->getName(); - if (fileIt->getName() != "english.dcp") { + if (_language == Common::EN_ANY && fileIt->getName() != "english.dcp") { + continue; + } else if (_language == Common::CZ_CZE && fileIt->getName() != "czech.dcp") { + continue; + } else if (_language == Common::IT_ITA && fileIt->getName() != "italian.dcp") { + continue; + } else if (_language == Common::PL_POL && fileIt->getName() != "polish.dcp") { + continue; + } else if (_language == Common::RU_RUS && fileIt->getName() != "russian.dcp") { continue; } } diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 91b1add1c8..5e18a95786 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -33,6 +33,7 @@ #include "common/str.h" #include "common/fs.h" #include "common/file.h" +#include "common/language.h" namespace Wintermute { class BaseFileManager { @@ -44,7 +45,7 @@ public: Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - BaseFileManager(); + BaseFileManager(Common::Language lang); virtual ~BaseFileManager(); // Used only for detection bool registerPackages(const Common::FSList &fslist); @@ -65,6 +66,7 @@ private: bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); Common::SearchSet _packages; Common::Array _openFiles; + Common::Language _language; // This class is intentionally not a subclass of Base, as it needs to be used by // the detector too, without launching the entire engine: }; -- cgit v1.2.3 From 209488c6cf87fc9c7f7adf005d7bad5a1f5428a8 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 17:26:46 +0200 Subject: WINTERMUTE: Save the loop-state of sounds properly. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 14bbcd9421..b94f0d8215 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -137,10 +137,12 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { delete _handle; _handle = NULL; } + // Store the loop-value for save-games. + setLooping(looping); if (_stream) { _stream->seek(startSample); _handle = new Audio::SoundHandle; - if (looping) { + if (_looping) { Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); } else { -- cgit v1.2.3 From 83344a5aef4d27a75694393be4f9a28266504ae0 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 17:27:28 +0200 Subject: WINTERMUTE: Adjust a few warnings. --- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index ced279dcc8..0893f36bc5 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -566,7 +566,7 @@ bool BaseFontTT::initFont() { } if (!_font) { _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BaseFontTT::InitFont - Couldn't load %s", _fontFile); + warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); } _lineHeight = _font->getFontHeight(); return STATUS_OK; diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 201c881122..4c8a80028b 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -539,7 +539,6 @@ bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { ////////////////////////////////////////////////////////////////////////// BaseImage *BaseRenderOSystem::takeScreenshot() { // TODO: Clip by viewport. - warning("BaseRenderOSystem::TakeScreenshot() - not ported yet"); BaseImage *screenshot = new BaseImage(); screenshot->copyFrom(_renderSurface); return screenshot; -- cgit v1.2.3 From e01dc47414355937d98b1de11151dde7c1c12a00 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 14 Aug 2012 18:20:12 +0200 Subject: WINTERMUTE: Fill the screen with fillRect for now. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 4c8a80028b..05520ee7a9 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -171,7 +171,7 @@ bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _blankSurface->fillRect(Common::Rect(0, 0, g_system->getHeight(), g_system->getWidth()), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); + _blankSurface->fillRect(Common::Rect(0, 0, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); _active = true; _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); @@ -206,7 +206,6 @@ bool BaseRenderOSystem::flip() { while (it != _renderQueue.end()) { if ((*it)->_wantsDraw == false) { RenderTicket *ticket = *it; - addDirtyRect((*it)->_dstRect); it = _renderQueue.erase(it); delete ticket; } else { @@ -237,11 +236,12 @@ bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { return STATUS_OK; } if (!rect) { - if (r == 0 && g == 0 && b == 0) { +// TODO: This should speed things up, but for some reason it misses the size by quite a bit. +/* if (r == 0 && g == 0 && b == 0) { // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); return STATUS_OK; - } + }*/ rect = &_renderRect; } // TODO: This doesn't work with dirty rects -- cgit v1.2.3 From 10ca0f136d120677d776981fc58aba548181c033 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 15 Aug 2012 02:35:11 +0200 Subject: WINTERMUTE: Clear out some commented-out code. --- engines/wintermute/base/base_game.cpp | 10 ---------- engines/wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 + 3 files changed, 1 insertion(+), 11 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 568e6dc6fd..acb20b2454 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -477,15 +477,6 @@ bool BaseGame::initialize3() { // renderer is initialized void BaseGame::DEBUG_DebugEnable(const char *filename) { _debugDebugMode = true; - /* time_t timeNow; - time(&timeNow); - struct tm *tm = localtime(&timeNow); - - #ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Debug Build) *******************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%04d (Release Build) *****************", tm->tm_mday, tm->tm_mon, tm->tm_year + 1900); - #endif*/ int secs = g_system->getMillis() / 1000; int hours = secs / 3600; secs = secs % 3600; @@ -499,7 +490,6 @@ void BaseGame::DEBUG_DebugEnable(const char *filename) { #endif LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - //LOG(0, "Extensions: %s ver %d.%02d", EXT_NAME, EXT_VER_MAJOR, EXT_VER_MINOR); AnsiString platform = BasePlatform::getPlatformName(); LOG(0, "Platform: %s", platform.c_str()); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 8765fb9864..575e24a3a3 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -312,7 +312,6 @@ bool ScEngine::tick() { break; } default: - //warning("ScEngine::Tick - Unhandled enum"); break; } // switch } // for each script diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index b94f0d8215..bb4d5ba375 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -156,6 +156,7 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) { ////////////////////////////////////////////////////////////////////////// void BaseSoundBuffer::setLooping(bool looping) { if (isPlaying()) { + // This warning is here, to see if this is ever the case. warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO } _looping = looping; -- cgit v1.2.3 From eacb0b169814345271d9d8e947d3d4fefe06ad7f Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Wed, 15 Aug 2012 02:36:08 +0200 Subject: WINTERMUTE: Make use of the wday-field in dates, instead of a wrong mday-value. --- engines/wintermute/base/scriptables/script_ext_date.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index b5acc7d389..7726015081 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -127,8 +127,7 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "GetWeekday") == 0) { stack->correctParams(0); - warning("GetWeekday returns a wrong value on purpose"); - stack->pushInt(_tm.tm_mday % 7); + stack->pushInt(_tm.tm_wday); return STATUS_OK; } -- cgit v1.2.3 From 246109839b9c196e9181a6f619c15694456b9aec Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sun, 19 Aug 2012 23:49:29 +0200 Subject: WINTERMUTE: Be case-insensitive when testing for sound-format. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index bb4d5ba375..e2d9c8c13f 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -102,6 +102,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel return STATUS_FAILED; } Common::String strFilename(filename); + strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); } else if (strFilename.hasSuffix(".wav")) { -- cgit v1.2.3 From 16b27090b1c7dc11cdc199b1a98c0f2973db5f45 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 13:49:38 +0200 Subject: WINTERMUTE: Update to use new TGA-decoder and new Video-system --- engines/wintermute/base/gfx/base_image.cpp | 4 ++-- engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index ec52e26c00..1184d2bbf7 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -32,8 +32,8 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/jpeg.h" #include "graphics/decoders/bmp.h" +#include "graphics/decoders/tga.h" #include "graphics/surface.h" -#include "engines/wintermute/graphics/tga.h" #include "common/textconsole.h" #include "common/stream.h" #include "common/system.h" @@ -69,7 +69,7 @@ bool BaseImage::loadFile(const Common::String &filename) { } else if (_filename.hasSuffix(".bmp")) { _decoder = new Graphics::BitmapDecoder(); } else if (_filename.hasSuffix(".tga")) { - _decoder = new Wintermute::TGA(); + _decoder = new Graphics::TGADecoder(); } else if (_filename.hasSuffix(".jpg")) { _decoder = new Graphics::JPEGDecoder(); } else { diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 5b0f7c94c3..f0ec41a265 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -36,8 +36,8 @@ #include "graphics/decoders/png.h" #include "graphics/decoders/bmp.h" #include "graphics/decoders/jpeg.h" +#include "graphics/decoders/tga.h" #include "engines/wintermute/graphics/transparent_surface.h" -#include "engines/wintermute/graphics/tga.h" #include "graphics/pixelformat.h" #include "graphics/surface.h" #include "common/stream.h" -- cgit v1.2.3 From 2039ea6b8df36c960ff25ae56930357d40e95d1d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 14:01:18 +0200 Subject: WINTERMUTE: Fix g++ warnings listed by LordHoto --- engines/wintermute/base/base_dynamic_buffer.cpp | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 2 +- engines/wintermute/base/base_game.cpp | 2 +- engines/wintermute/base/base_surface_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font.cpp | 2 +- engines/wintermute/base/font/base_font.h | 2 +- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.h | 4 ++-- engines/wintermute/base/font/base_font_truetype.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.h | 2 +- engines/wintermute/base/gfx/base_image.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- 12 files changed, 17 insertions(+), 17 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index 0a7a214ba4..b49d4ce150 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -92,7 +92,7 @@ bool BaseDynamicBuffer::init(uint32 initSize) { ////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::putBytes(byte *buffer, uint32 size) { +bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { if (!_initialized) { init(); } @@ -152,7 +152,7 @@ void BaseDynamicBuffer::putString(const char *val) { putString("(null)"); } else { putDWORD(strlen(val) + 1); - putBytes((byte *)val, strlen(val) + 1); + putBytes((const byte *)val, strlen(val) + 1); } } diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 8285b472b2..926728baa6 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -44,7 +44,7 @@ public: char *getString(); void putString(const char *val); bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); + bool putBytes(const byte *buffer, uint32 size); uint32 getSize(); bool init(uint32 initSize = 0); void cleanup(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index acb20b2454..5436b4637f 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -4356,7 +4356,7 @@ bool BaseGame::displayDebugInfo() { _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); if (_activeObject != NULL) { - _systemFont->drawText((byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + _systemFont->drawText((const byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); } sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0ff325be7d..a829732696 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -176,8 +176,8 @@ bool BaseSurfaceStorage::sortSurfaces() { ////////////////////////////////////////////////////////////////////////// int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - BaseSurface *s1 = *((BaseSurface **)arg1); - BaseSurface *s2 = *((BaseSurface **)arg2); + const BaseSurface *s1 = *((BaseSurface **)arg1); + const BaseSurface *s2 = *((BaseSurface **)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 198b1ae308..8fb2b2b44a 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -52,7 +52,7 @@ BaseFont::~BaseFont() { ////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { } diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index e4413e3410..aaf5aa2367 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -40,7 +40,7 @@ public: DECLARE_PERSISTENT(BaseFont, BaseObject) virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); virtual void initLoop() {}; diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 0913ac9b53..ff1207b31f 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -69,7 +69,7 @@ BaseFontBitmap::~BaseFontBitmap() { ////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontBitmap::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); } @@ -106,7 +106,7 @@ int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { ////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { +int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { if (maxLength == 0) { return 0; } diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 0b873855bb..22cd9c6ba8 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -41,7 +41,7 @@ public: bool loadFile(const Common::String &filename); virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); BaseFontBitmap(BaseGame *inGame); @@ -62,7 +62,7 @@ private: int getCharWidth(byte index); void drawChar(byte c, int x, int y); - int textHeightDraw(byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); + int textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); }; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 0893f36bc5..2c8cd261a9 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -152,7 +152,7 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// -void BaseFontTT::drawText(byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { if (text == NULL || strcmp((char *)text, "") == 0) { return; } diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index fc4de30fc5..93431b039c 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -101,7 +101,7 @@ public: virtual int getTextWidth(byte *text, int maxLength = -1); virtual int getTextHeight(byte *text, int width); - virtual void drawText(byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); bool loadBuffer(byte *buffer); diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index 1184d2bbf7..bf11e15307 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -93,7 +93,7 @@ byte BaseImage::getAlphaAt(int x, int y) const { if (!_surface) { return 0xFF; } - uint32 color = *(uint32 *)_surface->getBasePtr(x, y); + uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); byte r, g, b, a; _surface->format.colorToARGB(color, a, r, g, b); return a; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index d6006528a2..1a6d4fe1e5 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -373,8 +373,8 @@ bool PartEmitter::sortParticlesByZ() { ////////////////////////////////////////////////////////////////////////// int PartEmitter::compareZ(const void *obj1, const void *obj2) { - PartParticle *p1 = *(PartParticle **)obj1; - PartParticle *p2 = *(PartParticle **)obj2; + const PartParticle *p1 = *(PartParticle **)obj1; + const PartParticle *p2 = *(PartParticle **)obj2; if (p1->_posZ < p2->_posZ) { return -1; -- cgit v1.2.3 From 764ca7a51a27210ca7a66a6ab2f01714029af09c Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 14:21:33 +0200 Subject: WINTERMUTE: Fix some of the clang++ warnings listed by LordHoto --- engines/wintermute/base/base_sprite.cpp | 4 +++- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 1 + engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 4 ++-- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 2 +- engines/wintermute/base/scriptables/script_ext_date.h | 1 - 5 files changed, 7 insertions(+), 5 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 6fe5be9e11..2fc2096802 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -137,7 +137,7 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC file = NULL; } - bool ret; + bool ret = STATUS_FAILED; AnsiString filePrefix = filename; AnsiString ext = PathUtil::getExtension(filename); @@ -164,6 +164,8 @@ bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteC if (buffer) { if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); + } else { + ret = STATUS_OK; } delete[] buffer; } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 5859fec74e..44acca0267 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -83,6 +83,7 @@ public: void drawFromTicket(RenderTicket *renderTicket); bool setViewport(int left, int top, int right, int bottom); + bool setViewport(Rect32 *rect) { return BaseRenderer::setViewport(rect); } Rect32 getViewPort(); void modTargetRect(Common::Rect *rect); void pointFromScreen(Point32 *point); diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index f0ec41a265..ea88f19065 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -196,7 +196,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { bool hasTransparency = false; for (int y = 0; y < surface->h; y++) { for (int x = 0; x < surface->w; x++) { - uint32 pixel = getPixel(surface, x, y); + uint32 pixel = getPixelAt(surface, x, y); uint8 r, g, b, a; surface->format.colorToARGB(pixel, a, r, g, b); @@ -220,7 +220,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { } ////////////////////////////////////////////////////////////////////////// -uint32 BaseSurfaceOSystem::getPixel(Graphics::Surface *surface, int x, int y) { +uint32 BaseSurfaceOSystem::getPixelAt(Graphics::Surface *surface, int x, int y) { warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); int bpp = surface->format.bytesPerPixel; /* Here p is the address to the pixel we want to retrieve */ diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 27f9ad047e..1b7146632e 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -86,7 +86,7 @@ private: bool finishLoad(); bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); void genAlphaMask(Graphics::Surface *surface); - uint32 getPixel(Graphics::Surface *surface, int x, int y); + uint32 getPixelAt(Graphics::Surface *surface, int x, int y); bool _hasAlpha; void *_lockPixels; diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 521b7a9f8a..7cdf57e689 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -45,7 +45,6 @@ public: bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); private: - char *_string; TimeDate _tm; Common::String _strRep; }; -- cgit v1.2.3 From 71981aaecf68b6a0910a18cad67cbba9ac7a1fb1 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 16:34:12 +0200 Subject: WINTERMUTE: Simplify getNodeForRelativePath --- engines/wintermute/base/file/base_disk_file.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 2f7450a999..44a8049121 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -71,14 +71,11 @@ static Common::FSNode getNodeForRelativePath(const Common::String &filename) { // Get the next path-component by slicing on '\\' Common::String pathPart = path.nextToken(); // Get the next FSNode in the chain, if it exists as a child from the previous. - Common::FSNode nextNode(curNode.getChild(pathPart)); - if (!nextNode.exists()) { + curNode = curNode.getChild(pathPart); + if (!curNode.isReadable()) { // Return an invalid FSNode. return Common::FSNode(); } - if (nextNode.exists() && nextNode.isReadable()) { - curNode = nextNode; - } // Following the comments in common/fs.h, anything not a directory is a file. if (!curNode.isDirectory()) { if (!path.empty()) { -- cgit v1.2.3 From 3dc5d32e8547c0bbccbb20d6a84ca5307d29ca5e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 16:55:17 +0200 Subject: WINTERMUTE: Replace qsort with Common::sort --- engines/wintermute/base/base_surface_storage.cpp | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index a829732696..0e0976b838 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -169,7 +169,7 @@ bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) ////////////////////////////////////////////////////////////////////////// bool BaseSurfaceStorage::sortSurfaces() { - qsort(&_surfaces[0], _surfaces.size(), sizeof(BaseSurface *), surfaceSortCB); + Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); return STATUS_OK; } diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 1a6d4fe1e5..4fb0eb6637 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -367,7 +367,7 @@ bool PartEmitter::start() { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::sortParticlesByZ() { // sort particles by _posY - qsort(_particles.getData(), _particles.getSize(), sizeof(PartParticle *), PartEmitter::compareZ); + Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); return STATUS_OK; } -- cgit v1.2.3 From b01f09e82fd254823a839a8d4f622dc4d35bde6a Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:28:37 +0200 Subject: WINTERMUTE: Use instead of --- engines/wintermute/base/scriptables/script_ext_math.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 906d807275..f7d0ba20b9 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -31,7 +31,7 @@ #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/persistent.h" #include "common/math.h" -#include +#include namespace Wintermute { -- cgit v1.2.3 From 2fd38f47e04430b8684502e625f87a04dd968def Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 18:25:24 +0200 Subject: WINTERMUTE: Replace col_templ's getSize with Common::Array::size() --- engines/wintermute/base/base_frame.cpp | 40 ++++++++--------- engines/wintermute/base/base_game.cpp | 40 ++++++++--------- engines/wintermute/base/base_region.cpp | 38 ++++++++-------- engines/wintermute/base/base_script_holder.cpp | 22 +++++----- engines/wintermute/base/base_sprite.cpp | 45 +++++++++---------- engines/wintermute/base/font/base_font_bitmap.cpp | 8 ++-- engines/wintermute/base/font/base_font_storage.cpp | 8 ++-- .../wintermute/base/font/base_font_truetype.cpp | 10 ++--- engines/wintermute/base/particles/part_emitter.cpp | 50 +++++++++++----------- .../wintermute/base/particles/part_particle.cpp | 2 +- engines/wintermute/base/scriptables/script.cpp | 2 +- .../wintermute/base/scriptables/script_engine.cpp | 28 ++++++------ .../wintermute/base/scriptables/script_stack.cpp | 18 ++++---- 13 files changed, 151 insertions(+), 160 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 1462f1430d..eb66661c62 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -61,12 +61,12 @@ BaseFrame::~BaseFrame() { delete _sound; _sound = NULL; - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { delete _subframes[i]; } _subframes.clear(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { delete[] _applyEvent[i]; _applyEvent[i] = NULL; } @@ -78,7 +78,7 @@ BaseFrame::~BaseFrame() { bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { bool res; - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); if (DID_FAIL(res)) { return res; @@ -102,7 +102,7 @@ bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { */ } if (owner) { - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { owner->applyEvent(_applyEvent[i]); } } @@ -349,7 +349,7 @@ bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float Rect32 subRect; - for (int i = 0; i < _subframes.getSize(); i++) { + for (int i = 0; i < _subframes.size(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); BasePlatform::unionRect(rect, rect, &subRect); } @@ -381,15 +381,15 @@ bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); } - if (_subframes.getSize() > 0) { + if (_subframes.size() > 0) { _subframes[0]->saveAsText(buffer, indent, false); } - for (int i = 1; i < _subframes.getSize(); i++) { + for (uint32 i = 1; i < _subframes.size(); i++) { _subframes[i]->saveAsText(buffer, indent + 2); } - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); } @@ -469,7 +469,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { + if (index < 0 || index >= _subframes.size()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else { @@ -487,12 +487,12 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _subframes.getSize()) { + if (index < 0 || index >= _subframes.size()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); - for (int i = 0; i < _subframes.getSize(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { if (_subframes[i] == sub) { delete _subframes[i]; _subframes.remove_at(i); @@ -547,7 +547,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac sub->setSurface(filename); } - if (index >= _subframes.getSize()) { + if (index >= (int32)_subframes.size()) { _subframes.add(sub); } else { _subframes.insert_at(index, sub); @@ -563,7 +563,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.getSize()) { + if (index < 0 || index >= _applyEvent.size()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else { @@ -578,7 +578,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "AddEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { stack->pushNULL(); return STATUS_OK; @@ -595,7 +595,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "DeleteEvent") == 0) { stack->correctParams(1); const char *event = stack->pop()->getString(); - for (int i = 0; i < _applyEvent.getSize(); i++) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { if (scumm_stricmp(_applyEvent[i], event) == 0) { delete[] _applyEvent[i]; _applyEvent.remove_at(i); @@ -608,7 +608,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scCallMethod(script, stack, thisStack, name); } else { return BaseScriptable::scCallMethod(script, stack, thisStack, name); @@ -676,7 +676,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.getSize()); + _scValue->setInt(_subframes.size()); return _scValue; } @@ -684,13 +684,13 @@ ScValue *BaseFrame::scGetProperty(const char *name) { // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.getSize()); + _scValue->setInt(_applyEvent.size()); return _scValue; } ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scGetProperty(name); } else { return BaseScriptable::scGetProperty(name); @@ -743,7 +743,7 @@ bool BaseFrame::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// else { - if (_subframes.getSize() == 1) { + if (_subframes.size() == 1) { return _subframes[0]->scSetProperty(name, value); } else { return BaseScriptable::scSetProperty(name, value); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 5436b4637f..e8aaac6c40 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -328,7 +328,7 @@ bool BaseGame::cleanup() { unregisterObject(_fader); _fader = NULL; - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { delete _regObjects[i]; _regObjects[i] = NULL; } @@ -349,7 +349,7 @@ bool BaseGame::cleanup() { _scValue = NULL; _sFX = NULL; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->_owner = NULL; _scripts[i]->finish(); } @@ -361,7 +361,7 @@ bool BaseGame::cleanup() { _fontStorage->removeFont(_videoFont); _videoFont = NULL; - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { delete _quickMessages[i]; } _quickMessages.clear(); @@ -587,7 +587,7 @@ bool BaseGame::initLoop() { getMousePos(&_mousePos); _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { + for (int i = _windows.size() - 1; i >= 0; i--) { if (_windows[i]->_visible) { _focusedWindow = _windows[i]; break; @@ -1922,7 +1922,7 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack else if (strcmp(name, "DeleteWindow") == 0) { stack->correctParams(1); BaseObject *obj = (BaseObject *)stack->pop()->getNative(); - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i] == obj) { unregisterObject(_windows[i]); stack->pushBool(true); @@ -2849,12 +2849,12 @@ const char *BaseGame::scToString() { #define QUICK_MSG_DURATION 3000 ////////////////////////////////////////////////////////////////////////// bool BaseGame::displayQuickMsg() { - if (_quickMessages.getSize() == 0 || !_systemFont) { + if (_quickMessages.size() == 0 || !_systemFont) { return STATUS_OK; } // update - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { delete _quickMessages[i]; _quickMessages.remove_at(i); @@ -2865,7 +2865,7 @@ bool BaseGame::displayQuickMsg() { int posY = 20; // display - for (int i = 0; i < _quickMessages.getSize(); i++) { + for (uint32 i = 0; i < _quickMessages.size(); i++) { _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); } @@ -2876,7 +2876,7 @@ bool BaseGame::displayQuickMsg() { #define MAX_QUICK_MSG 5 ////////////////////////////////////////////////////////////////////////// void BaseGame::quickMessage(const char *text) { - if (_quickMessages.getSize() >= MAX_QUICK_MSG) { + if (_quickMessages.size() >= MAX_QUICK_MSG) { delete _quickMessages[0]; _quickMessages.remove_at(0); } @@ -2911,7 +2911,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { } // is it a window? - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if ((BaseObject *)_windows[i] == object) { _windows.remove_at(i); @@ -2935,7 +2935,7 @@ bool BaseGame::unregisterObject(BaseObject *object) { } // destroy object - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { if (_regObjects[i] == object) { _regObjects.remove_at(i); if (!_loadInProgress) { @@ -2973,7 +2973,7 @@ bool BaseGame::validObject(BaseObject *object) { return true; } - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { if (_regObjects[i] == object) { return true; } @@ -3322,7 +3322,7 @@ bool BaseGame::displayWindows(bool inGame) { // did we lose focus? focus topmost window if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { _focusedWindow = NULL; - for (int i = _windows.getSize() - 1; i >= 0; i--) { + for (int i = _windows.size() - 1; i >= 0; i--) { if (_windows[i]->_visible && !_windows[i]->_disable) { _focusedWindow = _windows[i]; break; @@ -3331,7 +3331,7 @@ bool BaseGame::displayWindows(bool inGame) { } // display all windows - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { res = _windows[i]->display(); @@ -3656,9 +3656,9 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { bool BaseGame::focusWindow(UIWindow *window) { UIWindow *prev = _focusedWindow; - for (int i = 0; i < _windows.getSize(); i++) { + for (uint32 i = 0; i < _windows.size(); i++) { if (_windows[i] == window) { - if (i < _windows.getSize() - 1) { + if (i < _windows.size() - 1) { _windows.remove_at(i); _windows.add(window); @@ -3854,7 +3854,7 @@ bool BaseGame::setActiveObject(BaseObject *obj) { ////////////////////////////////////////////////////////////////////////// bool BaseGame::pushViewport(BaseViewport *viewport) { _viewportSP++; - if (_viewportSP >= _viewportStack.getSize()) { + if (_viewportSP >= (int32)_viewportStack.size()) { _viewportStack.add(viewport); } else { _viewportStack[_viewportSP] = viewport; @@ -3873,7 +3873,7 @@ bool BaseGame::popViewport() { _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); } - if (_viewportSP >= 0 && _viewportSP < _viewportStack.getSize()) { + if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); } else _renderer->setViewport(_renderer->_drawOffsetX, _renderer->_drawOffsetY, @@ -4065,7 +4065,7 @@ void BaseGame::DEBUG_DumpClassRegistry() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::invalidateDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { _regObjects[i]->invalidateDeviceObjects(); } return STATUS_OK; @@ -4074,7 +4074,7 @@ bool BaseGame::invalidateDeviceObjects() { ////////////////////////////////////////////////////////////////////////// bool BaseGame::restoreDeviceObjects() { - for (int i = 0; i < _regObjects.getSize(); i++) { + for (uint32 i = 0; i < _regObjects.size(); i++) { _regObjects[i]->restoreDeviceObjects(); } return STATUS_OK; diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index a781c7eeb7..4d7f3487f0 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -60,7 +60,7 @@ BaseRegion::~BaseRegion() { ////////////////////////////////////////////////////////////////////////// void BaseRegion::cleanup() { - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -78,7 +78,7 @@ bool BaseRegion::createRegion() { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::pointInRegion(int x, int y) { - if (_points.getSize() < 3) { + if (_points.size() < 3) { return false; } @@ -160,9 +160,7 @@ bool BaseRegion::loadBuffer(byte *buffer, bool complete) { buffer = params; } - int i; - - for (i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { delete _points[i]; } _points.clear(); @@ -248,7 +246,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { _points.insert_at(index, new BasePoint(x, y)); createRegion(); @@ -269,7 +267,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta int x = stack->pop()->getInt(); int y = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { _points[index]->x = x; _points[index]->y = y; createRegion(); @@ -289,7 +287,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { delete _points[index]; _points[index] = NULL; @@ -311,7 +309,7 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta stack->correctParams(1); int index = stack->pop()->getInt(); - if (index >= 0 && index < _points.getSize()) { + if (index >= 0 && index < (int32)_points.size()) { ScValue *val = stack->getPushValue(); if (val) { val->setProperty("X", _points[index]->x); @@ -360,7 +358,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { // NumPoints ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.getSize()); + _scValue->setInt(_points.size()); return _scValue; } else { return BaseObject::scGetProperty(name); @@ -409,13 +407,11 @@ bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *n buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - for (i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); } @@ -451,7 +447,7 @@ typedef struct { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::ptInPolygon(int x, int y) { - if (_points.getSize() < 3) { + if (_points.size() < 3) { return false; } @@ -465,9 +461,9 @@ bool BaseRegion::ptInPolygon(int x, int y) { p1.x = (double)_points[0]->x; p1.y = (double)_points[0]->y; - for (int i = 1; i <= _points.getSize(); i++) { - p2.x = (double)_points[i % _points.getSize()]->x; - p2.y = (double)_points[i % _points.getSize()]->y; + for (uint32 i = 1; i <= _points.size(); i++) { + p2.x = (double)_points[i % _points.size()]->x; + p2.y = (double)_points[i % _points.size()]->y; if (p.y > MIN(p1.y, p2.y)) { if (p.y <= MAX(p1.y, p2.y)) { @@ -494,12 +490,12 @@ bool BaseRegion::ptInPolygon(int x, int y) { ////////////////////////////////////////////////////////////////////////// bool BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.getSize() == 0) { + if (_points.size() == 0) { BasePlatform::setRectEmpty(rect); } else { int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; - for (int i = 0; i < _points.getSize(); i++) { + for (uint32 i = 0; i < _points.size(); i++) { minX = MIN(minX, _points[i]->x); minY = MIN(minY, _points[i]->y); @@ -520,7 +516,7 @@ bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { cleanup(); - for (int i = 0; i < region->_points.getSize(); i++) { + for (uint32 i = 0; i < region->_points.size(); i++) { int xVal, yVal; xVal = (int)((float)region->_points[i]->x * scale / 100.0f); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d57638a4a8..e4132351e0 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -58,9 +58,7 @@ bool BaseScriptHolder::cleanup() { delete[] _filename; _filename = NULL; - int i; - - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->finish(true); _scripts[i]->_owner = NULL; } @@ -90,7 +88,7 @@ bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { int numHandlers = 0; bool ret = STATUS_FAILED; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread) { ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); if (handler) { @@ -186,7 +184,7 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t const char *filename = stack->pop()->getString(); bool killThreads = stack->pop()->getBool(false); bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { _scripts[i]->finish(killThreads); ret = true; @@ -205,7 +203,7 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t stack->correctParams(1); const char *filename = stack->pop()->getString(); bool ret = false; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { ret = true; break; @@ -300,7 +298,7 @@ bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::addScript(const char *filename) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { if (_scripts[i]->_state != SCRIPT_FINISHED) { _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); @@ -334,7 +332,7 @@ bool BaseScriptHolder::addScript(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::removeScript(ScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] == script) { _scripts.remove_at(i); break; @@ -345,7 +343,7 @@ bool BaseScriptHolder::removeScript(ScScript *script) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleEvent(const char *EventName) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { return true; } @@ -356,7 +354,7 @@ bool BaseScriptHolder::canHandleEvent(const char *EventName) { ////////////////////////////////////////////////////////////////////////// bool BaseScriptHolder::canHandleMethod(const char *MethodName) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { return true; } @@ -452,7 +450,7 @@ bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { ////////////////////////////////////////////////////////////////////////// void BaseScriptHolder::makeFreezable(bool freezable) { _freezable = freezable; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->_freezable = freezable; } @@ -461,7 +459,7 @@ void BaseScriptHolder::makeFreezable(bool freezable) { ////////////////////////////////////////////////////////////////////////// ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.getSize() - 1; i >= 0; i--) { + for (int i = _scripts.size() - 1; i >= 0; i--) { if (_scripts[i]->canHandleMethod(methodName)) { ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 2fc2096802..ae0e844cb5 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -88,7 +88,7 @@ void BaseSprite::setDefaults() { void BaseSprite::cleanup() { BaseScriptHolder::cleanup(); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { delete _frames[i]; } _frames.clear(); @@ -103,7 +103,7 @@ void BaseSprite::cleanup() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { getCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return STATUS_OK; } @@ -334,7 +334,7 @@ bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCa ////////////////////////////////////////////////////////////////////// void BaseSprite::reset() { - if (_frames.getSize() > 0) { + if (_frames.size() > 0) { _currentFrame = 0; } else { _currentFrame = -1; @@ -367,10 +367,10 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { // get current frame if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < _frames.getSize() - 1) { + if (_currentFrame < (int32)_frames.size() - 1) { _currentFrame++; if (_continuous) { - _canBreak = (_currentFrame == _frames.getSize() - 1); + _canBreak = (_currentFrame == (int32)_frames.size() - 1); } } else { if (_looping) { @@ -385,13 +385,13 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { _lastFrameTime = timer; } - _changed = (lastFrame != _currentFrame || (_looping && _frames.getSize() == 1)); + _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); if (_lastFrameTime == 0) { _lastFrameTime = timer; _changed = true; if (_continuous) { - _canBreak = (_currentFrame == _frames.getSize() - 1); + _canBreak = (_currentFrame == (int32)_frames.size() - 1); } } @@ -411,7 +411,7 @@ bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { ////////////////////////////////////////////////////////////////////// bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return STATUS_OK; } @@ -432,11 +432,11 @@ bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, flo ////////////////////////////////////////////////////////////////////////// BaseSurface *BaseSprite::getSurface() { // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= _frames.getSize()) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { return NULL; } BaseFrame *frame = _frames[_currentFrame]; - if (frame && frame->_subframes.getSize() > 0) { + if (frame && frame->_subframes.size() > 0) { BaseSubFrame *subframe = frame->_subframes[0]; if (subframe) { return subframe->_surface; @@ -455,7 +455,7 @@ bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float } BasePlatform::setRectEmpty(rect); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { Rect32 frame; Rect32 temp; BasePlatform::copyRect(&temp, rect); @@ -493,15 +493,12 @@ bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { BaseScriptHolder::saveAsText(buffer, indent + 2); - int i; - // scripts - for (i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); } - - for (i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { _frames[i]->saveAsText(buffer, indent + 2); } @@ -554,7 +551,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta if (strcmp(name, "GetFrame") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _frames.getSize()) { + if (index < 0 || index >= (int32)_frames.size()) { script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); stack->pushNULL(); } else { @@ -571,14 +568,14 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _frames.getSize()) { + if (index < 0 || index >= (int32)_frames.size()) { script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); } } else { BaseFrame *frame = (BaseFrame *)val->getNative(); - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { if (_frames[i] == frame) { - if (i == _currentFrame) { + if (i == (uint32)_currentFrame) { _lastFrameTime = 0; } delete _frames[i]; @@ -654,7 +651,7 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta } } - if (index >= _frames.getSize()) { + if (index >= (int32)_frames.size()) { _frames.add(frame); } else { _frames.insert_at(index, frame); @@ -704,7 +701,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.getSize()); + _scValue->setInt(_frames.size()); return _scValue; } @@ -771,7 +768,7 @@ bool BaseSprite::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// if (strcmp(name, "CurrentFrame") == 0) { _currentFrame = value->getInt(0); - if (_currentFrame >= _frames.getSize() || _currentFrame < 0) { + if (_currentFrame >= (int32)_frames.size() || _currentFrame < 0) { _currentFrame = -1; } _lastFrameTime = 0; @@ -806,7 +803,7 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { - for (int i = 0; i < _frames.getSize(); i++) { + for (uint32 i = 0; i < _frames.size(); i++) { if (_frames[i]->_sound) { _frames[i]->_sound->stop(); } diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index ff1207b31f..a9d71e0fa1 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -256,8 +256,8 @@ void BaseFontBitmap::drawChar(byte c, int x, int y) { bool handled = false; if (_sprite) { _sprite->getCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < _sprite->_frames.getSize() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.getSize() > 0) { + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < (int32)_sprite->_frames.size() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.size() > 0) { _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); } handled = true; @@ -532,8 +532,8 @@ bool BaseFontBitmap::getWidths() { BaseSurface *surf = NULL; if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < _sprite->_frames.getSize()) { - if (_sprite->_frames[_widthsFrame] && _sprite->_frames[_widthsFrame]->_subframes.getSize() > 0) { + if (_widthsFrame >= 0 && _widthsFrame < (int32)_sprite->_frames.size()) { + if (_sprite->_frames[_widthsFrame] && (int32)_sprite->_frames[_widthsFrame]->_subframes.size() > 0) { surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; } } diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index bc7ab6f22c..298417ec32 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -51,7 +51,7 @@ BaseFontStorage::~BaseFontStorage() { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::cleanup(bool warn) { - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (warn) { _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); } @@ -64,7 +64,7 @@ bool BaseFontStorage::cleanup(bool warn) { ////////////////////////////////////////////////////////////////////////// bool BaseFontStorage::initLoop() { - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { _fonts[i]->initLoop(); } return STATUS_OK; @@ -76,7 +76,7 @@ BaseFont *BaseFontStorage::addFont(const Common::String &filename) { return NULL; } - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { _fonts[i]->_refCount++; return _fonts[i]; @@ -112,7 +112,7 @@ bool BaseFontStorage::removeFont(BaseFont *font) { return STATUS_FAILED; } - for (int i = 0; i < _fonts.getSize(); i++) { + for (uint32 i = 0; i < _fonts.size(); i++) { if (_fonts[i] == font) { _fonts[i]->_refCount--; if (_fonts[i]->_refCount <= 0) { diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 2c8cd261a9..19c5cef7ee 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -69,7 +69,7 @@ BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { BaseFontTT::~BaseFontTT(void) { clearCache(); - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { delete _layers[i]; } _layers.clear(); @@ -224,7 +224,7 @@ void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign if (surface) { Rect32 rc; BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (int i = 0; i < _layers.getSize(); i++) { + for (uint32 i = 0; i < _layers.size(); i++) { uint32 color = _layers[i]->_color; uint32 origForceAlpha = renderer->_forceAlphaColor; if (renderer->_forceAlphaColor != 0) { @@ -433,7 +433,7 @@ bool BaseFontTT::loadBuffer(byte *buffer) { } // create at least one layer - if (_layers.getSize() == 0) { + if (_layers.size() == 0) { BaseTTFontLayer *layer = new BaseTTFontLayer; layer->_color = baseColor; _layers.add(layer); @@ -508,13 +508,13 @@ bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { // persist layers int numLayers; if (persistMgr->getIsSaving()) { - numLayers = _layers.getSize(); + numLayers = _layers.size(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { _layers[i]->persist(persistMgr); } } else { - numLayers = _layers.getSize(); + numLayers = _layers.size(); persistMgr->transfer(TMEMBER(numLayers)); for (int i = 0; i < numLayers; i++) { BaseTTFontLayer *layer = new BaseTTFontLayer; diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 4fb0eb6637..f52a1b8c82 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -94,18 +94,18 @@ PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject ////////////////////////////////////////////////////////////////////////// PartEmitter::~PartEmitter(void) { - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { delete _particles[i]; } _particles.clear(); - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { delete _forces[i]; } _forces.clear(); - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { delete[] _sprites[i]; } _sprites.clear(); @@ -121,7 +121,7 @@ bool PartEmitter::addSprite(const char *filename) { } // do we already have the file? - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { return STATUS_OK; } @@ -145,7 +145,7 @@ bool PartEmitter::addSprite(const char *filename) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeSprite(const char *filename) { - for (int i = 0; i < _sprites.getSize(); i++) { + for (uint32 i = 0; i < _sprites.size(); i++) { if (scumm_stricmp(filename, _sprites[i]) == 0) { delete[] _sprites[i]; _sprites.remove_at(i); @@ -160,7 +160,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 if (!particle) { return STATUS_FAILED; } - if (_sprites.getSize() == 0) { + if (_sprites.size() == 0) { return STATUS_FAILED; } @@ -190,7 +190,7 @@ bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint3 } float angle = BaseUtils::randomAngle(_angle1, _angle2); - int spriteIndex = BaseUtils::randomInt(0, _sprites.getSize() - 1); + int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); @@ -259,7 +259,7 @@ bool PartEmitter::update() { bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int numLive = 0; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->update(this, currentTime, timerDelta); if (!_particles[i]->_isDead) { @@ -282,7 +282,7 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { int toGen = MIN(_genAmount, _maxParticles - numLive); while (toGen > 0) { int firstDeadIndex = -1; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i]->_isDead) { firstDeadIndex = i; break; @@ -319,11 +319,11 @@ bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::display(BaseRegion *region) { - if (_sprites.getSize() <= 1) { + if (_sprites.size() <= 1) { _gameRef->_renderer->startSpriteBatch(); } - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (region != NULL && _useRegion) { if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { continue; @@ -333,7 +333,7 @@ bool PartEmitter::display(BaseRegion *region) { _particles[i]->display(this); } - if (_sprites.getSize() <= 1) { + if (_sprites.size() <= 1) { _gameRef->_renderer->endSpriteBatch(); } @@ -342,7 +342,7 @@ bool PartEmitter::display(BaseRegion *region) { ////////////////////////////////////////////////////////////////////////// bool PartEmitter::start() { - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->_isDead = true; } _running = true; @@ -406,7 +406,7 @@ bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int PartForce *PartEmitter::addForceByName(const Common::String &name) { PartForce *force = NULL; - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { force = _forces[i]; break; @@ -443,7 +443,7 @@ bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType typ ////////////////////////////////////////////////////////////////////////// bool PartEmitter::removeForce(const Common::String &name) { - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { delete _forces[i]; _forces.remove_at(i); @@ -524,7 +524,7 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt else if (strcmp(name, "Stop") == 0) { stack->correctParams(0); - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { delete _particles[i]; } _particles.clear(); @@ -787,7 +787,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else if (strcmp(name, "NumLiveParticles") == 0) { int numAlive = 0; - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i] && !_particles[i]->_isDead) { numAlive++; } @@ -1218,32 +1218,32 @@ bool PartEmitter::persist(BasePersistenceManager *persistMgr) { _sprites.persist(persistMgr); - int numForces; + uint32 numForces; if (persistMgr->getIsSaving()) { - numForces = _forces.getSize(); + numForces = _forces.size(); persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < _forces.getSize(); i++) { + for (uint32 i = 0; i < _forces.size(); i++) { _forces[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(numForces)); - for (int i = 0; i < numForces; i++) { + for (uint32 i = 0; i < numForces; i++) { PartForce *force = new PartForce(_gameRef); force->persist(persistMgr); _forces.add(force); } } - int numParticles; + uint32 numParticles; if (persistMgr->getIsSaving()) { - numParticles = _particles.getSize(); + numParticles = _particles.size(); persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < _particles.getSize(); i++) { + for (uint32 i = 0; i < _particles.size(); i++) { _particles[i]->persist(persistMgr); } } else { persistMgr->transfer(TMEMBER(numParticles)); - for (int i = 0; i < numParticles; i++) { + for (uint32 i = 0; i < numParticles; i++) { PartParticle *particle = new PartParticle(_gameRef); particle->persist(persistMgr); _particles.add(particle); diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 9247514ac3..5f523612b8 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -148,7 +148,7 @@ bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timer // update position float elapsedTime = (float)timerDelta / 1000.f; - for (int i = 0; i < emitter->_forces.getSize(); i++) { + for (uint32 i = 0; i < emitter->_forces.size(); i++) { PartForce *force = emitter->_forces[i]; switch (force->_type) { case PartForce::FORCE_GLOBAL: diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 6c8a88adb0..beef4ee9d2 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1423,7 +1423,7 @@ bool ScScript::copyParameters(ScStack *stack) { ////////////////////////////////////////////////////////////////////////// bool ScScript::finishThreads() { - for (int i = 0; i < _engine->_scripts.getSize(); i++) { + for (uint32 i = 0; i < _engine->_scripts.size(); i++) { ScScript *scr = _engine->_scripts[i]; if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { scr->finish(true); diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 575e24a3a3..d518be579f 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -95,7 +95,7 @@ ScEngine::~ScEngine() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::cleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); } @@ -248,19 +248,19 @@ byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ig ////////////////////////////////////////////////////////////////////////// bool ScEngine::tick() { - if (_scripts.getSize() == 0) { + if (_scripts.size() == 0) { return STATUS_OK; } // resolve waiting scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { switch (_scripts[i]->_state) { case SCRIPT_WAITING: { /* bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.getSize(); j++) + for(int j=0; j<_gameRef->_regObjects.size(); j++) { if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) { @@ -318,7 +318,7 @@ bool ScEngine::tick() { // execute scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { // skip paused scripts if (_scripts[i]->_state == SCRIPT_PAUSED) { @@ -365,7 +365,7 @@ bool ScEngine::tick() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::tickUnbreakable() { // execute unbreakable scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (!_scripts[i]->_unbreakable) { continue; } @@ -386,7 +386,7 @@ bool ScEngine::tickUnbreakable() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::removeFinishedScripts() { // remove finished scripts - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { if (!_scripts[i]->_thread && _scripts[i]->_owner) { _scripts[i]->_owner->removeScript(_scripts[i]); @@ -405,7 +405,7 @@ bool ScEngine::removeFinishedScripts() { int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_FINISHED) { continue; } @@ -456,7 +456,7 @@ bool ScEngine::emptyScriptCache() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resetObject(BaseObject *Object) { // terminate all scripts waiting for this object - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { if (!_gameRef->_compatKillMethodThreads) { resetScript(_scripts[i]); @@ -472,7 +472,7 @@ bool ScEngine::resetObject(BaseObject *Object) { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resetScript(ScScript *script) { // terminate all scripts waiting for this script - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { _scripts[i]->finish(); } @@ -497,7 +497,7 @@ bool ScEngine::persist(BasePersistenceManager *persistMgr) { ////////////////////////////////////////////////////////////////////////// void ScEngine::editorCleanup() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { delete _scripts[i]; _scripts.remove_at(i); @@ -509,7 +509,7 @@ void ScEngine::editorCleanup() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::pauseAll() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] != _currentScript) { _scripts[i]->pause(); } @@ -521,7 +521,7 @@ bool ScEngine::pauseAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::resumeAll() { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { _scripts[i]->resume(); } @@ -531,7 +531,7 @@ bool ScEngine::resumeAll() { ////////////////////////////////////////////////////////////////////////// bool ScEngine::isValidScript(ScScript *script) { - for (int i = 0; i < _scripts.getSize(); i++) { + for (uint32 i = 0; i < _scripts.size(); i++) { if (_scripts[i] == script) { return true; } diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index 7e81cdaf17..d27748abe6 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -44,10 +44,10 @@ ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { ScStack::~ScStack() { #if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.getSize(), _sP); + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); #endif - for (int i = 0; i < _values.getSize(); i++) { + for (uint32 i = 0; i < _values.size(); i++) { delete _values[i]; } _values.clear(); @@ -69,7 +69,7 @@ ScValue *ScStack::pop() { void ScStack::push(ScValue *val) { _sP++; - if (_sP < _values.getSize()) { + if (_sP < (int32)_values.size()) { _values[_sP]->cleanup(); _values[_sP]->copy(val); } else { @@ -84,7 +84,7 @@ void ScStack::push(ScValue *val) { ScValue *ScStack::getPushValue() { _sP++; - if (_sP >= _values.getSize()) { + if (_sP >= (int32)_values.size()) { ScValue *val = new ScValue(_gameRef); _values.add(val); } @@ -96,7 +96,7 @@ ScValue *ScStack::getPushValue() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= _values.getSize()) { + if (_sP < 0 || _sP >= (int32)_values.size()) { return NULL; } else { return _values[_sP]; @@ -107,7 +107,7 @@ ScValue *ScStack::getTop() { ////////////////////////////////////////////////////////////////////////// ScValue *ScStack::getAt(int index) { index = _sP - index; - if (index < 0 || index >= _values.getSize()) { + if (index < 0 || index >= (int32)_values.size()) { return NULL; } else { return _values[index]; @@ -136,9 +136,9 @@ void ScStack::correctParams(uint32 expectedParams) { nuParams++; _sP++; - if (_values.getSize() > _sP + 1) { - delete _values[_values.getSize() - 1]; - _values.remove_at(_values.getSize() - 1); + if ((int32)_values.size() > _sP + 1) { + delete _values[_values.size() - 1]; + _values.remove_at(_values.size() - 1); } } } -- cgit v1.2.3 From 07c27b775c8d3997bf40891c2772ae8859eb534d Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:35:49 +0200 Subject: WINTERMUTE: Cleanup the header-guards. --- engines/wintermute/base/base.h | 4 ++-- engines/wintermute/base/base_active_rect.h | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 4 ++-- engines/wintermute/base/base_fader.h | 4 ++-- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/base_frame.h | 4 ++-- engines/wintermute/base/base_game.h | 4 ++-- engines/wintermute/base/base_keyboard_state.h | 4 ++-- engines/wintermute/base/base_named_object.h | 4 ++-- engines/wintermute/base/base_object.h | 4 ++-- engines/wintermute/base/base_parser.h | 4 ++-- engines/wintermute/base/base_persistence_manager.h | 4 ++-- engines/wintermute/base/base_point.h | 4 ++-- engines/wintermute/base/base_quick_msg.h | 4 ++-- engines/wintermute/base/base_region.h | 4 ++-- engines/wintermute/base/base_save_thumb_helper.h | 4 ++-- engines/wintermute/base/base_script_holder.h | 4 ++-- engines/wintermute/base/base_scriptable.h | 4 ++-- engines/wintermute/base/base_sprite.h | 4 ++-- engines/wintermute/base/base_string_table.h | 4 ++-- engines/wintermute/base/base_sub_frame.h | 4 ++-- engines/wintermute/base/base_surface_storage.h | 4 ++-- engines/wintermute/base/base_transition_manager.h | 4 ++-- engines/wintermute/base/base_viewport.h | 4 ++-- engines/wintermute/base/file/base_disk_file.h | 4 ++-- engines/wintermute/base/file/base_file.h | 4 ++-- engines/wintermute/base/file/base_file_entry.h | 4 ++-- engines/wintermute/base/file/base_package.h | 4 ++-- engines/wintermute/base/file/base_resources.h | 4 ++-- engines/wintermute/base/file/base_save_thumb_file.h | 4 ++-- engines/wintermute/base/file/dcpackage.h | 2 +- engines/wintermute/base/font/base_font.h | 4 ++-- engines/wintermute/base/font/base_font_bitmap.h | 4 ++-- engines/wintermute/base/font/base_font_storage.h | 4 ++-- engines/wintermute/base/font/base_font_truetype.h | 4 ++-- engines/wintermute/base/gfx/base_image.h | 4 ++-- engines/wintermute/base/gfx/base_renderer.h | 4 ++-- engines/wintermute/base/gfx/base_surface.h | 4 ++-- engines/wintermute/base/gfx/osystem/base_render_osystem.h | 6 +++--- engines/wintermute/base/gfx/osystem/base_surface_osystem.h | 6 +++--- engines/wintermute/base/sound/base_sound.h | 4 ++-- engines/wintermute/base/sound/base_sound_buffer.h | 4 ++-- engines/wintermute/base/sound/base_sound_manager.h | 4 ++-- 43 files changed, 87 insertions(+), 87 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index b1b184b2f4..b07065ec0d 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BBASE_H -#define WINTERMUTE_BBASE_H +#ifndef WINTERMUTE_BASE_BASE_H +#define WINTERMUTE_BASE_BASE_H #include "engines/wintermute/wintypes.h" #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index b446dadcce..848b77e56e 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BACTIVERECT_H -#define WINTERMUTE_BACTIVERECT_H +#ifndef WINTERMUTE_BASE_ACTIVERECT_H +#define WINTERMUTE_BASE_BACTIVERECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 926728baa6..23aebfdf9f 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BDYNBUFFER_H -#define WINTERMUTE_BDYNBUFFER_H +#ifndef WINTERMUTE_BASE_DYNBUFFER_H +#define WINTERMUTE_BASE_DYNBUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 34d0e7d3da..30072babfa 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFADER_H -#define WINTERMUTE_BFADER_H +#ifndef WINTERMUTE_BASE_FADER_H +#define WINTERMUTE_BASE_FADER_H #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 5e18a95786..3716dd0581 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILEMANAGER_H -#define WINTERMUTE_BFILEMANAGER_H +#ifndef WINTERMUTE_BASE_FILEMANAGER_H +#define WINTERMUTE_BASE_FILEMANAGER_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index b1eae6b659..c89fb49e61 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFRAME_H -#define WINTERMUTE_BFRAME_H +#ifndef WINTERMUTE_BASE_FRAME_H +#define WINTERMUTE_BASE_FRAME_H #include "engines/wintermute/base/base_scriptable.h" #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 43efad1482..aecbe31722 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BGAME_H -#define WINTERMUTE_BGAME_H +#ifndef WINTERMUTE_BASE_GAME_H +#define WINTERMUTE_BASE_GAME_H #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index 382dd9fbce..4b1826d483 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BKEYBOARD_STATE_H -#define WINTERMUTE_BKEYBOARD_STATE_H +#ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H +#define WINTERMUTE_BASE_KEYBOARD_STATE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index cd856bb008..ca71471521 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BNAMEDOBJECT_H -#define WINTERMUTE_BNAMEDOBJECT_H +#ifndef WINTERMUTE_BASE_NAMEDOBJECT_H +#define WINTERMUTE_BASE_NAMEDOBJECT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 34d9ca89ca..e1a21e91ba 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BOBJECT_H -#define WINTERMUTE_BOBJECT_H +#ifndef WINTERMUTE_BASE_OBJECT_H +#define WINTERMUTE_BASE_OBJECT_H #include "engines/wintermute/base/base_script_holder.h" diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 3d63668059..6b4f733d74 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPARSER_H -#define WINTERMUTE_BPARSER_H +#ifndef WINTERMUTE_BASE_PARSER_H +#define WINTERMUTE_BASE_PARSER_H #define TOKEN_DEF_START \ diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index fea8f231d1..4de1f84c64 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPERSISTMGR_H -#define WINTERMUTE_BPERSISTMGR_H +#ifndef WINTERMUTE_BASE_PERSISTMGR_H +#define WINTERMUTE_BASE_PERSISTMGR_H #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 68a37c0110..43f8f960f1 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPOINT_H -#define WINTERMUTE_BPOINT_H +#ifndef WINTERMUTE_BASE_POINT_H +#define WINTERMUTE_BASE_POINT_H #include "engines/wintermute/persistent.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index bef81827b0..d00b302baf 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BQUICKMSG_H -#define WINTERMUTE_BQUICKMSG_H +#ifndef WINTERMUTE_BASE_QUICKMSG_H +#define WINTERMUTE_BASE_QUICKMSG_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index f456eb07fc..e7ae9bda13 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BREGION_H -#define WINTERMUTE_BREGION_H +#ifndef WINTERMUTE_BASE_REGION_H +#define WINTERMUTE_BASE_REGION_H #include "engines/wintermute/base/base_point.h" #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index 4131cf89d4..7c06384aa1 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -25,8 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSAVETHUMBHELPER_H -#define WINTERMUTE_BSAVETHUMBHELPER_H +#ifndef WINTERMUTE_BASE_SAVETHUMBHELPER_H +#define WINTERMUTE_BASE_SAVETHUMBHELPER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 4f3d5f4ef9..cab0d4f693 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSCRIPTHOLDER_H -#define WINTERMUTE_BSCRIPTHOLDER_H +#ifndef WINTERMUTE_BASE_SCRIPTHOLDER_H +#define WINTERMUTE_BASE_SCRIPTHOLDER_H #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/persistent.h" diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 2501f34561..11cb0bcf9f 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSCRIPTABLE_H -#define WINTERMUTE_BSCRIPTABLE_H +#ifndef WINTERMUTE_BASE_SCRIPTABLE_H +#define WINTERMUTE_BASE_SCRIPTABLE_H #include "engines/wintermute/base/base_named_object.h" diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index a02e69c63f..db9931c6f3 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSPRITE_H -#define WINTERMUTE_BSPRITE_H +#ifndef WINTERMUTE_BASE_SPRITE_H +#define WINTERMUTE_BASE_SPRITE_H #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index c8df25810e..46295426fd 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSTRINGTABLE_H -#define WINTERMUTE_BSTRINGTABLE_H +#ifndef WINTERMUTE_BASE_STRINGTABLE_H +#define WINTERMUTE_BASE_STRINGTABLE_H #include "common/hashmap.h" diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 935fb667d4..e89a189e2d 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSUBFRAME_H -#define WINTERMUTE_BSUBFRAME_H +#ifndef WINTERMUTE_BASE_SUBFRAME_H +#define WINTERMUTE_BASE_SUBFRAME_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index f1757b3a32..741177ae76 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACESTORAGE_H -#define WINTERMUTE_BSURFACESTORAGE_H +#ifndef WINTERMUTE_BASE_SURFACESTORAGE_H +#define WINTERMUTE_BASE_SURFACESTORAGE_H #include "engines/wintermute/base/base.h" #include "common/array.h" diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 412361a543..daf2299c2f 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BTRANSITIONMGR_H -#define WINTERMUTE_BTRANSITIONMGR_H +#ifndef WINTERMUTE_BASE_TRANSITIONMGR_H +#define WINTERMUTE_BASE_TRANSITIONMGR_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index 1080c1d806..c94beeb2b1 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BVIEWPORT_H -#define WINTERMUTE_BVIEWPORT_H +#ifndef WINTERMUTE_BASE_VIEWPORT_H +#define WINTERMUTE_BASE_VIEWPORT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 8be06199de..69644408d0 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BDISKFILE_H -#define WINTERMUTE_BDISKFILE_H +#ifndef WINTERMUTE_BASE_DISKFILE_H +#define WINTERMUTE_BASE_DISKFILE_H #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index f9947fe64f..7ae36d5ad1 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILE_H -#define WINTERMUTE_BFILE_H +#ifndef WINTERMUTE_BASE_FILE_H +#define WINTERMUTE_BASE_FILE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 7e71a486ef..6dd4bc08a4 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFILEENTRY_H -#define WINTERMUTE_BFILEENTRY_H +#ifndef WINTERMUTE_BASE_FILEENTRY_H +#define WINTERMUTE_BASE_FILEENTRY_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 676675b041..23d7d7690f 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BPACKAGE_H -#define WINTERMUTE_BPACKAGE_H +#ifndef WINTERMUTE_BASE_PACKAGE_H +#define WINTERMUTE_BASE_PACKAGE_H #include "common/archive.h" #include "common/stream.h" diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 596ac64dd7..48a0f534d0 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRESOURCES_H -#define WINTERMUTE_BRESOURCES_H +#ifndef WINTERMUTE_BASE_RESOURCES_H +#define WINTERMUTE_BASE_RESOURCES_H #include "common/stream.h" #include "common/str.h" diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index e68dc06904..377e06f02c 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSAVETHUMBFILE_H -#define WINTERMUTE_BSAVETHUMBFILE_H +#ifndef WINTERMUTE_BASE_SAVETHUMBFILE_H +#define WINTERMUTE_BASE_SAVETHUMBFILE_H #include "engines/wintermute/base/file/base_file.h" diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 42c0b75e55..82f1998527 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -77,4 +77,4 @@ v2: uint32 TimeDate1 } // end of namespace Wintermute -#endif // _DCPACKAGE_H_ +#endif diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index aaf5aa2367..461a724160 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONT_H -#define WINTERMUTE_BFONT_H +#ifndef WINTERMUTE_BASE_FONT_H +#define WINTERMUTE_BASE_FONT_H #include "engines/wintermute/base/base_object.h" diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 22cd9c6ba8..14a6e1cc87 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTBITMAP_H -#define WINTERMUTE_BFONTBITMAP_H +#ifndef WINTERMUTE_BASE_FONTBITMAP_H +#define WINTERMUTE_BASE_FONTBITMAP_H #include "engines/wintermute/base/font/base_font.h" diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 498096a5a8..733e1c5da3 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTSTORAGE_H -#define WINTERMUTE_BFONTSTORAGE_H +#ifndef WINTERMUTE_BASE_FONTSTORAGE_H +#define WINTERMUTE_BASE_FONTSTORAGE_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 93431b039c..a93e4efacb 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BFONTTT_H -#define WINTERMUTE_BFONTTT_H +#ifndef WINTERMUTE_BASE_FONTTT_H +#define WINTERMUTE_BASE_FONTTT_H #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font.h" diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 7bf901fe40..560a5f0d74 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BIMAGE_H -#define WINTERMUTE_BIMAGE_H +#ifndef WINTERMUTE_BASE_IMAGE_H +#define WINTERMUTE_BASE_IMAGE_H #include "graphics/surface.h" #include "graphics/pixelformat.h" diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 1b284b044d..26d7e6db57 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRENDERER_H -#define WINTERMUTE_BRENDERER_H +#ifndef WINTERMUTE_BASE_RENDERER_H +#define WINTERMUTE_BASE_RENDERER_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index 3be61477ba..f45856f652 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACE_H -#define WINTERMUTE_BSURFACE_H +#ifndef WINTERMUTE_BASE_SURFACE_H +#define WINTERMUTE_BASE_SURFACE_H #include "engines/wintermute/base/base.h" #include "engines/wintermute/math/rect32.h" diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index 44acca0267..aebb4cf888 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BRENDERER_SDL_H -#define WINTERMUTE_BRENDERER_SDL_H +#ifndef WINTERMUTE_BASE_RENDERER_SDL_H +#define WINTERMUTE_BASE_RENDERER_SDL_H #include "engines/wintermute/base/gfx/base_renderer.h" #include "common/rect.h" @@ -128,4 +128,4 @@ private: } // end of namespace Wintermute -#endif // WINTERMUTE_BRENDERER_SDL_H +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index 1b7146632e..b68fac4e3b 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSURFACESDL_H -#define WINTERMUTE_BSURFACESDL_H +#ifndef WINTERMUTE_BASE_SURFACESDL_H +#define WINTERMUTE_BASE_SURFACESDL_H #include "graphics/surface.h" #include "engines/wintermute/base/gfx/base_surface.h" @@ -96,4 +96,4 @@ private: } // end of namespace Wintermute -#endif // WINTERMUTE_BSURFACESDL_H +#endif diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index fcc463ed06..d65757474a 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUND_H -#define WINTERMUTE_BSOUND_H +#ifndef WINTERMUTE_BASE_SOUND_H +#define WINTERMUTE_BASE_SOUND_H #include "engines/wintermute/base/base.h" #include "engines/wintermute/dctypes.h" // Added by ClassView diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 3ec4d4d28b..29402ee76e 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUNDBUFFER_H -#define WINTERMUTE_BSOUNDBUFFER_H +#ifndef WINTERMUTE_BASE_SOUNDBUFFER_H +#define WINTERMUTE_BASE_SOUNDBUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index a0b9a4bc4b..d0b782b2b7 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BSOUNDMGR_H -#define WINTERMUTE_BSOUNDMGR_H +#ifndef WINTERMUTE_BASE_SOUNDMGR_H +#define WINTERMUTE_BASE_SOUNDMGR_H #include "engines/wintermute/coll_templ.h" #include "engines/wintermute/base/base.h" -- cgit v1.2.3 From 8cf7d765c05bd13fc381e94801b2bbd8c27e1c07 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:38:24 +0200 Subject: WINTERMUTE: General cleanup --- engines/wintermute/base/base.h | 4 +--- engines/wintermute/base/font/base_font.h | 4 ++-- engines/wintermute/base/gfx/base_renderer.h | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index b07065ec0d..f4c1cf0739 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -45,7 +45,7 @@ public: bool _persistable; bool setEditorProp(const Common::String &propName, const Common::String &propValue); Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); - BaseClass(TDynamicConstructor, TDynamicConstructor) {}; + BaseClass(TDynamicConstructor, TDynamicConstructor) {} bool parseEditorProperty(byte *buffer, bool complete = true); virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); BaseClass(); @@ -55,8 +55,6 @@ public: protected: Common::HashMap _editorProps; Common::HashMap::iterator _editorPropsIter; - /* std::map _editorProps; - std::map::iterator _editorPropsIter;*/ }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index 461a724160..acd424ac06 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -43,8 +43,8 @@ public: virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); virtual int getLetterHeight(); - virtual void initLoop() {}; - virtual void afterLoad() {}; + virtual void initLoop() {} + virtual void afterLoad() {} BaseFont(BaseGame *inGame); virtual ~BaseFont(); diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 26d7e6db57..0ff4e6a3be 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -54,7 +54,7 @@ public: int _drawOffsetX; int _drawOffsetY; - virtual void dumpData(const char *filename) {}; + virtual void dumpData(const char *filename) {} /** * Take a screenshot of the current screenstate * -- cgit v1.2.3 From 158a2060868eceff254460a89b67d78dc650bc94 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:42:53 +0200 Subject: WINTERMUTE: Use ++it instead of it++ --- engines/wintermute/base/base_file_manager.cpp | 6 +++--- engines/wintermute/base/base_persistence_manager.cpp | 2 +- engines/wintermute/base/file/base_disk_file.cpp | 4 ++-- engines/wintermute/base/file/base_package.cpp | 2 +- engines/wintermute/base/font/base_font_truetype.cpp | 4 ++-- .../wintermute/base/gfx/osystem/base_render_osystem.cpp | 16 ++++++++-------- engines/wintermute/base/scriptables/script_engine.cpp | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index 01b11352b5..f139d99146 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -165,7 +165,7 @@ bool BaseFileManager::initPaths() { } bool BaseFileManager::registerPackages(const Common::FSList &fslist) { - for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); it++) { + for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); ++it) { debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); if ((*it).getName().contains(".dcp")) { if (registerPackage((*it))) { @@ -183,10 +183,10 @@ bool BaseFileManager::registerPackages() { // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail // and that has to be like that to support the detection-scheme. Common::FSList files; - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); it++) { + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); ++it) { debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); (*it).getChildren(files, Common::FSNode::kListFilesOnly); - for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); fileIt++) { + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { if (!fileIt->getName().hasSuffix(".dcp")) { continue; } diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 1beaeecdd7..94588eff32 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -169,7 +169,7 @@ uint32 BasePersistenceManager::getMaxUsedSlot() { Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); Common::StringArray::iterator it = saves.begin(); int ret = -1; - for (; it != saves.end(); it++) { + for (; it != saves.end(); ++it) { int num = -1; sscanf(it->c_str(), "save%d", &num); ret = MAX(ret, num); diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 44a8049121..8fff78a32a 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -94,7 +94,7 @@ bool diskFileExists(const Common::String &filename) { Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, filename); - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { return true; } @@ -124,7 +124,7 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { Common::ArchiveMemberList files; SearchMan.listMatchingMembers(files, fixedFilename); - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); it++) { + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { if ((*it)->getName() == filename) { file = (*it)->createReadStream(); break; diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index a9fb7f9a68..c5a62299e2 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -228,7 +228,7 @@ PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool } PackageSet::~PackageSet() { - for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); it++) { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); ++it) { delete *it; } _packages.clear(); diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 19c5cef7ee..36703ed44f 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -275,7 +275,7 @@ BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, uint32 useColor = 0xffffffff; Common::Array::iterator it; int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); it++) { + for (it = lines.begin(); it != lines.end(); ++it) { _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); heightOffset += (int)_lineHeight; } @@ -581,7 +581,7 @@ void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight _font->wordWrapText(text, maxWidth, lines); Common::Array::iterator it; textWidth = 0; - for (it = lines.begin(); it != lines.end(); it++) { + for (it = lines.begin(); it != lines.end(); ++it) { textWidth = MAX(textWidth, _font->getStringWidth(*it)); } diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 05520ee7a9..7a862e4441 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -210,7 +210,7 @@ bool BaseRenderOSystem::flip() { delete ticket; } else { (*it)->_wantsDraw = false; - it++; + ++it; } } } @@ -316,7 +316,7 @@ void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::S RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); compare._colorMod = _colorMod; RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { (*it)->_colorMod = _colorMod; if (_disableDirtyRects) { @@ -347,7 +347,7 @@ void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { if ((*it)->_owner == surf) { invalidateTicket(*it); } @@ -375,7 +375,7 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { Common::List::iterator it; renderTicket->_drawNum = _drawNum++; // Increment the following tickets, so they still are in line - for (it = pos; it != _renderQueue.end(); it++) { + for (it = pos; it != _renderQueue.end(); ++it) { (*it)->_drawNum++; (*it)->_wantsDraw = false; } @@ -393,12 +393,12 @@ void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { it = _renderQueue.erase(it); break; } else { - it++; + ++it; } } if (it != _renderQueue.end()) { // Decreement the following tickets. - for (; it != _renderQueue.end(); it++) { + for (; it != _renderQueue.end(); ++it) { (*it)->_drawNum--; } } @@ -431,7 +431,7 @@ void BaseRenderOSystem::drawTickets() { decrement++; } else { (*it)->_drawNum -= decrement; - it++; + ++it; } } if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { @@ -444,7 +444,7 @@ void BaseRenderOSystem::drawTickets() { // Apply the clear-color to the dirty rect. _renderSurface->fillRect(*_dirtyRect, _clearColor); _drawNum = 1; - for (it = _renderQueue.begin(); it != _renderQueue.end(); it++) { + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { RenderTicket *ticket = *it; assert(ticket->_drawNum == _drawNum++); if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index d518be579f..02f6080958 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -591,7 +591,7 @@ void ScEngine::dumpStats() { TimeVector times; ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); it++) { + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); ++it) { times.push_back(std::pair (it->_value, it->_key)); } std::sort(times.begin(), times.end()); @@ -602,7 +602,7 @@ void ScEngine::dumpStats() { _gameRef->LOG(0, "***** Script profiling information: *****"); _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - for (tit = times.rbegin(); tit != times.rend(); tit++) { + for (tit = times.rbegin(); tit != times.rend(); ++tit) { _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); }*/ } -- cgit v1.2.3 From 7027741de777f3d1f5e9e93f5a2dd8ade09b6599 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 19:51:07 +0200 Subject: WINTERMUTE: Fix warnings --- engines/wintermute/base/base_frame.cpp | 8 ++++---- engines/wintermute/base/base_surface_storage.cpp | 4 ++-- engines/wintermute/base/font/base_font_bitmap.cpp | 4 ++-- engines/wintermute/base/font/base_font_truetype.cpp | 4 ++-- engines/wintermute/base/particles/part_emitter.cpp | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index eb66661c62..ed2c7acaca 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -349,7 +349,7 @@ bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float Rect32 subRect; - for (int i = 0; i < _subframes.size(); i++) { + for (uint32 i = 0; i < _subframes.size(); i++) { _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); BasePlatform::unionRect(rect, rect, &subRect); } @@ -469,7 +469,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _subframes.size()) { + if (index < 0 || index >= (int32)_subframes.size()) { script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); stack->pushNULL(); } else { @@ -487,7 +487,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ScValue *val = stack->pop(); if (val->isInt()) { int index = val->getInt(-1); - if (index < 0 || index >= _subframes.size()) { + if (index < 0 || index >= (int32)_subframes.size()) { script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); } } else { @@ -563,7 +563,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac else if (strcmp(name, "GetSubframe") == 0) { stack->correctParams(1); int index = stack->pop()->getInt(-1); - if (index < 0 || index >= _applyEvent.size()) { + if (index < 0 || index >= (int32)_applyEvent.size()) { script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); stack->pushNULL(); } else { diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 0e0976b838..c87da898db 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -176,8 +176,8 @@ bool BaseSurfaceStorage::sortSurfaces() { ////////////////////////////////////////////////////////////////////////// int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - const BaseSurface *s1 = *((BaseSurface **)arg1); - const BaseSurface *s2 = *((BaseSurface **)arg2); + const BaseSurface *s1 = *((const BaseSurface *const *)arg1); + const BaseSurface *s2 = *((const BaseSurface *const *)arg2); // sort by life time if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index a9d71e0fa1..062f4801cf 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -118,10 +118,10 @@ int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TT AnsiString str; if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); str = StringUtil::wideToAnsi(wstr); } else { - str = AnsiString((char *)text); + str = AnsiString((const char *)text); } if (str.empty()) { return 0; diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 36703ed44f..171f33d8ab 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -153,11 +153,11 @@ int BaseFontTT::getTextHeight(byte *text, int width) { ////////////////////////////////////////////////////////////////////////// void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((char *)text, "") == 0) { + if (text == NULL || strcmp((const char *)text, "") == 0) { return; } - WideString textStr = (char *)text; + WideString textStr = (const char *)text; // TODO: Why do we still insist on Widestrings everywhere? /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index f52a1b8c82..7012bef86f 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -373,8 +373,8 @@ bool PartEmitter::sortParticlesByZ() { ////////////////////////////////////////////////////////////////////////// int PartEmitter::compareZ(const void *obj1, const void *obj2) { - const PartParticle *p1 = *(PartParticle **)obj1; - const PartParticle *p2 = *(PartParticle **)obj2; + const PartParticle *p1 = *(const PartParticle *const *)obj1; + const PartParticle *p2 = *(const PartParticle *const *)obj2; if (p1->_posZ < p2->_posZ) { return -1; -- cgit v1.2.3 From fb367d1ac3517897e7e3c1312fb8ed0c688cd137 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 20:14:34 +0200 Subject: WINTERMUTE: Fix a type in the header-guard-fix for base_active_rect.h --- engines/wintermute/base/base_active_rect.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 848b77e56e..651b8530ac 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -27,7 +27,7 @@ */ #ifndef WINTERMUTE_BASE_ACTIVERECT_H -#define WINTERMUTE_BASE_BACTIVERECT_H +#define WINTERMUTE_BASE_ACTIVERECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" -- cgit v1.2.3 From 59b1bbfa158b308d2674ca07efa77dbc7dbefaea Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 20:52:23 +0200 Subject: WINTERMUTE: Even more fixes to header-guards. --- engines/wintermute/base/base_active_rect.h | 4 ++-- engines/wintermute/base/base_dynamic_buffer.h | 4 ++-- engines/wintermute/base/base_file_manager.h | 4 ++-- engines/wintermute/base/base_named_object.h | 4 ++-- engines/wintermute/base/base_persistence_manager.h | 4 ++-- engines/wintermute/base/base_save_thumb_helper.h | 4 ++-- engines/wintermute/base/base_string_table.h | 4 ++-- engines/wintermute/base/base_surface_storage.h | 4 ++-- engines/wintermute/base/base_transition_manager.h | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 651b8530ac..3c2cccfeed 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_ACTIVERECT_H -#define WINTERMUTE_BASE_ACTIVERECT_H +#ifndef WINTERMUTE_BASE_ACTIVE_RECT_H +#define WINTERMUTE_BASE_ACTIVE_RECT_H #include "engines/wintermute/math/rect32.h" #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index 23aebfdf9f..df35ad817d 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_DYNBUFFER_H -#define WINTERMUTE_BASE_DYNBUFFER_H +#ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H +#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 3716dd0581..1b93f7dee4 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_FILEMANAGER_H -#define WINTERMUTE_BASE_FILEMANAGER_H +#ifndef WINTERMUTE_BASE_FILE_MANAGER_H +#define WINTERMUTE_BASE_FILE_MANAGER_H #include "common/archive.h" #include "common/str.h" diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index ca71471521..9818708605 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_NAMEDOBJECT_H -#define WINTERMUTE_BASE_NAMEDOBJECT_H +#ifndef WINTERMUTE_BASE_NAMED_OBJECT_H +#define WINTERMUTE_BASE_NAMED_OBJECT_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index 4de1f84c64..fb5a73d0d3 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_PERSISTMGR_H -#define WINTERMUTE_BASE_PERSISTMGR_H +#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H +#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H #include "engines/wintermute/dctypes.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index 7c06384aa1..0af3103f71 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -25,8 +25,8 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_SAVETHUMBHELPER_H -#define WINTERMUTE_BASE_SAVETHUMBHELPER_H +#ifndef WINTERMUTE_BASE_SAVE_THUMB_HELPER_H +#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H #include "engines/wintermute/base/base.h" diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index 46295426fd..09d8aecce4 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_STRINGTABLE_H -#define WINTERMUTE_BASE_STRINGTABLE_H +#ifndef WINTERMUTE_BASE_STRING_TABLE_H +#define WINTERMUTE_BASE_STRING_TABLE_H #include "common/hashmap.h" diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 741177ae76..28c36bebca 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_SURFACESTORAGE_H -#define WINTERMUTE_BASE_SURFACESTORAGE_H +#ifndef WINTERMUTE_BASE_SURFACE_STORAGE_H +#define WINTERMUTE_BASE_SURFACE_STORAGE_H #include "engines/wintermute/base/base.h" #include "common/array.h" diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index daf2299c2f..1a989fbcfd 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -26,8 +26,8 @@ * Copyright (c) 2011 Jan Nedoma */ -#ifndef WINTERMUTE_BASE_TRANSITIONMGR_H -#define WINTERMUTE_BASE_TRANSITIONMGR_H +#ifndef WINTERMUTE_BASE_TRANSITION_MANAGER_H +#define WINTERMUTE_BASE_TRANSITION_MANAGER_H #include "engines/wintermute/base/base.h" -- cgit v1.2.3 From e067520bb904615ed75217808ba27235eb244336 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 21:01:53 +0200 Subject: WINTERMUTE: Use tabs in enums --- engines/wintermute/base/base_file_manager.h | 4 +- engines/wintermute/base/scriptables/dcscript.h | 152 ++++++++++++------------- 2 files changed, 78 insertions(+), 78 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 1b93f7dee4..3fb4434e9c 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -52,8 +52,8 @@ public: static BaseFileManager *getEngineInstance(); private: typedef enum { - PATH_PACKAGE, - PATH_SINGLE + PATH_PACKAGE, + PATH_SINGLE } TPathType; bool reloadPaths(); bool initPaths(); diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index db63ad2b87..6810fdf665 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -36,104 +36,104 @@ namespace Wintermute { // value types typedef enum { - VAL_NULL, - VAL_STRING, - VAL_INT, - VAL_BOOL, - VAL_FLOAT, - VAL_OBJECT, - VAL_NATIVE, - VAL_VARIABLE_REF + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF } TValType; // script states typedef enum { - SCRIPT_RUNNING, - SCRIPT_WAITING, - SCRIPT_SLEEPING, - SCRIPT_FINISHED, - SCRIPT_PERSISTENT, - SCRIPT_ERROR, - SCRIPT_PAUSED, - SCRIPT_WAITING_SCRIPT, - SCRIPT_THREAD_FINISHED + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED } TScriptState; // opcodes typedef enum { - II_DEF_VAR = 0, - II_DEF_GLOB_VAR, - II_RET, - II_RET_EVENT, - II_CALL, - II_CALL_BY_EXP, - II_EXTERNAL_CALL, - II_SCOPE, - II_CORRECT_STACK, - II_CREATE_OBJECT, - II_POP_EMPTY, - II_PUSH_VAR, - II_PUSH_VAR_REF, - II_POP_VAR, - II_PUSH_VAR_THIS, // push current this on stack - II_PUSH_INT, - II_PUSH_BOOL, - II_PUSH_FLOAT, - II_PUSH_STRING, - II_PUSH_NULL, - II_PUSH_THIS_FROM_STACK, - II_PUSH_THIS, - II_POP_THIS, - II_PUSH_BY_EXP, - II_POP_BY_EXP, - II_JMP, - II_JMP_FALSE, - II_ADD, - II_SUB, - II_MUL, - II_DIV, - II_MODULO, - II_NOT, - II_AND, - II_OR, - II_CMP_EQ, - II_CMP_NE, - II_CMP_L, - II_CMP_G, - II_CMP_LE, - II_CMP_GE, - II_CMP_STRICT_EQ, - II_CMP_STRICT_NE, - II_DBG_LINE, - II_POP_REG1, - II_PUSH_REG1, - II_DEF_CONST_VAR + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR } TInstruction; // external data types typedef enum { - TYPE_VOID = 0, - TYPE_BOOL, - TYPE_LONG, - TYPE_BYTE, - TYPE_STRING, - TYPE_FLOAT, - TYPE_DOUBLE, - TYPE_MEMBUFFER + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER } TExternalType; // call types typedef enum { - CALL_STDCALL = 0, - CALL_CDECL, - CALL_THISCALL + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL } TCallType; // element types typedef enum { - ELEMENT_STRING = 0 + ELEMENT_STRING = 0 } TElementType; } // end of namespace Wintermute -- cgit v1.2.3 From 7b17d8060d5600fe736d0b3af4e24da4e1776ddb Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 1 Sep 2012 14:04:23 +0200 Subject: WINTERMUTE: Fix various comments. --- engines/wintermute/base/base_keyboard_state.cpp | 3 - engines/wintermute/base/base_parser.cpp | 2 +- engines/wintermute/base/font/base_font.cpp | 67 ---------------------- engines/wintermute/base/gfx/base_renderer.cpp | 1 + .../base/gfx/osystem/base_surface_osystem.cpp | 4 +- 5 files changed, 4 insertions(+), 73 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 70d92784a5..63c0a873ce 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -92,9 +92,6 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * vKey = val->getInt(); } - warning("BKeyboardState doesnt yet have state-support %d", vKey); //TODO; -// Uint8 *state = SDL_GetKeyboardState(NULL); -// SDL_Scancode scanCode = SDL_GetScancodeFromKey(VKeyToKeyCode(vKey)); bool isDown = _keyStates[vKeyToKeyCode(vKey)]; stack->pushBool(isDown); diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index bbbb5d69ba..007f93e443 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -79,7 +79,7 @@ int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, ch } // find the token. - // for now just use brute force. Improve later. + // TODO: for now just use brute force. Improve later. while (tokens->id != 0) { if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { // here we could be matching PART of a string diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index 8fb2b2b44a..cb70c4add8 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -67,73 +67,6 @@ int BaseFont::getTextWidth(byte *text, int maxLength) { return 0; } -/* -////////////////////////////////////////////////////////////////////// -bool BaseFont::loadFile(const char * Filename) -{ - BYTE* Buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (Buffer==NULL){ - _gameRef->LOG(0, "BaseFont::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - _filename = new char [strlen(filename)+1]; - strcpy(_filename, filename); - - if (DID_FAIL(ret = loadBuffer(Buffer))) _gameRef->LOG(0, "Error parsing FONT file '%s'", filename); - - delete[] Buffer; - - return ret; -} - - -TOKEN_DEF_START - TOKEN_DEF (FONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseFont::loadBuffer(byte * Buffer) -{ - TOKEN_TABLE_START(commands) - TOKEN_TABLE (FONT) - TOKEN_TABLE_END - - char* params; - int cmd; - BaseParser parser; - - if (parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)!=TOKEN_FONT){ - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - Buffer = (byte *)params; - - while ((cmd = parser.GetCommand ((char**)&Buffer, commands, (char**)¶ms)) > 0) - { - switch (cmd) - { - case TOKEN_IMAGE: - surface_file = (char*)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custo_trans = true; - break; - } - - - } - if (cmd == PARSERR_TOKENNOTFOUND){ - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} -*/ ////////////////////////////////////////////////////////////////////////// int BaseFont::getLetterHeight() { diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 9e271fc32d..202c864683 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -296,6 +296,7 @@ bool BaseRenderer::setViewport(Rect32 *rect) { ////////////////////////////////////////////////////////////////////////// bool BaseRenderer::clipCursor() { + // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) /* if (!_windowed) { Rect32 rc; diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index ea88f19065..7724a93481 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -176,7 +176,7 @@ bool BaseSurfaceOSystem::finishLoad() { void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); return; - + // TODO: Reimplement this delete[] _alphaMask; _alphaMask = NULL; if (!surface) { @@ -190,7 +190,7 @@ void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { hasColorKey = true; SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); } else hasColorKey = false; - */ //TODO + */ _alphaMask = new byte[surface->w * surface->h]; bool hasTransparency = false; -- cgit v1.2.3 From 00ad58c29b7ead1f9d18b99d374b3e8e1e62f3d3 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Sep 2012 20:10:30 +0300 Subject: WINTERMUTE: Fix a warning with MSVC --- engines/wintermute/base/scriptables/script.cpp | 4 ++-- engines/wintermute/base/scriptables/script.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index beef4ee9d2..269ea1ea03 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -38,7 +38,7 @@ namespace Wintermute { IMPLEMENT_PERSISTENT(ScScript, false) ////////////////////////////////////////////////////////////////////////// -ScScript::ScScript(BaseGame *inGame, ScEngine *Engine) : BaseClass(inGame) { +ScScript::ScScript(BaseGame *inGame, ScEngine *engine) : BaseClass(inGame) { _buffer = NULL; _bufferSize = _iP = 0; _scriptStream = NULL; @@ -48,7 +48,7 @@ ScScript::ScScript(BaseGame *inGame, ScEngine *Engine) : BaseClass(inGame) { _symbols = NULL; _numSymbols = 0; - _engine = Engine; + _engine = engine; _globals = NULL; diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 132f1ce6c5..4daeacd026 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -138,7 +138,7 @@ private: byte *_buffer; public: Common::SeekableReadStream *_scriptStream; - ScScript(BaseGame *inGame, ScEngine *Engine); + ScScript(BaseGame *inGame, ScEngine *engine); virtual ~ScScript(); char *_filename; bool _thread; -- cgit v1.2.3 From 4cfd906cec08fec8c27f33c1a54651271a4fb104 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Tue, 4 Sep 2012 20:27:19 +0300 Subject: WINTERMUTE: Fix compilation when vorbis isn't available --- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index e2d9c8c13f..24414e33a7 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -104,7 +104,9 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel Common::String strFilename(filename); strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { +#ifdef USE_VORBIS _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); +#endif } else if (strFilename.hasSuffix(".wav")) { int waveSize, waveRate; byte waveFlags; -- cgit v1.2.3 From 9989a4f3daba891326810d7ae620cd75d97521f1 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:41:58 +0200 Subject: WINTERMUTE: Remove extra semicolon. --- engines/wintermute/base/base_keyboard_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index 63c0a873ce..c8dc02c49a 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -277,7 +277,7 @@ enum VKeyCodes { VK_UP = 38, VK_RIGHT = 39, VK_DOWN = 40 -}; +} ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { -- cgit v1.2.3 From e8f2742cc789b54d22ed5d47e45938474ea608e9 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:43:15 +0200 Subject: WINTERMUTE: Replace VKeyCodes constant names. This is a purely cosmetical change, which should help compilation on systems, which use VK_* for internal constants. This should help compilation for WinCE. --- engines/wintermute/base/base_keyboard_state.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index c8dc02c49a..c8a6ccd391 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -272,30 +272,30 @@ uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { } enum VKeyCodes { - VK_SPACE = 32, - VK_LEFT = 37, - VK_UP = 38, - VK_RIGHT = 39, - VK_DOWN = 40 + kVkSpace = 32, + kVkLeft = 37, + kVkUp = 38, + kVkRight = 39, + kVkDown = 40 } ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { // todo switch (vkey) { - case VK_SPACE: + case kVkSpace: return Common::KEYCODE_SPACE; break; - case VK_LEFT: + case kVkLeft: return Common::KEYCODE_LEFT; break; - case VK_RIGHT: + case kVkRight: return Common::KEYCODE_RIGHT; break; - case VK_UP: + case kVkUp: return Common::KEYCODE_UP; break; - case VK_DOWN: + case kVkDown: return Common::KEYCODE_DOWN; break; default: -- cgit v1.2.3 From a8518eebe6632d7632ee204799bd8ff76eb01384 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 19:51:33 +0200 Subject: Revert "WINTERMUTE: Remove extra semicolon." This reverts commit 9989a4f3daba891326810d7ae620cd75d97521f1. Note: Don't blind fix warnings of broken builds. Conflicts: engines/wintermute/base/base_keyboard_state.cpp --- engines/wintermute/base/base_keyboard_state.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index c8a6ccd391..d5c2027a0d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -277,7 +277,7 @@ enum VKeyCodes { kVkUp = 38, kVkRight = 39, kVkDown = 40 -} +}; ////////////////////////////////////////////////////////////////////////// Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { -- cgit v1.2.3 From df80820184c90a87511f0cabdca4addb9fa13a66 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Tue, 4 Sep 2012 20:29:14 +0200 Subject: Revert "WINTERMUTE: Fix compilation when vorbis isn't available" This reverts commit 4cfd906cec08fec8c27f33c1a54651271a4fb104. We now have vorbis as a hard requirement for Wintermute. Also somaen said this commit causes issues, so we agreed on reverting this hack. --- engines/wintermute/base/sound/base_sound_buffer.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 24414e33a7..e2d9c8c13f 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -104,9 +104,7 @@ bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceRel Common::String strFilename(filename); strFilename.toLowercase(); if (strFilename.hasSuffix(".ogg")) { -#ifdef USE_VORBIS _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); -#endif } else if (strFilename.hasSuffix(".wav")) { int waveSize, waveRate; byte waveFlags; -- cgit v1.2.3 From b4090ead4d4334e08725323ff72fd355c93b63d5 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Tue, 4 Sep 2012 22:17:23 +0200 Subject: WINTERMUTE: Convert CRLF to LF --- engines/wintermute/base/base.cpp | 370 +- engines/wintermute/base/base.h | 124 +- engines/wintermute/base/base_active_rect.cpp | 220 +- engines/wintermute/base/base_active_rect.h | 120 +- engines/wintermute/base/base_dynamic_buffer.cpp | 408 +- engines/wintermute/base/base_dynamic_buffer.h | 132 +- engines/wintermute/base/base_fader.cpp | 388 +- engines/wintermute/base/base_fader.h | 126 +- engines/wintermute/base/base_file_manager.cpp | 680 +- engines/wintermute/base/base_file_manager.h | 152 +- engines/wintermute/base/base_frame.cpp | 1520 ++-- engines/wintermute/base/base_frame.h | 146 +- engines/wintermute/base/base_game.cpp | 8966 ++++++++++---------- engines/wintermute/base/base_game.h | 724 +- engines/wintermute/base/base_keyboard_state.cpp | 618 +- engines/wintermute/base/base_keyboard_state.h | 150 +- engines/wintermute/base/base_named_object.cpp | 142 +- engines/wintermute/base/base_named_object.h | 102 +- engines/wintermute/base/base_object.cpp | 2492 +++--- engines/wintermute/base/base_object.h | 294 +- engines/wintermute/base/base_parser.cpp | 934 +- engines/wintermute/base/base_parser.h | 176 +- .../wintermute/base/base_persistence_manager.cpp | 1656 ++-- engines/wintermute/base/base_persistence_manager.h | 236 +- engines/wintermute/base/base_point.cpp | 126 +- engines/wintermute/base/base_point.h | 100 +- engines/wintermute/base/base_quick_msg.cpp | 114 +- engines/wintermute/base/base_quick_msg.h | 96 +- engines/wintermute/base/base_region.cpp | 1070 +-- engines/wintermute/base/base_region.h | 138 +- engines/wintermute/base/base_save_thumb_helper.cpp | 160 +- engines/wintermute/base/base_save_thumb_helper.h | 102 +- engines/wintermute/base/base_script_holder.cpp | 1004 +-- engines/wintermute/base/base_script_holder.h | 152 +- engines/wintermute/base/base_scriptable.cpp | 382 +- engines/wintermute/base/base_scriptable.h | 166 +- engines/wintermute/base/base_sprite.cpp | 1628 ++-- engines/wintermute/base/base_sprite.h | 180 +- engines/wintermute/base/base_string_table.cpp | 510 +- engines/wintermute/base/base_string_table.h | 110 +- engines/wintermute/base/base_sub_frame.cpp | 1310 +-- engines/wintermute/base/base_sub_frame.h | 184 +- engines/wintermute/base/base_surface_storage.cpp | 414 +- engines/wintermute/base/base_surface_storage.h | 114 +- .../wintermute/base/base_transition_manager.cpp | 272 +- engines/wintermute/base/base_transition_manager.h | 108 +- engines/wintermute/base/base_viewport.cpp | 196 +- engines/wintermute/base/base_viewport.h | 110 +- engines/wintermute/base/file/base_disk_file.cpp | 392 +- engines/wintermute/base/file/base_disk_file.h | 82 +- engines/wintermute/base/file/base_file.cpp | 136 +- engines/wintermute/base/file/base_file.h | 134 +- engines/wintermute/base/file/base_file_entry.cpp | 146 +- engines/wintermute/base/file/base_file_entry.h | 120 +- engines/wintermute/base/file/base_package.cpp | 552 +- engines/wintermute/base/file/base_package.h | 180 +- engines/wintermute/base/file/base_resources.cpp | 5660 ++++++------ engines/wintermute/base/file/base_resources.h | 90 +- .../wintermute/base/file/base_save_thumb_file.cpp | 308 +- .../wintermute/base/file/base_save_thumb_file.h | 104 +- engines/wintermute/base/file/dcpackage.h | 160 +- engines/wintermute/base/font/base_font.cpp | 280 +- engines/wintermute/base/font/base_font.h | 122 +- engines/wintermute/base/font/base_font_bitmap.cpp | 1178 +-- engines/wintermute/base/font/base_font_bitmap.h | 142 +- engines/wintermute/base/font/base_font_storage.cpp | 284 +- engines/wintermute/base/font/base_font_storage.h | 110 +- .../wintermute/base/font/base_font_truetype.cpp | 1210 +-- engines/wintermute/base/font/base_font_truetype.h | 304 +- engines/wintermute/base/gfx/base_image.cpp | 462 +- engines/wintermute/base/gfx/base_image.h | 144 +- engines/wintermute/base/gfx/base_renderer.cpp | 762 +- engines/wintermute/base/gfx/base_renderer.h | 442 +- engines/wintermute/base/gfx/base_surface.cpp | 298 +- engines/wintermute/base/gfx/base_surface.h | 198 +- .../base/gfx/osystem/base_render_osystem.cpp | 1208 +-- .../base/gfx/osystem/base_render_osystem.h | 262 +- .../base/gfx/osystem/base_surface_osystem.cpp | 858 +- .../base/gfx/osystem/base_surface_osystem.h | 198 +- engines/wintermute/base/particles/part_emitter.cpp | 2512 +++--- engines/wintermute/base/particles/part_emitter.h | 280 +- engines/wintermute/base/particles/part_force.cpp | 130 +- engines/wintermute/base/particles/part_force.h | 114 +- .../wintermute/base/particles/part_particle.cpp | 538 +- engines/wintermute/base/particles/part_particle.h | 180 +- engines/wintermute/base/scriptables/dcscript.h | 282 +- engines/wintermute/base/scriptables/script.cpp | 2934 +++---- engines/wintermute/base/scriptables/script.h | 348 +- .../wintermute/base/scriptables/script_engine.cpp | 1220 +-- .../wintermute/base/scriptables/script_engine.h | 270 +- .../base/scriptables/script_ext_array.cpp | 504 +- .../wintermute/base/scriptables/script_ext_array.h | 112 +- .../base/scriptables/script_ext_date.cpp | 586 +- .../wintermute/base/scriptables/script_ext_date.h | 108 +- .../base/scriptables/script_ext_file.cpp | 1658 ++-- .../wintermute/base/scriptables/script_ext_file.h | 132 +- .../base/scriptables/script_ext_math.cpp | 590 +- .../wintermute/base/scriptables/script_ext_math.h | 106 +- .../base/scriptables/script_ext_mem_buffer.cpp | 1058 +-- .../base/scriptables/script_ext_mem_buffer.h | 120 +- .../base/scriptables/script_ext_object.cpp | 134 +- .../base/scriptables/script_ext_object.h | 92 +- .../base/scriptables/script_ext_string.cpp | 872 +- .../base/scriptables/script_ext_string.h | 116 +- .../wintermute/base/scriptables/script_stack.cpp | 464 +- engines/wintermute/base/scriptables/script_stack.h | 132 +- .../wintermute/base/scriptables/script_value.cpp | 1990 ++--- engines/wintermute/base/scriptables/script_value.h | 226 +- engines/wintermute/base/sound/base_sound.cpp | 584 +- engines/wintermute/base/sound/base_sound.h | 174 +- .../wintermute/base/sound/base_sound_buffer.cpp | 594 +- engines/wintermute/base/sound/base_sound_buffer.h | 200 +- .../wintermute/base/sound/base_sound_manager.cpp | 564 +- engines/wintermute/base/sound/base_sound_manager.h | 136 +- 114 files changed, 33104 insertions(+), 33104 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base.cpp b/engines/wintermute/base/base.cpp index 11f308a522..e351792e61 100644 --- a/engines/wintermute/base/base.cpp +++ b/engines/wintermute/base/base.cpp @@ -1,185 +1,185 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseClass::BaseClass(BaseGame *gameOwner) { - _gameRef = gameOwner; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////////// -BaseClass::BaseClass() { - _gameRef = NULL; - _persistable = true; -} - - -////////////////////////////////////////////////////////////////////// -BaseClass::~BaseClass() { - _editorProps.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -Common::String BaseClass::getEditorProp(const Common::String &propName, const Common::String &initVal) { - _editorPropsIter = _editorProps.find(propName); - if (_editorPropsIter != _editorProps.end()) { - return _editorPropsIter->_value.c_str(); - } else { - return initVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { - if (propName.size() == 0) { - return STATUS_FAILED; - } - - if (propValue.size() == 0) { - _editorProps.erase(propName); - } else { - _editorProps[propName] = propValue; - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - - if (!_gameRef->_editorMode) { - return STATUS_OK; - } - - - byte *params; - int cmd; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { - _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) { - strcpy(propName, (char *)params); - } else { - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) { - strcpy(propValue, (char *)params); - } else { - cmd = PARSERR_GENERIC; - } - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); - return STATUS_FAILED; - } - - - setEditorProp(propName, propValue); - - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { - _editorPropsIter = _editorProps.begin(); - while (_editorPropsIter != _editorProps.end()) { - buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); - buffer->putTextIndent(indent, "{\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); - buffer->putTextIndent(indent, "}\n\n"); - - _editorPropsIter++; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseClass::BaseClass(BaseGame *gameOwner) { + _gameRef = gameOwner; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////////// +BaseClass::BaseClass() { + _gameRef = NULL; + _persistable = true; +} + + +////////////////////////////////////////////////////////////////////// +BaseClass::~BaseClass() { + _editorProps.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +Common::String BaseClass::getEditorProp(const Common::String &propName, const Common::String &initVal) { + _editorPropsIter = _editorProps.find(propName); + if (_editorPropsIter != _editorProps.end()) { + return _editorPropsIter->_value.c_str(); + } else { + return initVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseClass::setEditorProp(const Common::String &propName, const Common::String &propValue) { + if (propName.size() == 0) { + return STATUS_FAILED; + } + + if (propValue.size() == 0) { + _editorProps.erase(propName); + } else { + _editorProps[propName] = propValue; + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool BaseClass::parseEditorProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + + if (!_gameRef->_editorMode) { + return STATUS_OK; + } + + + byte *params; + int cmd; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_EDITOR_PROPERTY) { + _gameRef->LOG(0, "'EDITOR_PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading EDITOR_PROPERTY definition"); + return STATUS_FAILED; + } + + + setEditorProp(propName, propValue); + + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseClass::saveAsText(BaseDynamicBuffer *buffer, int indent) { + _editorPropsIter = _editorProps.begin(); + while (_editorPropsIter != _editorProps.end()) { + buffer->putTextIndent(indent, "EDITOR_PROPERTY\n"); + buffer->putTextIndent(indent, "{\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _editorPropsIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _editorPropsIter->_value.c_str()); + buffer->putTextIndent(indent, "}\n\n"); + + _editorPropsIter++; + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base.h b/engines/wintermute/base/base.h index f4c1cf0739..24820c748a 100644 --- a/engines/wintermute/base/base.h +++ b/engines/wintermute/base/base.h @@ -1,62 +1,62 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_BASE_H -#define WINTERMUTE_BASE_BASE_H - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/dctypes.h" -#include "common/str.h" -#include "common/hashmap.h" -#include "common/hash-str.h" - -namespace Wintermute { - -class BaseGame; -class BaseDynamicBuffer; - -class BaseClass { -public: - bool _persistable; - bool setEditorProp(const Common::String &propName, const Common::String &propValue); - Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); - BaseClass(TDynamicConstructor, TDynamicConstructor) {} - bool parseEditorProperty(byte *buffer, bool complete = true); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); - BaseClass(); - BaseClass(BaseGame *GameOwner); - virtual ~BaseClass(); - BaseGame *_gameRef; -protected: - Common::HashMap _editorProps; - Common::HashMap::iterator _editorPropsIter; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_BASE_H +#define WINTERMUTE_BASE_BASE_H + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/dctypes.h" +#include "common/str.h" +#include "common/hashmap.h" +#include "common/hash-str.h" + +namespace Wintermute { + +class BaseGame; +class BaseDynamicBuffer; + +class BaseClass { +public: + bool _persistable; + bool setEditorProp(const Common::String &propName, const Common::String &propValue); + Common::String getEditorProp(const Common::String &propName, const Common::String &initVal = NULL); + BaseClass(TDynamicConstructor, TDynamicConstructor) {} + bool parseEditorProperty(byte *buffer, bool complete = true); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent = 0); + BaseClass(); + BaseClass(BaseGame *GameOwner); + virtual ~BaseClass(); + BaseGame *_gameRef; +protected: + Common::HashMap _editorProps; + Common::HashMap::iterator _editorPropsIter; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index 46870a0d29..d754cf0114 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -1,110 +1,110 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_active_rect.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_region.h" -#include "engines/wintermute/platform_osystem.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); - _owner = NULL; - _frame = NULL; - _region = NULL; - _zoomX = 100; - _zoomY = 100; - _offsetX = _offsetY = 0; - clipRect(); -} - - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise) : BaseClass(inGame) { - _owner = owner; - _frame = frame; - BasePlatform::setRect(&_rect, x, y, x + width, y + height); - _zoomX = zoomX; - _zoomY = zoomY; - _precise = precise; - _region = NULL; - _offsetX = _offsetY = 0; - clipRect(); -} - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { - _owner = owner; - _region = region; - BasePlatform::copyRect(&_rect, ®ion->_rect); - _rect.offsetRect(-offsetX, -offsetY); - _zoomX = 100; - _zoomY = 100; - _precise = true; - _frame = NULL; - clipRect(); - _offsetX = offsetX; - _offsetY = offsetY; -} - - -////////////////////////////////////////////////////////////////////// -BaseActiveRect::~BaseActiveRect() { - _owner = NULL; - _frame = NULL; - _region = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseActiveRect::clipRect() { - Rect32 rc; - bool customViewport; - _gameRef->getCurrentViewportRect(&rc, &customViewport); - BaseRenderer *Rend = _gameRef->_renderer; - - if (!customViewport) { - rc.left -= Rend->_drawOffsetX; - rc.right -= Rend->_drawOffsetX; - rc.top -= Rend->_drawOffsetY; - rc.bottom -= Rend->_drawOffsetY; - } - - if (rc.left > _rect.left) { - _offsetX = rc.left - _rect.left; - } - if (rc.top > _rect.top) { - _offsetY = rc.top - _rect.top; - } - - BasePlatform::intersectRect(&_rect, &_rect, &rc); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/platform_osystem.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::BaseActiveRect(BaseGame *inGame) : BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); + _owner = NULL; + _frame = NULL; + _region = NULL; + _zoomX = 100; + _zoomY = 100; + _offsetX = _offsetY = 0; + clipRect(); +} + + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX, float zoomY, bool precise) : BaseClass(inGame) { + _owner = owner; + _frame = frame; + BasePlatform::setRect(&_rect, x, y, x + width, y + height); + _zoomX = zoomX; + _zoomY = zoomY; + _precise = precise; + _region = NULL; + _offsetX = _offsetY = 0; + clipRect(); +} + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY) : BaseClass(inGame) { + _owner = owner; + _region = region; + BasePlatform::copyRect(&_rect, ®ion->_rect); + _rect.offsetRect(-offsetX, -offsetY); + _zoomX = 100; + _zoomY = 100; + _precise = true; + _frame = NULL; + clipRect(); + _offsetX = offsetX; + _offsetY = offsetY; +} + + +////////////////////////////////////////////////////////////////////// +BaseActiveRect::~BaseActiveRect() { + _owner = NULL; + _frame = NULL; + _region = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseActiveRect::clipRect() { + Rect32 rc; + bool customViewport; + _gameRef->getCurrentViewportRect(&rc, &customViewport); + BaseRenderer *Rend = _gameRef->_renderer; + + if (!customViewport) { + rc.left -= Rend->_drawOffsetX; + rc.right -= Rend->_drawOffsetX; + rc.top -= Rend->_drawOffsetY; + rc.bottom -= Rend->_drawOffsetY; + } + + if (rc.left > _rect.left) { + _offsetX = rc.left - _rect.left; + } + if (rc.top > _rect.top) { + _offsetY = rc.top - _rect.top; + } + + BasePlatform::intersectRect(&_rect, &_rect, &rc); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_active_rect.h b/engines/wintermute/base/base_active_rect.h index 3c2cccfeed..fcd2619b03 100644 --- a/engines/wintermute/base/base_active_rect.h +++ b/engines/wintermute/base/base_active_rect.h @@ -1,60 +1,60 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_ACTIVE_RECT_H -#define WINTERMUTE_BASE_ACTIVE_RECT_H - -#include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { -class BaseRegion; -class BaseSubFrame; -class BaseObject; -class BaseActiveRect: BaseClass { -public: - void clipRect(); - bool _precise; - float _zoomX; - float _zoomY; - BaseSubFrame *_frame; - BaseObject *_owner; - BaseRegion *_region; - int _offsetX; - int _offsetY; - Rect32 _rect; - BaseActiveRect(BaseGame *inGameOwner = NULL); - BaseActiveRect(BaseGame *inGameOwner, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); - BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY); - virtual ~BaseActiveRect(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_ACTIVE_RECT_H +#define WINTERMUTE_BASE_ACTIVE_RECT_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { +class BaseRegion; +class BaseSubFrame; +class BaseObject; +class BaseActiveRect: BaseClass { +public: + void clipRect(); + bool _precise; + float _zoomX; + float _zoomY; + BaseSubFrame *_frame; + BaseObject *_owner; + BaseRegion *_region; + int _offsetX; + int _offsetY; + Rect32 _rect; + BaseActiveRect(BaseGame *inGameOwner = NULL); + BaseActiveRect(BaseGame *inGameOwner, BaseObject *owner, BaseSubFrame *frame, int x, int y, int width, int height, float zoomX = 100, float zoomY = 100, bool precise = true); + BaseActiveRect(BaseGame *inGame, BaseObject *owner, BaseRegion *region, int offsetX, int offsetY); + virtual ~BaseActiveRect(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_dynamic_buffer.cpp b/engines/wintermute/base/base_dynamic_buffer.cpp index b49d4ce150..fc48e93c2b 100644 --- a/engines/wintermute/base/base_dynamic_buffer.cpp +++ b/engines/wintermute/base/base_dynamic_buffer.cpp @@ -1,204 +1,204 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { - _buffer = NULL; - _size = 0; - _realSize = 0; - - _offset = 0; - _initSize = initSize; - _growBy = growBy; - - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseDynamicBuffer::~BaseDynamicBuffer() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::cleanup() { - if (_buffer) { - free(_buffer); - } - _buffer = NULL; - _size = 0; - _realSize = 0; - _offset = 0; - _initialized = false; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseDynamicBuffer::getSize() { - return _size; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::init(uint32 initSize) { - cleanup(); - - if (initSize == 0) { - initSize = _initSize; - } - - _buffer = (byte *)malloc(initSize); - if (!_buffer) { - BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); - return STATUS_FAILED; - } - - _realSize = initSize; - _initialized = true; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { - if (!_initialized) { - init(); - } - - while (_offset + size > _realSize) { - _realSize += _growBy; - _buffer = (byte *)realloc(_buffer, _realSize); - if (!_buffer) { - BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); - return STATUS_FAILED; - } - } - - memcpy(_buffer + _offset, buffer, size); - _offset += size; - _size += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { - if (!_initialized) { - init(); - } - - if (_offset + size > _size) { - BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); - return STATUS_FAILED; - } - - memcpy(buffer, _buffer + _offset, size); - _offset += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putDWORD(uint32 val) { - putBytes((byte *)&val, sizeof(uint32)); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseDynamicBuffer::getDWORD() { - uint32 ret; - getBytes((byte *)&ret, sizeof(uint32)); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putString(const char *val) { - if (!val) { - putString("(null)"); - } else { - putDWORD(strlen(val) + 1); - putBytes((const byte *)val, strlen(val) + 1); - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseDynamicBuffer::getString() { - uint32 len = getDWORD(); - char *ret = (char *)(_buffer + _offset); - _offset += len; - - if (!strcmp(ret, "(null)")) { - return NULL; - } else { - return ret; - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putText(const char *fmt, ...) { - va_list va; - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); - -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { - va_list va; - - putText("%*s", indent, ""); - - va_start(va, fmt); - putTextForm(fmt, va); - va_end(va); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { - char buff[32768]; - vsprintf(buff, format, argptr); - putBytes((byte *)buff, strlen(buff)); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseDynamicBuffer::BaseDynamicBuffer(BaseGame *inGame, uint32 initSize, uint32 growBy) { + _buffer = NULL; + _size = 0; + _realSize = 0; + + _offset = 0; + _initSize = initSize; + _growBy = growBy; + + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseDynamicBuffer::~BaseDynamicBuffer() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::cleanup() { + if (_buffer) { + free(_buffer); + } + _buffer = NULL; + _size = 0; + _realSize = 0; + _offset = 0; + _initialized = false; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseDynamicBuffer::getSize() { + return _size; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::init(uint32 initSize) { + cleanup(); + + if (initSize == 0) { + initSize = _initSize; + } + + _buffer = (byte *)malloc(initSize); + if (!_buffer) { + BaseEngine::LOG(0, "BaseDynamicBuffer::Init - Error allocating %d bytes", initSize); + return STATUS_FAILED; + } + + _realSize = initSize; + _initialized = true; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::putBytes(const byte *buffer, uint32 size) { + if (!_initialized) { + init(); + } + + while (_offset + size > _realSize) { + _realSize += _growBy; + _buffer = (byte *)realloc(_buffer, _realSize); + if (!_buffer) { + BaseEngine::LOG(0, "BaseDynamicBuffer::PutBytes - Error reallocating buffer to %d bytes", _realSize); + return STATUS_FAILED; + } + } + + memcpy(_buffer + _offset, buffer, size); + _offset += size; + _size += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseDynamicBuffer::getBytes(byte *buffer, uint32 size) { + if (!_initialized) { + init(); + } + + if (_offset + size > _size) { + BaseEngine::LOG(0, "BaseDynamicBuffer::GetBytes - Buffer underflow"); + return STATUS_FAILED; + } + + memcpy(buffer, _buffer + _offset, size); + _offset += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putDWORD(uint32 val) { + putBytes((byte *)&val, sizeof(uint32)); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseDynamicBuffer::getDWORD() { + uint32 ret; + getBytes((byte *)&ret, sizeof(uint32)); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putString(const char *val) { + if (!val) { + putString("(null)"); + } else { + putDWORD(strlen(val) + 1); + putBytes((const byte *)val, strlen(val) + 1); + } +} + + +////////////////////////////////////////////////////////////////////////// +char *BaseDynamicBuffer::getString() { + uint32 len = getDWORD(); + char *ret = (char *)(_buffer + _offset); + _offset += len; + + if (!strcmp(ret, "(null)")) { + return NULL; + } else { + return ret; + } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putText(const char *fmt, ...) { + va_list va; + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); + +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putTextIndent(int indent, const char *fmt, ...) { + va_list va; + + putText("%*s", indent, ""); + + va_start(va, fmt); + putTextForm(fmt, va); + va_end(va); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseDynamicBuffer::putTextForm(const char *format, va_list argptr) { + char buff[32768]; + vsprintf(buff, format, argptr); + putBytes((byte *)buff, strlen(buff)); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index df35ad817d..b6f3e12b9c 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -1,66 +1,66 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H -#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseDynamicBuffer { -public: - bool _initialized; - void putText(const char *fmt, ...); - void putTextIndent(int indent, const char *fmt, ...); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - void putString(const char *val); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(const byte *buffer, uint32 size); - uint32 getSize(); - bool init(uint32 initSize = 0); - void cleanup(); - uint32 _size; - byte *_buffer; - BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); - virtual ~BaseDynamicBuffer(); - -private: - uint32 _realSize; - uint32 _growBy; - uint32 _initSize; - uint32 _offset; - void putTextForm(const char *format, va_list argptr); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H +#define WINTERMUTE_BASE_DYNAMIC_BUFFER_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseDynamicBuffer { +public: + bool _initialized; + void putText(const char *fmt, ...); + void putTextIndent(int indent, const char *fmt, ...); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + void putString(const char *val); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(const byte *buffer, uint32 size); + uint32 getSize(); + bool init(uint32 initSize = 0); + void cleanup(); + uint32 _size; + byte *_buffer; + BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); + virtual ~BaseDynamicBuffer(); + +private: + uint32 _realSize; + uint32 _growBy; + uint32 _initSize; + uint32 _offset; + void putTextForm(const char *format, va_list argptr); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 580a7afeb4..08e6f689ba 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -1,194 +1,194 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_fader.h" -#include "engines/wintermute/base/base_game.h" -#include "common/util.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFader, false) - -////////////////////////////////////////////////////////////////////////// -BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { - _active = false; - _red = _green = _blue = 0; - _currentAlpha = 0x00; - _sourceAlpha = 0; - _targetAlpha = 0; - _duration = 1000; - _startTime = 0; - _system = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFader::~BaseFader() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::update() { - if (!_active) { - return STATUS_OK; - } - - int alphaDelta = _targetAlpha - _sourceAlpha; - - uint32 time; - - if (_system) { - time = g_system->getMillis() - _startTime; - } else { - time = _gameRef->_timer - _startTime; - } - - if (time >= _duration) { - _currentAlpha = _targetAlpha; - } else { - _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); - } - _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean - - _ready = time >= _duration; - if (_ready && _currentAlpha == 0x00) { - _active = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::display() { - if (!_active) { - return STATUS_OK; - } - - if (_currentAlpha > 0x00) { - _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::deactivate() { - _active = false; - _ready = true; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(sourceColor); - _green = RGBCOLGetG(sourceColor); - _blue = RGBCOLGetB(sourceColor); - - _sourceAlpha = RGBCOLGetA(sourceColor); - _targetAlpha = 0; - - _duration = duration; - _system = system; - - if (_system) { - _startTime = g_system->getMillis(); - } else { - _startTime = _gameRef->_timer; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { - _ready = false; - _active = true; - - _red = RGBCOLGetR(targetColor); - _green = RGBCOLGetG(targetColor); - _blue = RGBCOLGetB(targetColor); - - //_sourceAlpha = 0; - _sourceAlpha = _currentAlpha; - _targetAlpha = RGBCOLGetA(targetColor); - - _duration = duration; - _system = system; - - if (_system) { - _startTime = g_system->getMillis(); - } else { - _startTime = _gameRef->_timer; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseFader::getCurrentColor() { - return BYTETORGBA(_red, _green, _blue, _currentAlpha); -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseFader::persist(BasePersistenceManager *persistMgr) { - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_blue)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_duration)); - persistMgr->transfer(TMEMBER(_green)); - persistMgr->transfer(TMEMBER(_red)); - persistMgr->transfer(TMEMBER(_sourceAlpha)); - persistMgr->transfer(TMEMBER(_startTime)); - persistMgr->transfer(TMEMBER(_targetAlpha)); - persistMgr->transfer(TMEMBER(_system)); - - if (_system && !persistMgr->getIsSaving()) { - _startTime = 0; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_fader.h" +#include "engines/wintermute/base/base_game.h" +#include "common/util.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFader, false) + +////////////////////////////////////////////////////////////////////////// +BaseFader::BaseFader(BaseGame *inGame) : BaseObject(inGame) { + _active = false; + _red = _green = _blue = 0; + _currentAlpha = 0x00; + _sourceAlpha = 0; + _targetAlpha = 0; + _duration = 1000; + _startTime = 0; + _system = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFader::~BaseFader() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::update() { + if (!_active) { + return STATUS_OK; + } + + int alphaDelta = _targetAlpha - _sourceAlpha; + + uint32 time; + + if (_system) { + time = g_system->getMillis() - _startTime; + } else { + time = _gameRef->_timer - _startTime; + } + + if (time >= _duration) { + _currentAlpha = _targetAlpha; + } else { + _currentAlpha = (byte)(_sourceAlpha + (float)time / (float)_duration * alphaDelta); + } + _currentAlpha = MIN((unsigned char)255, MAX(_currentAlpha, (byte)0)); // TODO: clean + + _ready = time >= _duration; + if (_ready && _currentAlpha == 0x00) { + _active = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::display() { + if (!_active) { + return STATUS_OK; + } + + if (_currentAlpha > 0x00) { + _gameRef->_renderer->fadeToColor(_red, _green, _blue, _currentAlpha); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::deactivate() { + _active = false; + _ready = true; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::fadeIn(uint32 sourceColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(sourceColor); + _green = RGBCOLGetG(sourceColor); + _blue = RGBCOLGetB(sourceColor); + + _sourceAlpha = RGBCOLGetA(sourceColor); + _targetAlpha = 0; + + _duration = duration; + _system = system; + + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::fadeOut(uint32 targetColor, uint32 duration, bool system) { + _ready = false; + _active = true; + + _red = RGBCOLGetR(targetColor); + _green = RGBCOLGetG(targetColor); + _blue = RGBCOLGetB(targetColor); + + //_sourceAlpha = 0; + _sourceAlpha = _currentAlpha; + _targetAlpha = RGBCOLGetA(targetColor); + + _duration = duration; + _system = system; + + if (_system) { + _startTime = g_system->getMillis(); + } else { + _startTime = _gameRef->_timer; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseFader::getCurrentColor() { + return BYTETORGBA(_red, _green, _blue, _currentAlpha); +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseFader::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_blue)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_duration)); + persistMgr->transfer(TMEMBER(_green)); + persistMgr->transfer(TMEMBER(_red)); + persistMgr->transfer(TMEMBER(_sourceAlpha)); + persistMgr->transfer(TMEMBER(_startTime)); + persistMgr->transfer(TMEMBER(_targetAlpha)); + persistMgr->transfer(TMEMBER(_system)); + + if (_system && !persistMgr->getIsSaving()) { + _startTime = 0; + } + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index 30072babfa..d3ced4aacc 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -1,63 +1,63 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FADER_H -#define WINTERMUTE_BASE_FADER_H - - -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class BaseFader : public BaseObject { -public: - bool _system; - uint32 getCurrentColor(); - bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); - bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); - bool deactivate(); - bool display(); - bool update(); - DECLARE_PERSISTENT(BaseFader, BaseObject) - BaseFader(BaseGame *inGame); - virtual ~BaseFader(); -private: - bool _active; - byte _red; - byte _green; - byte _blue; - byte _currentAlpha; - byte _targetAlpha; - byte _sourceAlpha; - uint32 _duration; - uint32 _startTime; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FADER_H +#define WINTERMUTE_BASE_FADER_H + + +#include "engines/wintermute/base/base_object.h" + +namespace Wintermute { + +class BaseFader : public BaseObject { +public: + bool _system; + uint32 getCurrentColor(); + bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); + bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); + bool deactivate(); + bool display(); + bool update(); + DECLARE_PERSISTENT(BaseFader, BaseObject) + BaseFader(BaseGame *inGame); + virtual ~BaseFader(); +private: + bool _active; + byte _red; + byte _green; + byte _blue; + byte _currentAlpha; + byte _targetAlpha; + byte _sourceAlpha; + uint32 _duration; + uint32 _startTime; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_file_manager.cpp b/engines/wintermute/base/base_file_manager.cpp index f139d99146..b726c0c66f 100644 --- a/engines/wintermute/base/base_file_manager.cpp +++ b/engines/wintermute/base/base_file_manager.cpp @@ -1,340 +1,340 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_persistence_manager.h" -#include "engines/wintermute/base/file/base_disk_file.h" -#include "engines/wintermute/base/file/base_save_thumb_file.h" -#include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/base_resources.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/wintermute.h" -#include "common/debug.h" -#include "common/str.h" -#include "common/tokenizer.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/config-manager.h" -#include "common/system.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/savefile.h" -#include "common/fs.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -////////////////////////////////////////////////////////////////////// -BaseFileManager::BaseFileManager(Common::Language lang) { - _language = lang; - initPaths(); - registerPackages(); -} - -////////////////////////////////////////////////////////////////////// -BaseFileManager::~BaseFileManager() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::cleanup() { - // delete registered paths - _packagePaths.clear(); - - // close open files - for (uint32 i = 0; i < _openFiles.size(); i++) { - delete _openFiles[i]; - } - _openFiles.clear(); - - // delete packages - _packages.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { - byte *buffer = NULL; - - Common::SeekableReadStream *file = openFile(filename); - if (!file) { - if (mustExist) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error opening file '%s'", filename.c_str()); - } - return NULL; - } - - buffer = new byte[file->size() + 1]; - if (buffer == NULL) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); - closeFile(file); - return NULL; - } - - if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error reading file '%s'", filename.c_str()); - closeFile(file); - delete[] buffer; - return NULL; - }; - - buffer[file->size()] = '\0'; - if (size != NULL) { - *size = file->size(); - } - closeFile(file); - - return buffer; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { - if (!path.exists()) { - return STATUS_FAILED; - } - - switch (type) { - case PATH_SINGLE: - // _singlePaths.push_back(path); - error("TODO: Allow adding single-paths"); - break; - case PATH_PACKAGE: - _packagePaths.push_back(path); - break; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::reloadPaths() { - // delete registered paths - //_singlePaths.clear(); - _packagePaths.clear(); - - return initPaths(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::initPaths() { - // Removed: Config-based file-path choice. - - // package files paths - const Common::FSNode gameData(ConfMan.get("path")); - addPath(PATH_PACKAGE, gameData); - - Common::FSNode dataSubFolder = gameData.getChild("data"); - if (dataSubFolder.exists()) { - addPath(PATH_PACKAGE, dataSubFolder); - } - Common::FSNode languageSubFolder = gameData.getChild("language"); - if (languageSubFolder.exists()) { - addPath(PATH_PACKAGE, languageSubFolder); - } - return STATUS_OK; -} - -bool BaseFileManager::registerPackages(const Common::FSList &fslist) { - for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); ++it) { - debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); - if ((*it).getName().contains(".dcp")) { - if (registerPackage((*it))) { - addPath(PATH_PACKAGE, (*it)); - } - } - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::registerPackages() { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Scanning packages"); - - // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail - // and that has to be like that to support the detection-scheme. - Common::FSList files; - for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); ++it) { - debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); - (*it).getChildren(files, Common::FSNode::kListFilesOnly); - for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { - if (!fileIt->getName().hasSuffix(".dcp")) { - continue; - } - // Avoid registering all the language files - // TODO: Select based on the gameDesc. - if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { - Common::String parentName = fileIt->getParent().getName(); - Common::String dcpName = fileIt->getName(); - if (_language == Common::EN_ANY && fileIt->getName() != "english.dcp") { - continue; - } else if (_language == Common::CZ_CZE && fileIt->getName() != "czech.dcp") { - continue; - } else if (_language == Common::IT_ITA && fileIt->getName() != "italian.dcp") { - continue; - } else if (_language == Common::PL_POL && fileIt->getName() != "polish.dcp") { - continue; - } else if (_language == Common::RU_RUS && fileIt->getName() != "russian.dcp") { - continue; - } - } - debugC(kWintermuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); - registerPackage((*fileIt)); - } - } - -// debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - - return STATUS_OK; -} - -bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { - PackageSet *pack = new PackageSet(file, filename, searchSignature); - _packages.add(file.getName(), pack, pack->getPriority() , true); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &filename) { - Common::String upcName = filename; - upcName.toUppercase(); - Common::SeekableReadStream *file = NULL; - char fileName[MAX_PATH_LENGTH]; - strcpy(fileName, upcName.c_str()); - - // correct slashes - for (uint32 i = 0; i < upcName.size(); i++) { - if (upcName[(int32)i] == '/') { - upcName.setChar('\\', (uint32)i); - } - } - Common::ArchiveMemberPtr entry = _packages.getMember(upcName); - if (!entry) { - return NULL; - } - file = entry->createReadStream(); - return file; -} - -bool BaseFileManager::hasFile(const Common::String &filename) { - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - BasePersistenceManager pm(BaseEngine::instance().getGameId()); - if (filename.size() <= 9) { - return false; - } - int slot = atoi(filename.c_str() + 9); - return pm.getSaveExists(slot); - } - if (diskFileExists(filename)) { - return true; - } - if (_packages.hasFile(filename)) { - return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. - } - if (BaseResources::hasFile(filename)) { - return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { - if (strcmp(filename.c_str(), "") == 0) { - return NULL; - } - debugC(kWintermuteDebugFileAccess, "Open file %s", filename.c_str()); - - Common::SeekableReadStream *file = openFileRaw(filename); - if (file && keepTrackOf) { - _openFiles.push_back(file); - } - return file; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { - for (uint32 i = 0; i < _openFiles.size(); i++) { - if (_openFiles[i] == File) { - delete _openFiles[i]; - _openFiles.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { - Common::SeekableReadStream *ret = NULL; - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { - if (!BaseEngine::instance().getGameRef()) { - error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); - } - BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); - if (DID_SUCCEED(saveThumbFile->open(filename))) { - ret = saveThumbFile->getMemStream(); - } - delete saveThumbFile; - return ret; - } - - ret = openDiskFile(filename); - if (ret) { - return ret; - } - - ret = openPkgFile(filename); - if (ret) { - return ret; - } - - ret = BaseResources::getFile(filename); - if (ret) { - return ret; - } - - debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); - return NULL; -} - -BaseFileManager *BaseFileManager::getEngineInstance() { - if (BaseEngine::instance().getFileManager()) { - return BaseEngine::instance().getFileManager(); - } - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/file/base_resources.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/wintermute.h" +#include "common/debug.h" +#include "common/str.h" +#include "common/tokenizer.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/config-manager.h" +#include "common/system.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/savefile.h" +#include "common/fs.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////// +BaseFileManager::BaseFileManager(Common::Language lang) { + _language = lang; + initPaths(); + registerPackages(); +} + +////////////////////////////////////////////////////////////////////// +BaseFileManager::~BaseFileManager() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::cleanup() { + // delete registered paths + _packagePaths.clear(); + + // close open files + for (uint32 i = 0; i < _openFiles.size(); i++) { + delete _openFiles[i]; + } + _openFiles.clear(); + + // delete packages + _packages.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +byte *BaseFileManager::readWholeFile(const Common::String &filename, uint32 *size, bool mustExist) { + byte *buffer = NULL; + + Common::SeekableReadStream *file = openFile(filename); + if (!file) { + if (mustExist) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error opening file '%s'", filename.c_str()); + } + return NULL; + } + + buffer = new byte[file->size() + 1]; + if (buffer == NULL) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error allocating buffer for file '%s' (%d bytes)", filename.c_str(), file->size() + 1); + closeFile(file); + return NULL; + } + + if (file->read(buffer, (uint32)file->size()) != (uint32)file->size()) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Error reading file '%s'", filename.c_str()); + closeFile(file); + delete[] buffer; + return NULL; + }; + + buffer[file->size()] = '\0'; + if (size != NULL) { + *size = file->size(); + } + closeFile(file); + + return buffer; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::addPath(TPathType type, const Common::FSNode &path) { + if (!path.exists()) { + return STATUS_FAILED; + } + + switch (type) { + case PATH_SINGLE: + // _singlePaths.push_back(path); + error("TODO: Allow adding single-paths"); + break; + case PATH_PACKAGE: + _packagePaths.push_back(path); + break; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::reloadPaths() { + // delete registered paths + //_singlePaths.clear(); + _packagePaths.clear(); + + return initPaths(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::initPaths() { + // Removed: Config-based file-path choice. + + // package files paths + const Common::FSNode gameData(ConfMan.get("path")); + addPath(PATH_PACKAGE, gameData); + + Common::FSNode dataSubFolder = gameData.getChild("data"); + if (dataSubFolder.exists()) { + addPath(PATH_PACKAGE, dataSubFolder); + } + Common::FSNode languageSubFolder = gameData.getChild("language"); + if (languageSubFolder.exists()) { + addPath(PATH_PACKAGE, languageSubFolder); + } + return STATUS_OK; +} + +bool BaseFileManager::registerPackages(const Common::FSList &fslist) { + for (Common::FSList::const_iterator it = fslist.begin(); it != fslist.end(); ++it) { + debugC(kWintermuteDebugFileAccess, "Adding %s", (*it).getName().c_str()); + if ((*it).getName().contains(".dcp")) { + if (registerPackage((*it))) { + addPath(PATH_PACKAGE, (*it)); + } + } + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::registerPackages() { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, "Scanning packages"); + + // Register without using SearchMan, as otherwise the FSNode-based lookup in openPackage will fail + // and that has to be like that to support the detection-scheme. + Common::FSList files; + for (Common::FSList::iterator it = _packagePaths.begin(); it != _packagePaths.end(); ++it) { + debugC(kWintermuteDebugFileAccess, "Should register folder: %s %s", (*it).getPath().c_str(), (*it).getName().c_str()); + (*it).getChildren(files, Common::FSNode::kListFilesOnly); + for (Common::FSList::iterator fileIt = files.begin(); fileIt != files.end(); ++fileIt) { + if (!fileIt->getName().hasSuffix(".dcp")) { + continue; + } + // Avoid registering all the language files + // TODO: Select based on the gameDesc. + if (_language != Common::UNK_LANG && fileIt->getParent().getName() == "language") { + Common::String parentName = fileIt->getParent().getName(); + Common::String dcpName = fileIt->getName(); + if (_language == Common::EN_ANY && fileIt->getName() != "english.dcp") { + continue; + } else if (_language == Common::CZ_CZE && fileIt->getName() != "czech.dcp") { + continue; + } else if (_language == Common::IT_ITA && fileIt->getName() != "italian.dcp") { + continue; + } else if (_language == Common::PL_POL && fileIt->getName() != "polish.dcp") { + continue; + } else if (_language == Common::RU_RUS && fileIt->getName() != "russian.dcp") { + continue; + } + } + debugC(kWintermuteDebugFileAccess, "Registering %s %s", (*fileIt).getPath().c_str(), (*fileIt).getName().c_str()); + registerPackage((*fileIt)); + } + } + +// debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + return STATUS_OK; +} + +bool BaseFileManager::registerPackage(Common::FSNode file, const Common::String &filename, bool searchSignature) { + PackageSet *pack = new PackageSet(file, filename, searchSignature); + _packages.add(file.getName(), pack, pack->getPriority() , true); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *BaseFileManager::openPkgFile(const Common::String &filename) { + Common::String upcName = filename; + upcName.toUppercase(); + Common::SeekableReadStream *file = NULL; + char fileName[MAX_PATH_LENGTH]; + strcpy(fileName, upcName.c_str()); + + // correct slashes + for (uint32 i = 0; i < upcName.size(); i++) { + if (upcName[(int32)i] == '/') { + upcName.setChar('\\', (uint32)i); + } + } + Common::ArchiveMemberPtr entry = _packages.getMember(upcName); + if (!entry) { + return NULL; + } + file = entry->createReadStream(); + return file; +} + +bool BaseFileManager::hasFile(const Common::String &filename) { + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + BasePersistenceManager pm(BaseEngine::instance().getGameId()); + if (filename.size() <= 9) { + return false; + } + int slot = atoi(filename.c_str() + 9); + return pm.getSaveExists(slot); + } + if (diskFileExists(filename)) { + return true; + } + if (_packages.hasFile(filename)) { + return true; // We don't bother checking if the file can actually be opened, something bigger is wrong if that is the case. + } + if (BaseResources::hasFile(filename)) { + return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *BaseFileManager::openFile(const Common::String &filename, bool absPathWarning, bool keepTrackOf) { + if (strcmp(filename.c_str(), "") == 0) { + return NULL; + } + debugC(kWintermuteDebugFileAccess, "Open file %s", filename.c_str()); + + Common::SeekableReadStream *file = openFileRaw(filename); + if (file && keepTrackOf) { + _openFiles.push_back(file); + } + return file; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFileManager::closeFile(Common::SeekableReadStream *File) { + for (uint32 i = 0; i < _openFiles.size(); i++) { + if (_openFiles[i] == File) { + delete _openFiles[i]; + _openFiles.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +Common::SeekableReadStream *BaseFileManager::openFileRaw(const Common::String &filename) { + Common::SeekableReadStream *ret = NULL; + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) == 0) { + if (!BaseEngine::instance().getGameRef()) { + error("Attempt to load filename: %s without BaseEngine-object, this is unsupported", filename.c_str()); + } + BaseSaveThumbFile *saveThumbFile = new BaseSaveThumbFile(); + if (DID_SUCCEED(saveThumbFile->open(filename))) { + ret = saveThumbFile->getMemStream(); + } + delete saveThumbFile; + return ret; + } + + ret = openDiskFile(filename); + if (ret) { + return ret; + } + + ret = openPkgFile(filename); + if (ret) { + return ret; + } + + ret = BaseResources::getFile(filename); + if (ret) { + return ret; + } + + debugC(kWintermuteDebugFileAccess ,"BFileManager::OpenFileRaw - Failed to open %s", filename.c_str()); + return NULL; +} + +BaseFileManager *BaseFileManager::getEngineInstance() { + if (BaseEngine::instance().getFileManager()) { + return BaseEngine::instance().getFileManager(); + } + return NULL; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_file_manager.h b/engines/wintermute/base/base_file_manager.h index 3fb4434e9c..70aff49bbb 100644 --- a/engines/wintermute/base/base_file_manager.h +++ b/engines/wintermute/base/base_file_manager.h @@ -1,76 +1,76 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FILE_MANAGER_H -#define WINTERMUTE_BASE_FILE_MANAGER_H - -#include "common/archive.h" -#include "common/str.h" -#include "common/fs.h" -#include "common/file.h" -#include "common/language.h" - -namespace Wintermute { -class BaseFileManager { -public: - bool cleanup(); - - bool closeFile(Common::SeekableReadStream *File); - bool hasFile(const Common::String &filename); - Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); - byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); - - BaseFileManager(Common::Language lang); - virtual ~BaseFileManager(); - // Used only for detection - bool registerPackages(const Common::FSList &fslist); - static BaseFileManager *getEngineInstance(); -private: - typedef enum { - PATH_PACKAGE, - PATH_SINGLE - } TPathType; - bool reloadPaths(); - bool initPaths(); - bool addPath(TPathType type, const Common::FSNode &path); - bool registerPackages(); - Common::SeekableReadStream *openFileRaw(const Common::String &filename); - Common::SeekableReadStream *openPkgFile(const Common::String &filename); - Common::FSList _packagePaths; - bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); - bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); - Common::SearchSet _packages; - Common::Array _openFiles; - Common::Language _language; - // This class is intentionally not a subclass of Base, as it needs to be used by - // the detector too, without launching the entire engine: -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILE_MANAGER_H +#define WINTERMUTE_BASE_FILE_MANAGER_H + +#include "common/archive.h" +#include "common/str.h" +#include "common/fs.h" +#include "common/file.h" +#include "common/language.h" + +namespace Wintermute { +class BaseFileManager { +public: + bool cleanup(); + + bool closeFile(Common::SeekableReadStream *File); + bool hasFile(const Common::String &filename); + Common::SeekableReadStream *openFile(const Common::String &filename, bool absPathWarning = true, bool keepTrackOf = true); + byte *readWholeFile(const Common::String &filename, uint32 *size = NULL, bool mustExist = true); + + BaseFileManager(Common::Language lang); + virtual ~BaseFileManager(); + // Used only for detection + bool registerPackages(const Common::FSList &fslist); + static BaseFileManager *getEngineInstance(); +private: + typedef enum { + PATH_PACKAGE, + PATH_SINGLE + } TPathType; + bool reloadPaths(); + bool initPaths(); + bool addPath(TPathType type, const Common::FSNode &path); + bool registerPackages(); + Common::SeekableReadStream *openFileRaw(const Common::String &filename); + Common::SeekableReadStream *openPkgFile(const Common::String &filename); + Common::FSList _packagePaths; + bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset); + bool registerPackage(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); + Common::SearchSet _packages; + Common::Array _openFiles; + Common::Language _language; + // This class is intentionally not a subclass of Base, as it needs to be used by + // the detector too, without launching the entire engine: +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index ed2c7acaca..e1b29a3a5c 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -1,760 +1,760 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_frame.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "common/str.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseFrame, false) - -////////////////////////////////////////////////////////////////////// -BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { - _delay = 0; - _moveX = _moveY = 0; - - _sound = NULL; - _killSound = false; - - _editorExpanded = false; - _keyframe = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseFrame::~BaseFrame() { - delete _sound; - _sound = NULL; - - for (uint32 i = 0; i < _subframes.size(); i++) { - delete _subframes[i]; - } - _subframes.clear(); - - for (uint32 i = 0; i < _applyEvent.size(); i++) { - delete[] _applyEvent[i]; - _applyEvent[i] = NULL; - } - _applyEvent.clear(); -} - - -////////////////////////////////////////////////////////////////////// -bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { - bool res; - - for (uint32 i = 0; i < _subframes.size(); i++) { - res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); - if (DID_FAIL(res)) { - return res; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { - if (_sound && !muted) { - if (owner) { - owner->updateOneSound(_sound); - } - _sound->play(); - /* - if (_gameRef->_state == GAME_FROZEN) { - _sound->Pause(true); - } - */ - } - if (owner) { - for (uint32 i = 0; i < _applyEvent.size(); i++) { - owner->applyEvent(_applyEvent[i]); - } - } - return STATUS_OK; -} - - - -TOKEN_DEF_START -TOKEN_DEF(DELAY) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(MOVE) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(SUBFRAME) -TOKEN_DEF(SOUND) -TOKEN_DEF(KEYFRAME) -TOKEN_DEF(DECORATION) -TOKEN_DEF(APPLY_EVENT) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_EXPANDED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(KILL_SOUND) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(DELAY) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(MOVE) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(SUBFRAME) - TOKEN_TABLE(SOUND) - TOKEN_TABLE(KEYFRAME) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(APPLY_EVENT) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_EXPANDED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(KILL_SOUND) - TOKEN_TABLE_END - - char *params; - int cmd; - BaseParser parser; - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - int hotspotX = 0, hotspotY = 0; - bool custoTrans = false; - bool editorSelected = false; - bool is2DOnly = false; - bool is3DOnly = false; - bool decoration = false; - bool mirrorX = false; - bool mirrorY = false; - BasePlatform::setRectEmpty(&rect); - char *surface_file = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_DELAY: - parser.scanStr(params, "%d", &_delay); - break; - - case TOKEN_IMAGE: - surface_file = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); - break; - - case TOKEN_MOVE: - parser.scanStr(params, "%d,%d", &_moveX, &_moveY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &is2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &is3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &mirrorY); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &editorSelected); - break; - - case TOKEN_EDITOR_EXPANDED: - parser.scanStr(params, "%b", &_editorExpanded); - break; - - case TOKEN_KILL_SOUND: - parser.scanStr(params, "%b", &_killSound); - break; - - case TOKEN_SUBFRAME: { - BaseSubFrame *subframe = new BaseSubFrame(_gameRef); - if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { - delete subframe; - cmd = PARSERR_GENERIC; - } else { - _subframes.add(subframe); - } - } - break; - - case TOKEN_SOUND: { - if (_sound) { - delete _sound; - _sound = NULL; - } - _sound = new BaseSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { - if (_gameRef->_soundMgr->_soundAvailable) { - _gameRef->LOG(0, "Error loading sound '%s'.", params); - } - delete _sound; - _sound = NULL; - } - } - break; - - case TOKEN_APPLY_EVENT: { - char *event = new char[strlen(params) + 1]; - strcpy(event, params); - _applyEvent.add(event); - } - break; - - case TOKEN_KEYFRAME: - parser.scanStr(params, "%b", &_keyframe); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &decoration); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FRAME definition"); - return STATUS_FAILED; - } - - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading FRAME definition"); - return STATUS_FAILED; - } - - - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (surface_file != NULL) { - if (custoTrans) { - sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); - } else { - sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); - } - - if (!sub->_surface) { - delete sub; - _gameRef->LOG(0, "Error loading SUBFRAME"); - return STATUS_FAILED; - } - - sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) { - sub->_transparent = BYTETORGBA(r, g, b, 0xFF); - } - } - - if (BasePlatform::isRectEmpty(&rect)) { - sub->setDefaultRect(); - } else { - sub->setRect(rect); - } - - sub->_hotspotX = hotspotX; - sub->_hotspotY = hotspotY; - sub->_2DOnly = is2DOnly; - sub->_3DOnly = is3DOnly; - sub->_decoration = decoration; - sub->_mirrorX = mirrorX; - sub->_mirrorY = mirrorY; - - - sub->_editorSelected = editorSelected; - _subframes.insert_at(0, sub); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) { - return false; - } - BasePlatform::setRectEmpty(rect); - - Rect32 subRect; - - for (uint32 i = 0; i < _subframes.size(); i++) { - _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); - BasePlatform::unionRect(rect, rect, &subRect); - } - return true; -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "FRAME {\n"); - buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); - - if (_moveX != 0 || _moveY != 0) { - buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); - } - - if (_sound && _sound->getFilename()) { - buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); - } - - buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); - - if (_killSound) { - buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); - } - - if (_editorExpanded) { - buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); - } - - if (_subframes.size() > 0) { - _subframes[0]->saveAsText(buffer, indent, false); - } - - for (uint32 i = 1; i < _subframes.size(); i++) { - _subframes[i]->saveAsText(buffer, indent + 2); - } - - for (uint32 i = 0; i < _applyEvent.size(); i++) { - buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); - } - - BaseClass::saveAsText(buffer, indent + 2); - - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::persist(persistMgr); - - _applyEvent.persist(persistMgr); - persistMgr->transfer(TMEMBER(_delay)); - persistMgr->transfer(TMEMBER(_editorExpanded)); - persistMgr->transfer(TMEMBER(_keyframe)); - persistMgr->transfer(TMEMBER(_killSound)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_sound)); - _subframes.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSound") == 0) { - stack->correctParams(0); - - if (_sound && _sound->getFilename()) { - stack->pushString(_sound->getFilename()); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSound - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSound") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - delete _sound; - _sound = NULL; - - if (!val->isNULL()) { - _sound = new BaseSound(_gameRef); - if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { - stack->pushBool(false); - delete _sound; - _sound = NULL; - } else { - stack->pushBool(true); - } - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSubframe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= (int32)_subframes.size()) { - script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); - stack->pushNULL(); - } else { - stack->pushNative(_subframes[index], true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSubframe") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= (int32)_subframes.size()) { - script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); - } - } else { - BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); - for (uint32 i = 0; i < _subframes.size(); i++) { - if (_subframes[i] == sub) { - delete _subframes[i]; - _subframes.remove_at(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSubframe") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - sub->setDefaultRect(); - } - _subframes.add(sub); - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertSubframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertSubframe") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) { - index = 0; - } - - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (filename != NULL) { - sub->setSurface(filename); - } - - if (index >= (int32)_subframes.size()) { - _subframes.add(sub); - } else { - _subframes.insert_at(index, sub); - } - - stack->pushNative(sub, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSubframe") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= (int32)_applyEvent.size()) { - script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); - stack->pushNULL(); - } else { - stack->pushString(_applyEvent[index]); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (uint32 i = 0; i < _applyEvent.size(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - stack->pushNULL(); - return STATUS_OK; - } - } - _applyEvent.add(event); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteEvent") == 0) { - stack->correctParams(1); - const char *event = stack->pop()->getString(); - for (uint32 i = 0; i < _applyEvent.size(); i++) { - if (scumm_stricmp(_applyEvent[i], event) == 0) { - delete[] _applyEvent[i]; - _applyEvent.remove_at(i); - break; - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.size() == 1) { - return _subframes[0]->scCallMethod(script, stack, thisStack, name); - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseFrame::scGetProperty(const char *name) { - if (!_scValue) { - _scValue = new ScValue(_gameRef); - } - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("frame"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { - _scValue->setInt(_delay); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _scValue->setBool(_keyframe); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _scValue->setBool(_killSound); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _scValue->setInt(_moveX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _scValue->setInt(_moveY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumSubframes (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { - _scValue->setInt(_subframes.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumEvents (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { - _scValue->setInt(_applyEvent.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.size() == 1) { - return _subframes[0]->scGetProperty(name); - } else { - return BaseScriptable::scGetProperty(name); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFrame::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Delay - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Delay") == 0) { - _delay = MAX(0, value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyframe - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { - _keyframe = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // KillSounds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { - _killSound = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { - _moveX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MoveY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { - _moveY = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - else { - if (_subframes.size() == 1) { - return _subframes[0]->scSetProperty(name, value); - } else { - return BaseScriptable::scSetProperty(name, value); - } - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseFrame::scToString() { - return "[frame]"; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/str.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseFrame, false) + +////////////////////////////////////////////////////////////////////// +BaseFrame::BaseFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { + _delay = 0; + _moveX = _moveY = 0; + + _sound = NULL; + _killSound = false; + + _editorExpanded = false; + _keyframe = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseFrame::~BaseFrame() { + delete _sound; + _sound = NULL; + + for (uint32 i = 0; i < _subframes.size(); i++) { + delete _subframes[i]; + } + _subframes.clear(); + + for (uint32 i = 0; i < _applyEvent.size(); i++) { + delete[] _applyEvent[i]; + _applyEvent[i] = NULL; + } + _applyEvent.clear(); +} + + +////////////////////////////////////////////////////////////////////// +bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, bool allFrames, float rotate, TSpriteBlendMode blendMode) { + bool res; + + for (uint32 i = 0; i < _subframes.size(); i++) { + res = _subframes[i]->draw(x, y, registerOwner, zoomX, zoomY, precise, alpha, rotate, blendMode); + if (DID_FAIL(res)) { + return res; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { + if (_sound && !muted) { + if (owner) { + owner->updateOneSound(_sound); + } + _sound->play(); + /* + if (_gameRef->_state == GAME_FROZEN) { + _sound->Pause(true); + } + */ + } + if (owner) { + for (uint32 i = 0; i < _applyEvent.size(); i++) { + owner->applyEvent(_applyEvent[i]); + } + } + return STATUS_OK; +} + + + +TOKEN_DEF_START +TOKEN_DEF(DELAY) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(MOVE) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(SUBFRAME) +TOKEN_DEF(SOUND) +TOKEN_DEF(KEYFRAME) +TOKEN_DEF(DECORATION) +TOKEN_DEF(APPLY_EVENT) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_EXPANDED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(KILL_SOUND) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool BaseFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(DELAY) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(MOVE) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(SUBFRAME) + TOKEN_TABLE(SOUND) + TOKEN_TABLE(KEYFRAME) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(APPLY_EVENT) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_EXPANDED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(KILL_SOUND) + TOKEN_TABLE_END + + char *params; + int cmd; + BaseParser parser; + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + int hotspotX = 0, hotspotY = 0; + bool custoTrans = false; + bool editorSelected = false; + bool is2DOnly = false; + bool is3DOnly = false; + bool decoration = false; + bool mirrorX = false; + bool mirrorY = false; + BasePlatform::setRectEmpty(&rect); + char *surface_file = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_DELAY: + parser.scanStr(params, "%d", &_delay); + break; + + case TOKEN_IMAGE: + surface_file = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &hotspotX, &hotspotY); + break; + + case TOKEN_MOVE: + parser.scanStr(params, "%d,%d", &_moveX, &_moveY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &is2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &is3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &mirrorY); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &editorSelected); + break; + + case TOKEN_EDITOR_EXPANDED: + parser.scanStr(params, "%b", &_editorExpanded); + break; + + case TOKEN_KILL_SOUND: + parser.scanStr(params, "%b", &_killSound); + break; + + case TOKEN_SUBFRAME: { + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); + if (!subframe || DID_FAIL(subframe->loadBuffer((byte *)params, lifeTime, keepLoaded))) { + delete subframe; + cmd = PARSERR_GENERIC; + } else { + _subframes.add(subframe); + } + } + break; + + case TOKEN_SOUND: { + if (_sound) { + delete _sound; + _sound = NULL; + } + _sound = new BaseSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(params, Audio::Mixer::kSFXSoundType, false))) { + if (_gameRef->_soundMgr->_soundAvailable) { + _gameRef->LOG(0, "Error loading sound '%s'.", params); + } + delete _sound; + _sound = NULL; + } + } + break; + + case TOKEN_APPLY_EVENT: { + char *event = new char[strlen(params) + 1]; + strcpy(event, params); + _applyEvent.add(event); + } + break; + + case TOKEN_KEYFRAME: + parser.scanStr(params, "%b", &_keyframe); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &decoration); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FRAME definition"); + return STATUS_FAILED; + } + + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading FRAME definition"); + return STATUS_FAILED; + } + + + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (surface_file != NULL) { + if (custoTrans) { + sub->setSurface(surface_file, false, r, g, b, lifeTime, keepLoaded); + } else { + sub->setSurface(surface_file, true, 0, 0, 0, lifeTime, keepLoaded); + } + + if (!sub->_surface) { + delete sub; + _gameRef->LOG(0, "Error loading SUBFRAME"); + return STATUS_FAILED; + } + + sub->_alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) { + sub->_transparent = BYTETORGBA(r, g, b, 0xFF); + } + } + + if (BasePlatform::isRectEmpty(&rect)) { + sub->setDefaultRect(); + } else { + sub->setRect(rect); + } + + sub->_hotspotX = hotspotX; + sub->_hotspotY = hotspotY; + sub->_2DOnly = is2DOnly; + sub->_3DOnly = is3DOnly; + sub->_decoration = decoration; + sub->_mirrorX = mirrorX; + sub->_mirrorY = mirrorY; + + + sub->_editorSelected = editorSelected; + _subframes.insert_at(0, sub); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) { + return false; + } + BasePlatform::setRectEmpty(rect); + + Rect32 subRect; + + for (uint32 i = 0; i < _subframes.size(); i++) { + _subframes[i]->getBoundingRect(&subRect, x, y, scaleX, scaleY); + BasePlatform::unionRect(rect, rect, &subRect); + } + return true; +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "FRAME {\n"); + buffer->putTextIndent(indent + 2, "DELAY = %d\n", _delay); + + if (_moveX != 0 || _moveY != 0) { + buffer->putTextIndent(indent + 2, "MOVE {%d, %d}\n", _moveX, _moveY); + } + + if (_sound && _sound->getFilename()) { + buffer->putTextIndent(indent + 2, "SOUND=\"%s\"\n", _sound->getFilename()); + } + + buffer->putTextIndent(indent + 2, "KEYFRAME=%s\n", _keyframe ? "TRUE" : "FALSE"); + + if (_killSound) { + buffer->putTextIndent(indent + 2, "KILL_SOUND=%s\n", _killSound ? "TRUE" : "FALSE"); + } + + if (_editorExpanded) { + buffer->putTextIndent(indent + 2, "EDITOR_EXPANDED=%s\n", _editorExpanded ? "TRUE" : "FALSE"); + } + + if (_subframes.size() > 0) { + _subframes[0]->saveAsText(buffer, indent, false); + } + + for (uint32 i = 1; i < _subframes.size(); i++) { + _subframes[i]->saveAsText(buffer, indent + 2); + } + + for (uint32 i = 0; i < _applyEvent.size(); i++) { + buffer->putTextIndent(indent + 2, "APPLY_EVENT=\"%s\"\n", _applyEvent[i]); + } + + BaseClass::saveAsText(buffer, indent + 2); + + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); + + _applyEvent.persist(persistMgr); + persistMgr->transfer(TMEMBER(_delay)); + persistMgr->transfer(TMEMBER(_editorExpanded)); + persistMgr->transfer(TMEMBER(_keyframe)); + persistMgr->transfer(TMEMBER(_killSound)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_sound)); + _subframes.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSound") == 0) { + stack->correctParams(0); + + if (_sound && _sound->getFilename()) { + stack->pushString(_sound->getFilename()); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSound + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSound") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + delete _sound; + _sound = NULL; + + if (!val->isNULL()) { + _sound = new BaseSound(_gameRef); + if (!_sound || DID_FAIL(_sound->setSound(val->getString(), Audio::Mixer::kSFXSoundType, false))) { + stack->pushBool(false); + delete _sound; + _sound = NULL; + } else { + stack->pushBool(true); + } + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSubframe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= (int32)_subframes.size()) { + script->runtimeError("Frame.GetSubframe: Subframe index %d is out of range.", index); + stack->pushNULL(); + } else { + stack->pushNative(_subframes[index], true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSubframe") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= (int32)_subframes.size()) { + script->runtimeError("Frame.DeleteSubframe: Subframe index %d is out of range.", index); + } + } else { + BaseSubFrame *sub = (BaseSubFrame *)val->getNative(); + for (uint32 i = 0; i < _subframes.size(); i++) { + if (_subframes[i] == sub) { + delete _subframes[i]; + _subframes.remove_at(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSubframe") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + sub->setDefaultRect(); + } + _subframes.add(sub); + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertSubframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertSubframe") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) { + index = 0; + } + + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (filename != NULL) { + sub->setSurface(filename); + } + + if (index >= (int32)_subframes.size()) { + _subframes.add(sub); + } else { + _subframes.insert_at(index, sub); + } + + stack->pushNative(sub, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSubframe") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= (int32)_applyEvent.size()) { + script->runtimeError("Frame.GetEvent: Event index %d is out of range.", index); + stack->pushNULL(); + } else { + stack->pushString(_applyEvent[index]); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (uint32 i = 0; i < _applyEvent.size(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + stack->pushNULL(); + return STATUS_OK; + } + } + _applyEvent.add(event); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteEvent") == 0) { + stack->correctParams(1); + const char *event = stack->pop()->getString(); + for (uint32 i = 0; i < _applyEvent.size(); i++) { + if (scumm_stricmp(_applyEvent[i], event) == 0) { + delete[] _applyEvent[i]; + _applyEvent.remove_at(i); + break; + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.size() == 1) { + return _subframes[0]->scCallMethod(script, stack, thisStack, name); + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseFrame::scGetProperty(const char *name) { + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("frame"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delay") == 0) { + _scValue->setInt(_delay); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _scValue->setBool(_keyframe); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _scValue->setBool(_killSound); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _scValue->setInt(_moveX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _scValue->setInt(_moveY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumSubframes (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumSubframes") == 0) { + _scValue->setInt(_subframes.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumEvents (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumEvents") == 0) { + _scValue->setInt(_applyEvent.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.size() == 1) { + return _subframes[0]->scGetProperty(name); + } else { + return BaseScriptable::scGetProperty(name); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFrame::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Delay + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Delay") == 0) { + _delay = MAX(0, value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyframe + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyframe") == 0) { + _keyframe = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // KillSounds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KillSounds") == 0) { + _killSound = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveX") == 0) { + _moveX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MoveY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MoveY") == 0) { + _moveY = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + else { + if (_subframes.size() == 1) { + return _subframes[0]->scSetProperty(name, value); + } else { + return BaseScriptable::scSetProperty(name, value); + } + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseFrame::scToString() { + return "[frame]"; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index c89fb49e61..ea5467b6fe 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -1,73 +1,73 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FRAME_H -#define WINTERMUTE_BASE_FRAME_H - -#include "engines/wintermute/base/base_scriptable.h" -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { -class BaseSound; -class BaseSubFrame; -class BaseObject; -class ScScript; -class ScStack; -class BaseFrame: public BaseScriptable { -public: - bool _killSound; - bool _keyframe; - bool oneTimeDisplay(BaseObject *owner, bool muted = false); - DECLARE_PERSISTENT(BaseFrame, BaseScriptable) - BaseSound *_sound; - bool _editorExpanded; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - bool saveAsText(BaseDynamicBuffer *buffer, int indent); - int _moveY; - int _moveX; - uint32 _delay; - BaseArray _subframes; - bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - - BaseFrame(BaseGame *inGame); - virtual ~BaseFrame(); - - BaseArray _applyEvent; - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FRAME_H +#define WINTERMUTE_BASE_FRAME_H + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { +class BaseSound; +class BaseSubFrame; +class BaseObject; +class ScScript; +class ScStack; +class BaseFrame: public BaseScriptable { +public: + bool _killSound; + bool _keyframe; + bool oneTimeDisplay(BaseObject *owner, bool muted = false); + DECLARE_PERSISTENT(BaseFrame, BaseScriptable) + BaseSound *_sound; + bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + int _moveY; + int _moveX; + uint32 _delay; + BaseArray _subframes; + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, bool allFrames = false, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + + BaseFrame(BaseGame *inGame); + virtual ~BaseFrame(); + + BaseArray _applyEvent; + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index e8aaac6c40..622e85cc11 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -1,4483 +1,4483 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_fader.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/font/base_font.h" -#include "engines/wintermute/base/font/base_font_storage.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/base_keyboard_state.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_quick_msg.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/base/base_transition_manager.h" -#include "engines/wintermute/base/base_viewport.h" -#include "engines/wintermute/base/base_string_table.h" -#include "engines/wintermute/base/base_region.h" -#include "engines/wintermute/base/base_save_thumb_helper.h" -#include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/base/saveload.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_ext_math.h" -#include "engines/wintermute/video/video_player.h" -#include "engines/wintermute/video/video_theora_player.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/utils/crc.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/ui/ui_window.h" -#include "engines/wintermute/wintermute.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/config-manager.h" -#include "common/savefile.h" -#include "common/textconsole.h" -#include "common/util.h" -#include "common/keyboard.h" -#include "common/system.h" -#include "common/file.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseGame, true) - - -////////////////////////////////////////////////////////////////////// -BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { - _shuttingDown = false; - - _state = GAME_RUNNING; - _origState = GAME_RUNNING; - _freezeLevel = 0; - - _interactive = true; - _origInteractive = false; - - _surfaceStorage = NULL; - _fontStorage = NULL; - _renderer = NULL; - _soundMgr = NULL; - _transMgr = NULL; - _scEngine = NULL; - _keyboardState = NULL; - - _mathClass = NULL; - - _debugLogFile = NULL; - _debugDebugMode = false; - _debugShowFPS = false; - - _systemFont = NULL; - _videoFont = NULL; - - _videoPlayer = NULL; - _theoraPlayer = NULL; - - _mainObject = NULL; - _activeObject = NULL; - - _fader = NULL; - - _offsetX = _offsetY = 0; - _offsetPercentX = _offsetPercentY = 0.0f; - - _subtitles = true; - _videoSubtitles = true; - - _timer = 0; - _timerDelta = 0; - _timerLast = 0; - - _liveTimer = 0; - _liveTimerDelta = 0; - _liveTimerLast = 0; - - _sequence = 0; - - _mousePos.x = _mousePos.y = 0; - _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; - _capturedObject = NULL; - - // FPS counters - _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; - - _cursorNoninteractive = NULL; - - _useD3D = false; - - _stringTable = new BaseStringTable(this); - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - _settingsResWidth = 800; - _settingsResHeight = 600; - _settingsRequireAcceleration = false; - _settingsRequireSound = false; - _settingsTLMode = 0; - _settingsAllowWindowed = true; - _settingsGameFile = NULL; - _settingsAllowAdvanced = false; - _settingsAllowAccessTab = true; - _settingsAllowAboutTab = true; - _settingsAllowDesktopRes = false; - - _editorForceScripts = false; - _editorAlwaysRegister = false; - - _focusedWindow = NULL; - - _loadInProgress = false; - - _quitting = false; - _loading = false; - _scheduledLoadSlot = -1; - - _personalizedSave = false; - _compressedSavegames = true; - - _editorMode = false; - //_doNotExpandStrings = false; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - _smartCache = false; - _surfaceGCCycleTime = 10000; - - _reportTextureFormat = false; - - _viewportSP = -1; - - _subtitlesSpeed = 70; - - _forceNonStreamedSounds = false; - - _thumbnailWidth = _thumbnailHeight = 0; - - _richSavedGames = false; - _savedGameExt = NULL; - BaseUtils::setString(&_savedGameExt, "dsv"); - - _musicCrossfadeRunning = false; - _musicCrossfadeStartTime = 0; - _musicCrossfadeLength = 0; - _musicCrossfadeChannel1 = -1; - _musicCrossfadeChannel2 = -1; - _musicCrossfadeSwap = false; - - _localSaveDir = NULL; - BaseUtils::setString(&_localSaveDir, "saves"); - _saveDirChecked = false; - - _loadingIcon = NULL; - _loadingIconX = _loadingIconY = 0; - _loadingIconPersistent = false; - - _textEncoding = TEXT_ANSI; - _textRTL = false; - - _soundBufferSizeSec = 3; - _suspendedRendering = false; - - _lastCursor = NULL; - - - BasePlatform::setRectEmpty(&_mouseLockRect); - - _suppressScriptErrors = false; - _lastMiniUpdate = 0; - _miniUpdateEnabled = false; - - _cachedThumbnail = NULL; - - _autorunDisabled = false; - - // compatibility bits - _compatKillMethodThreads = false; - - _usedMem = 0; - - - _autoSaveOnExit = true; - _autoSaveSlot = 999; - _cursorHidden = false; - - // Block kept as a reminder that the engine CAN run in constrained/touch-mode - /*#ifdef __IPHONEOS__ - _touchInterface = true; - _constrainedMemory = true; // TODO differentiate old and new iOS devices - #else*/ - _touchInterface = false; - _constrainedMemory = false; -//#endif - -} - - -////////////////////////////////////////////////////////////////////// -BaseGame::~BaseGame() { - _shuttingDown = true; - - LOG(0, ""); - LOG(0, "Shutting down..."); - - ConfMan.setBool("last_run", true); - - cleanup(); - - delete[] _localSaveDir; - delete[] _settingsGameFile; - delete[] _savedGameExt; - - delete _cachedThumbnail; - - delete _mathClass; - - delete _transMgr; - delete _scEngine; - delete _fontStorage; - delete _surfaceStorage; - delete _videoPlayer; - delete _theoraPlayer; - delete _soundMgr; - //SAFE_DELETE(_keyboardState); - - delete _renderer; - delete _stringTable; - - _localSaveDir = NULL; - _settingsGameFile = NULL; - _savedGameExt = NULL; - - _cachedThumbnail = NULL; - - _mathClass = NULL; - - _transMgr = NULL; - _scEngine = NULL; - _fontStorage = NULL; - _surfaceStorage = NULL; - _videoPlayer = NULL; - _theoraPlayer = NULL; - _soundMgr = NULL; - - _renderer = NULL; - _stringTable = NULL; - - DEBUG_DebugDisable(); - debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::cleanup() { - delete _loadingIcon; - _loadingIcon = NULL; - - _engineLogCallback = NULL; - _engineLogCallbackData = NULL; - - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - delete _music[i]; - _music[i] = NULL; - _musicStartTime[i] = 0; - } - - unregisterObject(_fader); - _fader = NULL; - - for (uint32 i = 0; i < _regObjects.size(); i++) { - delete _regObjects[i]; - _regObjects[i] = NULL; - } - _regObjects.clear(); - - _windows.clear(); // refs only - _focusedWindow = NULL; // ref only - - delete _cursorNoninteractive; - delete _cursor; - delete _activeCursor; - _cursorNoninteractive = NULL; - _cursor = NULL; - _activeCursor = NULL; - - delete _scValue; - delete _sFX; - _scValue = NULL; - _sFX = NULL; - - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->_owner = NULL; - _scripts[i]->finish(); - } - _scripts.clear(); - - _fontStorage->removeFont(_systemFont); - _systemFont = NULL; - - _fontStorage->removeFont(_videoFont); - _videoFont = NULL; - - for (uint32 i = 0; i < _quickMessages.size(); i++) { - delete _quickMessages[i]; - } - _quickMessages.clear(); - - _viewportStack.clear(); - _viewportSP = -1; - - setName(NULL); - setFilename(NULL); - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _lastCursor = NULL; - - delete _keyboardState; - _keyboardState = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize1() { - bool loaded = false; // Not really a loop, but a goto-replacement. - while (!loaded) { - _surfaceStorage = new BaseSurfaceStorage(this); - if (_surfaceStorage == NULL) { - break; - } - - _fontStorage = new BaseFontStorage(this); - if (_fontStorage == NULL) { - break; - } - - _soundMgr = new BaseSoundMgr(this); - if (_soundMgr == NULL) { - break; - } - - _mathClass = new SXMath(this); - if (_mathClass == NULL) { - break; - } - - _scEngine = new ScEngine(this); - if (_scEngine == NULL) { - break; - } - - _videoPlayer = new VideoPlayer(this); - if (_videoPlayer == NULL) { - break; - } - - _transMgr = new BaseTransitionMgr(this); - if (_transMgr == NULL) { - break; - } - - _keyboardState = new BaseKeyboardState(this); - if (_keyboardState == NULL) { - break; - } - - _fader = new BaseFader(this); - if (_fader == NULL) { - break; - } - registerObject(_fader); - - loaded = true; - } - if (loaded == true) { - return STATUS_OK; - } else { - delete _mathClass; - delete _keyboardState; - delete _transMgr; - delete _surfaceStorage; - delete _fontStorage; - delete _soundMgr; - delete _scEngine; - delete _videoPlayer; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize2() { // we know whether we are going to be accelerated - _renderer = makeOSystemRenderer(this); - if (_renderer == NULL) { - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initialize3() { // renderer is initialized - _posX = _renderer->_width / 2; - _posY = _renderer->_height / 2; - _renderer->initIndicator(); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DebugEnable(const char *filename) { - _debugDebugMode = true; - - int secs = g_system->getMillis() / 1000; - int hours = secs / 3600; - secs = secs % 3600; - int mins = secs / 60; - secs = secs % 60; - -#ifdef _DEBUG - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); -#else - LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); -#endif - - LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); - - AnsiString platform = BasePlatform::getPlatformName(); - LOG(0, "Platform: %s", platform.c_str()); - LOG(0, ""); -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DebugDisable() { - if (_debugLogFile != NULL) { - LOG(0, "********** DEBUG LOG CLOSED ********************************************"); - //fclose((FILE *)_debugLogFile); - _debugLogFile = NULL; - } - _debugDebugMode = false; -} - - -////////////////////////////////////////////////////////////////////// -void BaseGame::LOG(bool res, const char *fmt, ...) { - uint32 secs = g_system->getMillis() / 1000; - uint32 hours = secs / 3600; - secs = secs % 3600; - uint32 mins = secs / 60; - secs = secs % 60; - - char buff[512]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - // redirect to an engine's own callback - if (_engineLogCallback) { - _engineLogCallback(buff, res, _engineLogCallbackData); - } - - debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - - //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); - //fflush((FILE *)_debugLogFile); - - //QuickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { - _engineLogCallback = callback; - _engineLogCallbackData = data; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initLoop() { - _viewportSP = -1; - - _currentTime = g_system->getMillis(); - - _renderer->initLoop(); - updateMusicCrossfade(); - - _surfaceStorage->initLoop(); - _fontStorage->initLoop(); - - - //_activeObject = NULL; - - // count FPS - _deltaTime = _currentTime - _lastTime; - _lastTime = _currentTime; - _fpsTime += _deltaTime; - - _liveTimerDelta = _liveTimer - _liveTimerLast; - _liveTimerLast = _liveTimer; - _liveTimer += MIN((uint32)1000, _deltaTime); - - if (_state != GAME_FROZEN) { - _timerDelta = _timer - _timerLast; - _timerLast = _timer; - _timer += MIN((uint32)1000, _deltaTime); - } else { - _timerDelta = 0; - } - - _framesRendered++; - if (_fpsTime > 1000) { - _fps = _framesRendered; - _framesRendered = 0; - _fpsTime = 0; - } - //_gameRef->LOG(0, "%d", _fps); - - getMousePos(&_mousePos); - - _focusedWindow = NULL; - for (int i = _windows.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible) { - _focusedWindow = _windows[i]; - break; - } - } - - updateSounds(); - - if (_fader) { - _fader->update(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseGame::initInput() { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseGame::getSequence() { - return ++_sequence; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setOffset(int offsetX, int offsetY) { - _offsetX = offsetX; - _offsetY = offsetY; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::getOffset(int *offsetX, int *offsetY) { - if (offsetX != NULL) { - *offsetX = _offsetX; - } - if (offsetY != NULL) { - *offsetY = _offsetY; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) { - _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); - } - - delete[] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(GAME) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(SYSTEM_FONT) -TOKEN_DEF(VIDEO_FONT) -TOKEN_DEF(EVENTS) -TOKEN_DEF(CURSOR) -TOKEN_DEF(ACTIVE_CURSOR) -TOKEN_DEF(NONINTERACTIVE_CURSOR) -TOKEN_DEF(STRING_TABLE) -TOKEN_DEF(RESOLUTION) -TOKEN_DEF(SETTINGS) -TOKEN_DEF(REQUIRE_3D_ACCELERATION) -TOKEN_DEF(REQUIRE_SOUND) -TOKEN_DEF(HWTL_MODE) -TOKEN_DEF(ALLOW_WINDOWED_MODE) -TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) -TOKEN_DEF(ALLOW_ABOUT_TAB) -TOKEN_DEF(ALLOW_ADVANCED) -TOKEN_DEF(ALLOW_DESKTOP_RES) -TOKEN_DEF(REGISTRY_PATH) -TOKEN_DEF(PERSONAL_SAVEGAMES) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(PROPERTY) -TOKEN_DEF(SUBTITLES_SPEED) -TOKEN_DEF(SUBTITLES) -TOKEN_DEF(VIDEO_SUBTITLES) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(THUMBNAIL_WIDTH) -TOKEN_DEF(THUMBNAIL_HEIGHT) -TOKEN_DEF(INDICATOR_X) -TOKEN_DEF(INDICATOR_Y) -TOKEN_DEF(INDICATOR_WIDTH) -TOKEN_DEF(INDICATOR_HEIGHT) -TOKEN_DEF(INDICATOR_COLOR) -TOKEN_DEF(SAVE_IMAGE_X) -TOKEN_DEF(SAVE_IMAGE_Y) -TOKEN_DEF(SAVE_IMAGE) -TOKEN_DEF(LOAD_IMAGE_X) -TOKEN_DEF(LOAD_IMAGE_Y) -TOKEN_DEF(LOAD_IMAGE) -TOKEN_DEF(LOCAL_SAVE_DIR) -TOKEN_DEF(RICH_SAVED_GAMES) -TOKEN_DEF(SAVED_GAME_EXT) -TOKEN_DEF(GUID) -TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(GAME) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(SYSTEM_FONT) - TOKEN_TABLE(VIDEO_FONT) - TOKEN_TABLE(EVENTS) - TOKEN_TABLE(CURSOR) - TOKEN_TABLE(ACTIVE_CURSOR) - TOKEN_TABLE(NONINTERACTIVE_CURSOR) - TOKEN_TABLE(PERSONAL_SAVEGAMES) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(SUBTITLES_SPEED) - TOKEN_TABLE(SUBTITLES) - TOKEN_TABLE(VIDEO_SUBTITLES) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(THUMBNAIL_WIDTH) - TOKEN_TABLE(THUMBNAIL_HEIGHT) - TOKEN_TABLE(INDICATOR_X) - TOKEN_TABLE(INDICATOR_Y) - TOKEN_TABLE(INDICATOR_WIDTH) - TOKEN_TABLE(INDICATOR_HEIGHT) - TOKEN_TABLE(INDICATOR_COLOR) - TOKEN_TABLE(SAVE_IMAGE_X) - TOKEN_TABLE(SAVE_IMAGE_Y) - TOKEN_TABLE(SAVE_IMAGE) - TOKEN_TABLE(LOAD_IMAGE_X) - TOKEN_TABLE(LOAD_IMAGE_Y) - TOKEN_TABLE(LOAD_IMAGE) - TOKEN_TABLE(LOCAL_SAVE_DIR) - TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) - TOKEN_TABLE_END - - // Declare a few variables necessary for moving data from these settings over to the renderer: - // The values are the same as the defaults set in BaseRenderer. - int loadImageX = 0; - int loadImageY = 0; - int saveImageX = 0; - int saveImageY = 0; - int indicatorX = -1; - int indicatorY = -1; - int indicatorWidth = -1; - int indicatorHeight = 8; - uint32 indicatorColor = BYTETORGBA(255, 0, 0, 128); - Common::String loadImageName = ""; - Common::String saveImageName = ""; - - byte *params; - int cmd; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { - _gameRef->LOG(0, "'GAME' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_SYSTEM_FONT: - if (_systemFont) { - _fontStorage->removeFont(_systemFont); - } - _systemFont = NULL; - - _systemFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - case TOKEN_VIDEO_FONT: - if (_videoFont) { - _fontStorage->removeFont(_videoFont); - } - _videoFont = NULL; - - _videoFont = _gameRef->_fontStorage->addFont((char *)params); - break; - - - case TOKEN_CURSOR: - delete _cursor; - _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { - delete _cursor; - _cursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_ACTIVE_CURSOR: - delete _activeCursor; - _activeCursor = NULL; - _activeCursor = new BaseSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { - delete _activeCursor; - _activeCursor = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NONINTERACTIVE_CURSOR: - delete _cursorNoninteractive; - _cursorNoninteractive = new BaseSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_PERSONAL_SAVEGAMES: - parser.scanStr((char *)params, "%b", &_personalizedSave); - break; - - case TOKEN_SUBTITLES: - parser.scanStr((char *)params, "%b", &_subtitles); - break; - - case TOKEN_SUBTITLES_SPEED: - parser.scanStr((char *)params, "%d", &_subtitlesSpeed); - break; - - case TOKEN_VIDEO_SUBTITLES: - parser.scanStr((char *)params, "%b", &_videoSubtitles); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - - case TOKEN_THUMBNAIL_WIDTH: - parser.scanStr((char *)params, "%d", &_thumbnailWidth); - break; - - case TOKEN_THUMBNAIL_HEIGHT: - parser.scanStr((char *)params, "%d", &_thumbnailHeight); - break; - - case TOKEN_INDICATOR_X: - parser.scanStr((char *)params, "%d", &indicatorX); - break; - - case TOKEN_INDICATOR_Y: - parser.scanStr((char *)params, "%d", &indicatorY); - break; - - case TOKEN_INDICATOR_COLOR: { - int r, g, b, a; - parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); - indicatorColor = BYTETORGBA(r, g, b, a); - } - break; - - case TOKEN_INDICATOR_WIDTH: - parser.scanStr((char *)params, "%d", &indicatorWidth); - break; - - case TOKEN_INDICATOR_HEIGHT: - parser.scanStr((char *)params, "%d", &indicatorHeight); - break; - - case TOKEN_SAVE_IMAGE: - saveImageName = (char *) params; - break; - - case TOKEN_SAVE_IMAGE_X: - parser.scanStr((char *)params, "%d", &saveImageX); - break; - - case TOKEN_SAVE_IMAGE_Y: - parser.scanStr((char *)params, "%d", &saveImageY); - break; - - case TOKEN_LOAD_IMAGE: - loadImageName = (char *) params; - break; - - case TOKEN_LOAD_IMAGE_X: - parser.scanStr((char *)params, "%d", &loadImageX); - break; - - case TOKEN_LOAD_IMAGE_Y: - parser.scanStr((char *)params, "%d", &loadImageY); - break; - - case TOKEN_LOCAL_SAVE_DIR: - BaseUtils::setString(&_localSaveDir, (char *)params); - break; - - case TOKEN_COMPAT_KILL_METHOD_THREADS: - parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); - break; - } - } - - _renderer->setIndicator(indicatorWidth, indicatorHeight, indicatorX, indicatorY, indicatorColor); - _renderer->initIndicator(); // In case we just reset the values. - _renderer->setSaveImage(saveImageName.c_str(), saveImageX, saveImageY); - _renderer->setLoadingScreen(loadImageName.c_str(), loadImageX, loadImageY); - - if (!_systemFont) { - _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); - } - - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in GAME definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading GAME definition"); - return STATUS_FAILED; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - LOG(0, stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - bool res = BaseObject::scCallMethod(script, stack, thisStack, name); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // Msg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Msg") == 0) { - stack->correctParams(1); - quickMessage(stack->pop()->getString()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RunScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RunScript") == 0) { - _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); - stack->correctParams(1); - if (DID_FAIL(addScript(stack->pop()->getString()))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadStringTable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadStringTable") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - ScValue *val = stack->pop(); - - bool clearOld; - if (val->isNULL()) { - clearOld = true; - } else { - clearOld = val->getBool(); - } - - if (DID_FAIL(_stringTable->loadFile(filename, clearOld))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ValidObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ValidObject") == 0) { - stack->correctParams(1); - BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *) obj)) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - resetContent(); - stack->pushNULL(); - - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // UnloadObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UnloadObject") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - BaseObject *obj = (BaseObject *)val->getNative(); - unregisterObject(obj); - if (val->getType() == VAL_VARIABLE_REF) { - val->setNULL(); - } - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadWindow") == 0) { - stack->correctParams(1); - UIWindow *win = new UIWindow(_gameRef); - if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { - _windows.add(win); - registerObject(win); - stack->pushNative(win, true); - } else { - delete win; - win = NULL; - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ExpandString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExpandString") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - char *str = new char[strlen(val->getString()) + 1]; - strcpy(str, val->getString()); - _stringTable->expand(&str); - stack->pushString(str); - delete[] str; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayMusic / PlayMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "PlayMusic") == 0) { - stack->correctParams(3); - } else { - stack->correctParams(4); - channel = stack->pop()->getInt(); - } - - const char *filename = stack->pop()->getString(); - ScValue *valLooping = stack->pop(); - bool looping = valLooping->isNULL() ? true : valLooping->getBool(); - - ScValue *valLoopStart = stack->pop(); - uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); - - - if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopMusic / StopMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "StopMusic") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(stopMusic(channel))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseMusic / PauseMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { - int channel = 0; - - if (strcmp(name, "PauseMusic") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(pauseMusic(channel))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeMusic / ResumeMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "ResumeMusic") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (DID_FAIL(resumeMusic(channel))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusic / GetMusicChannel - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { - int channel = 0; - if (strcmp(name, "GetMusic") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { - stack->pushNULL(); - } else { - if (!_music[channel] || !_music[channel]->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_music[channel]->getFilename()); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicPosition / SetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicPosition") == 0) { - stack->correctParams(1); - } else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - uint32 time = stack->pop()->getInt(); - - if (DID_FAIL(setMusicStartTime(channel, time))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicPosition / GetMusicChannelPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicPosition") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { - stack->pushInt(0); - } else { - stack->pushInt(_music[channel]->getPositionTime()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsMusicPlaying / IsMusicChannelPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { - int channel = 0; - if (strcmp(name, "IsMusicPlaying") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { - stack->pushBool(false); - } else { - stack->pushBool(_music[channel]->isPlaying()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMusicVolume / SetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "SetMusicVolume") == 0) { - stack->correctParams(1); - } else { - stack->correctParams(2); - channel = stack->pop()->getInt(); - } - - int volume = stack->pop()->getInt(); - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { - stack->pushBool(false); - } else { - if (DID_FAIL(_music[channel]->setVolumePercent(volume))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetMusicVolume / GetMusicChannelVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { - int channel = 0; - if (strcmp(name, "GetMusicVolume") == 0) { - stack->correctParams(0); - } else { - stack->correctParams(1); - channel = stack->pop()->getInt(); - } - - if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { - stack->pushInt(0); - } else { - stack->pushInt(_music[channel]->getVolumePercent()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicCrossfade - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicCrossfade") == 0) { - stack->correctParams(4); - int channel1 = stack->pop()->getInt(0); - int channel2 = stack->pop()->getInt(0); - uint32 fadeLength = (uint32)stack->pop()->getInt(0); - bool swap = stack->pop()->getBool(true); - - if (_musicCrossfadeRunning) { - script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); - stack->pushBool(false); - return STATUS_OK; - } - - _musicCrossfadeStartTime = _liveTimer; - _musicCrossfadeChannel1 = channel1; - _musicCrossfadeChannel2 = channel2; - _musicCrossfadeLength = fadeLength; - _musicCrossfadeSwap = swap; - - _musicCrossfadeRunning = true; - - stack->pushBool(true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundLength - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundLength") == 0) { - stack->correctParams(1); - - int length = 0; - const char *filename = stack->pop()->getString(); - - BaseSound *sound = new BaseSound(_gameRef); - if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - length = sound->getLength(); - delete sound; - sound = NULL; - } - stack->pushInt(length); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetMousePos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMousePos") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - x = MAX(x, 0); - x = MIN(x, _renderer->_width); - y = MAX(y, 0); - y = MIN(y, _renderer->_height); - Point32 p; - p.x = x + _renderer->_drawOffsetX; - p.y = y + _renderer->_drawOffsetY; - - BasePlatform::setCursorPos(p.x, p.y); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LockMouseRect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LockMouseRect") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - if (right < left) { - BaseUtils::swap(&left, &right); - } - if (bottom < top) { - BaseUtils::swap(&top, &bottom); - } - - BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayVideo - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayVideo") == 0) { - _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); - - stack->correctParams(6); - const char *filename = stack->pop()->getString(); - warning("PlayVideo: %s - not implemented yet", filename); - ScValue *valType = stack->pop(); - int type; - if (valType->isNULL()) { - type = (int)VID_PLAY_STRETCH; - } else { - type = valType->getInt(); - } - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool freezeMusic = stack->pop()->getBool(true); - - ScValue *valSub = stack->pop(); - const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { - type = (int)VID_PLAY_STRETCH; - } - - if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, subtitleFile))) { - if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)type, xVal, yVal, freezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else { - stack->pushBool(false); - } - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlayTheora - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlayTheora") == 0) { - stack->correctParams(7); - const char *filename = stack->pop()->getString(); - ScValue *valType = stack->pop(); - int type; - if (valType->isNULL()) { - type = (int)VID_PLAY_STRETCH; - } else { - type = valType->getInt(); - } - - int xVal = stack->pop()->getInt(); - int yVal = stack->pop()->getInt(); - bool freezeMusic = stack->pop()->getBool(true); - bool dropFrames = stack->pop()->getBool(true); - - ScValue *valSub = stack->pop(); - const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); - - if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { - type = (int)VID_PLAY_STRETCH; - } - - delete _theoraPlayer; - _theoraPlayer = new VideoTheoraPlayer(this); - if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, subtitleFile))) { - _theoraPlayer->_dontDropFrames = !dropFrames; - if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { - stack->pushBool(true); - script->sleep(0); - } else { - stack->pushBool(false); - } - } else { - stack->pushBool(false); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // QuitGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "QuitGame") == 0) { - stack->correctParams(0); - stack->pushNULL(); - _quitting = true; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int val = stack->pop()->getInt(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - ConfMan.setInt(privKey, val); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadNumber - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadNumber") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - int initVal = stack->pop()->getInt(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - int result = initVal; - if (ConfMan.hasKey(privKey)) { - result = ConfMan.getInt(privKey); - } - stack->pushInt(result); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegWriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegWriteString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *val = stack->pop()->getString(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - Common::String privVal = StringUtil::encodeSetting(val); - ConfMan.set(privKey, privVal); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RegReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RegReadString") == 0) { - stack->correctParams(2); - const char *key = stack->pop()->getString(); - const char *initVal = stack->pop()->getString(); - Common::String privKey = "priv_" + StringUtil::encodeSetting(key); - Common::String result = initVal; - if (ConfMan.hasKey(privKey)) { - result = StringUtil::decodeSetting(ConfMan.get(key)); - } - stack->pushString(result.c_str()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveGame") == 0) { - stack->correctParams(3); - int slot = stack->pop()->getInt(); - const char *xdesc = stack->pop()->getString(); - bool quick = stack->pop()->getBool(false); - - char *desc = new char[strlen(xdesc) + 1]; - strcpy(desc, xdesc); - stack->pushBool(true); - if (DID_FAIL(saveGame(slot, desc, quick))) { - stack->pop(); - stack->pushBool(false); - } - delete[] desc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadGame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadGame") == 0) { - stack->correctParams(1); - _scheduledLoadSlot = stack->pop()->getInt(); - _loading = true; - stack->pushBool(false); - script->sleep(0); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSaveSlotUsed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSaveSlotUsed") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - stack->pushBool(SaveLoad::isSaveSlotUsed(slot)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSaveSlotDescription - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSaveSlotDescription") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - char desc[512]; - desc[0] = '\0'; - SaveLoad::getSaveSlotDescription(slot, desc); - stack->pushString(desc); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmptySaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmptySaveSlot") == 0) { - stack->correctParams(1); - int slot = stack->pop()->getInt(); - SaveLoad::emptySaveSlot(slot); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSFXVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMusicVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetGlobalMasterVolume") == 0) { - stack->correctParams(1); - _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSFXVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalSpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMusicVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetGlobalMasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGlobalMasterVolume") == 0) { - stack->correctParams(0); - stack->pushInt(_soundMgr->getMasterVolumePercent()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetActiveCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursor") == 0) { - stack->correctParams(0); - if (!_activeCursor || !_activeCursor->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_activeCursor->getFilename()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetActiveCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetActiveCursorObject") == 0) { - stack->correctParams(0); - if (!_activeCursor) { - stack->pushNULL(); - } else { - stack->pushNative(_activeCursor, true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveActiveCursor") == 0) { - stack->correctParams(0); - delete _activeCursor; - _activeCursor = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasActiveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasActiveCursor") == 0) { - stack->correctParams(0); - - if (_activeCursor) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FileExists - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FileExists") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false - stack->pushBool(exists); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); - - _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) { - script->waitFor(_fader); - } - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { - stack->correctParams(5); - uint32 duration = stack->pop()->getInt(500); - byte red = stack->pop()->getInt(0); - byte green = stack->pop()->getInt(0); - byte blue = stack->pop()->getInt(0); - byte alpha = stack->pop()->getInt(0xFF); - - bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); - - _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); - if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) { - script->waitFor(_fader); - } - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFadeColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFadeColor") == 0) { - stack->correctParams(0); - stack->pushInt(_fader->getCurrentColor()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Screenshot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Screenshot") == 0) { - stack->correctParams(1); - char filename[MAX_PATH_LENGTH]; - - ScValue *val = stack->pop(); - - warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO - int fileNum = 0; - - while (true) { - sprintf(filename, "%s%03d.bmp", val->isNULL() ? getName() : val->getString(), fileNum); - if (!Common::File::exists(filename)) { - break; - } - fileNum++; - } - - bool ret = false; - BaseImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->saveBMPFile(filename)); - delete image; - } else { - ret = false; - } - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenshotEx - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenshotEx") == 0) { - stack->correctParams(3); - const char *filename = stack->pop()->getString(); - int sizeX = stack->pop()->getInt(_renderer->_width); - int sizeY = stack->pop()->getInt(_renderer->_height); - - bool ret = false; - BaseImage *image = _gameRef->_renderer->takeScreenshot(); - if (image) { - ret = DID_SUCCEED(image->resize(sizeX, sizeY)); - if (ret) { - ret = DID_SUCCEED(image->saveBMPFile(filename)); - } - delete image; - } else { - ret = false; - } - - stack->pushBool(ret); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CreateWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CreateWindow") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - UIWindow *win = new UIWindow(_gameRef); - _windows.add(win); - registerObject(win); - if (!val->isNULL()) { - win->setName(val->getString()); - } - stack->pushNative(win, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteWindow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteWindow") == 0) { - stack->correctParams(1); - BaseObject *obj = (BaseObject *)stack->pop()->getNative(); - for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i] == obj) { - unregisterObject(_windows[i]); - stack->pushBool(true); - return STATUS_OK; - } - } - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenDocument - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenDocument") == 0) { - stack->correctParams(0); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_DumpClassRegistry - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { - stack->correctParams(0); - DEBUG_DumpClassRegistry(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetLoadingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetLoadingScreen") == 0) { - stack->correctParams(3); - ScValue *val = stack->pop(); - int loadImageX = stack->pop()->getInt(); - int loadImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); - } else { - _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSavingScreen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSavingScreen") == 0) { - stack->correctParams(3); - ScValue *val = stack->pop(); - int saveImageX = stack->pop()->getInt(); - int saveImageY = stack->pop()->getInt(); - - if (val->isNULL()) { - _renderer->setSaveImage(NULL, saveImageX, saveImageY); - } else { - _renderer->setSaveImage(NULL, saveImageX, saveImageY); - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetWaitCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveWaitCursor") == 0) { - stack->correctParams(0); - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursor") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursorNoninteractive->getFilename()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetWaitCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWaitCursorObject") == 0) { - stack->correctParams(0); - if (!_cursorNoninteractive) { - stack->pushNULL(); - } else { - stack->pushNative(_cursorNoninteractive, true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ClearScriptCache - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ClearScriptCache") == 0) { - stack->correctParams(0); - stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisplayLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisplayLoadingIcon") == 0) { - stack->correctParams(4); - - const char *filename = stack->pop()->getString(); - _loadingIconX = stack->pop()->getInt(); - _loadingIconY = stack->pop()->getInt(); - _loadingIconPersistent = stack->pop()->getBool(); - - delete _loadingIcon; - _loadingIcon = new BaseSprite(this); - if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { - delete _loadingIcon; - _loadingIcon = NULL; - } else { - displayContent(false, true); - _gameRef->_renderer->flip(); - _gameRef->_renderer->initLoop(); - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideLoadingIcon - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideLoadingIcon") == 0) { - stack->correctParams(0); - delete _loadingIcon; - _loadingIcon = NULL; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DumpTextureStats - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DumpTextureStats") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - - _renderer->dumpData(filename); - - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccOutputText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccOutputText") == 0) { - stack->correctParams(2); - /* const char *str = */ stack->pop()->getString(); - /* int type = */ stack->pop()->getInt(); - // do nothing - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StoreSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StoreSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = new BaseSaveThumbHelper(this); - if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushBool(false); - } else { - stack->pushBool(true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteSaveThumbnail - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteSaveThumbnail") == 0) { - stack->correctParams(0); - delete _cachedThumbnail; - _cachedThumbnail = NULL; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFileChecksum - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFileChecksum") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool asHex = stack->pop()->getBool(false); - - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false); - if (file) { - crc remainder = crc_initialize(); - byte buf[1024]; - int bytesRead = 0; - - while (bytesRead < file->size()) { - int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); - bytesRead += file->read(buf, bufSize); - - for (int i = 0; i < bufSize; i++) { - remainder = crc_process_byte(buf[i], remainder); - } - } - crc checksum = crc_finalize(remainder); - - if (asHex) { - char hex[100]; - sprintf(hex, "%x", checksum); - stack->pushString(hex); - } else { - stack->pushInt(checksum); - } - - BaseFileManager::getEngineInstance()->closeFile(file); - file = NULL; - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EnableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EnableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->enableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DisableScriptProfiling - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DisableScriptProfiling") == 0) { - stack->correctParams(0); - _scEngine->disableProfiling(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ShowStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ShowStatusLine") == 0) { - stack->correctParams(0); - // Block kept to show intention of opcode. - /*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(TRUE); - #endif*/ - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HideStatusLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HideStatusLine") == 0) { - stack->correctParams(0); - // Block kept to show intention of opcode. - /*#ifdef __IPHONEOS__ - IOS_ShowStatusLine(FALSE); - #endif*/ - stack->pushNULL(); - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseGame::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("game"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(getName()); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Hwnd (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { - _scValue->setInt((int)_renderer->_window); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { - _scValue->setInt((int)_timer); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowsTime (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { - _scValue->setInt((int)g_system->getMillis()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // WindowedMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { - _scValue->setBool(_renderer->_windowed); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _scValue->setInt(_mousePos.x); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _scValue->setInt(_mousePos.y); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - _scValue->setNative(_mainObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ActiveObject (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { - _scValue->setNative(_activeObject, true); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenWidth (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { - _scValue->setInt(_renderer->_width); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScreenHeight (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { - _scValue->setInt(_renderer->_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - _scValue->setBool(_interactive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DebugMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { - _scValue->setBool(_debugDebugMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundAvailable (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { - _scValue->setBool(_soundMgr->_soundAvailable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _scValue->setInt(_soundMgr->getMasterVolumePercent()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Keyboard (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { - if (_keyboardState) { - _scValue->setNative(_keyboardState, true); - } else { - _scValue->setNULL(); - } - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _scValue->setBool(_subtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _scValue->setInt(_subtitlesSpeed); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _scValue->setBool(_videoSubtitles); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FPS (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { - _scValue->setInt(_fps); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AcceleratedMode / Accelerated (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { - _scValue->setBool(_useD3D); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - _scValue->setInt(_textEncoding); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _scValue->setBool(_textRTL); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _scValue->setInt(_soundBufferSizeSec); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _scValue->setBool(_suspendedRendering); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _scValue->setBool(_suppressScriptErrors); - return _scValue; - } - - - ////////////////////////////////////////////////////////////////////////// - // Frozen - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { - _scValue->setBool(_state == GAME_FROZEN); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSTalk - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSCaptions - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccTTSKeypress - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardEnabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardCursorSkip - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccKeyboardPause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { - _scValue->setBool(false); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _scValue->setBool(_autorunDisabled); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveDirectory (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { - AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. - _scValue->setString(dataDir.c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _scValue->setBool(_autoSaveOnExit); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _scValue->setInt(_autoSaveSlot); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _scValue->setBool(_cursorHidden); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Platform (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { - _scValue->setString(BasePlatform::getPlatformName().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // DeviceType (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { - _scValue->setString(getDeviceType().c_str()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MostRecentSaveSlot (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { - if (!ConfMan.hasKey("most_recent_saveslot")) { - _scValue->setInt(-1); - } else { - _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Store (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { - _scValue->setNULL(); - error("Request for a SXStore-object, which is not supported by ScummVM"); - - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { - _mousePos.x = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MouseY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { - _mousePos.y = value->getInt(); - resetMousePos(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - bool res = BaseObject::scSetProperty(name, value); - setWindowTitle(); - return res; - } - - ////////////////////////////////////////////////////////////////////////// - // MainObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { - BaseScriptable *obj = value->getNative(); - if (obj == NULL || validObject((BaseObject *)obj)) { - _mainObject = (BaseObject *)obj; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { - setInteractive(value->getBool()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SFXVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SpeechVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { - _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MusicVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); - _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MasterVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { - _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); - _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Subtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { - _subtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SubtitlesSpeed - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { - _subtitlesSpeed = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // VideoSubtitles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { - _videoSubtitles = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextEncoding - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { - int enc = value->getInt(); - if (enc < 0) { - enc = 0; - } - if (enc >= NUM_TEXT_ENCODINGS) { - enc = NUM_TEXT_ENCODINGS - 1; - } - _textEncoding = (TTextEncoding)enc; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // TextRTL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { - _textRTL = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundBufferSize - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { - _soundBufferSizeSec = value->getInt(); - _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuspendedRendering - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { - _suspendedRendering = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SuppressScriptErrors - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { - _suppressScriptErrors = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutorunDisabled - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { - _autorunDisabled = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveOnExit - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { - _autoSaveOnExit = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AutoSaveSlot - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { - _autoSaveSlot = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CursorHidden - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { - _cursorHidden = value->getBool(); - return STATUS_OK; - } else { - return BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseGame::scToString() { - return "[game object]"; -} - - - -#define QUICK_MSG_DURATION 3000 -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayQuickMsg() { - if (_quickMessages.size() == 0 || !_systemFont) { - return STATUS_OK; - } - - // update - for (uint32 i = 0; i < _quickMessages.size(); i++) { - if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { - delete _quickMessages[i]; - _quickMessages.remove_at(i); - i--; - } - } - - int posY = 20; - - // display - for (uint32 i = 0; i < _quickMessages.size(); i++) { - _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); - posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); - } - return STATUS_OK; -} - - -#define MAX_QUICK_MSG 5 -////////////////////////////////////////////////////////////////////////// -void BaseGame::quickMessage(const char *text) { - if (_quickMessages.size() >= MAX_QUICK_MSG) { - delete _quickMessages[0]; - _quickMessages.remove_at(0); - } - _quickMessages.add(new BaseQuickMsg(_gameRef, text)); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::quickMessageForm(char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - quickMessage(buff); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::registerObject(BaseObject *object) { - _regObjects.add(object); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::unregisterObject(BaseObject *object) { - if (!object) { - return STATUS_OK; - } - - // is it a window? - for (uint32 i = 0; i < _windows.size(); i++) { - if ((BaseObject *)_windows[i] == object) { - _windows.remove_at(i); - - // get new focused window - if (_focusedWindow == object) { - _focusedWindow = NULL; - } - - break; - } - } - - // is it active object? - if (_activeObject == object) { - _activeObject = NULL; - } - - // is it main object? - if (_mainObject == object) { - _mainObject = NULL; - } - - // destroy object - for (uint32 i = 0; i < _regObjects.size(); i++) { - if (_regObjects[i] == object) { - _regObjects.remove_at(i); - if (!_loadInProgress) { - SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); - } - delete object; - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::invalidateValues(void *value, void *data) { - ScValue *val = (ScValue *)value; - if (val->isNative() && val->getNative() == data) { - if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { - ((BaseScriptable *)data)->_refCount++; - } - val->setNative(NULL); - val->setNULL(); - } -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::validObject(BaseObject *object) { - if (!object) { - return false; - } - if (object == this) { - return true; - } - - for (uint32 i = 0; i < _regObjects.size(); i++) { - if (_regObjects[i] == object) { - return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { - ScValue *thisObj; - - ////////////////////////////////////////////////////////////////////////// - // LOG - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "LOG") == 0) { - stack->correctParams(1); - _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // String - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "String") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXString(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MemBuffer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MemBuffer") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // File - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "File") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXFile(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Date - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Date") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXDate(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Array - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Array") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXArray(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Object - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Object") == 0) { - thisObj = thisStack->getTop(); - - thisObj->setNative(makeSXObject(_gameRef, stack)); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Sleep - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sleep") == 0) { - stack->correctParams(1); - - script->sleep((uint32)stack->pop()->getInt()); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // WaitFor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WaitFor") == 0) { - stack->correctParams(1); - - BaseScriptable *obj = stack->pop()->getNative(); - if (validObject((BaseObject *)obj)) { - script->waitForExclusive((BaseObject *)obj); - } - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // Random - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Random") == 0) { - stack->correctParams(2); - - int from = stack->pop()->getInt(); - int to = stack->pop()->getInt(); - - stack->pushInt(BaseUtils::randomInt(from, to)); - } - - ////////////////////////////////////////////////////////////////////////// - // SetScriptTimeSlice - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetScriptTimeSlice") == 0) { - stack->correctParams(1); - - script->_timeSlice = (uint32)stack->pop()->getInt(); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeRGBA / MakeRGB / RGB - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { - stack->correctParams(4); - int r = stack->pop()->getInt(); - int g = stack->pop()->getInt(); - int b = stack->pop()->getInt(); - int a; - ScValue *val = stack->pop(); - if (val->isNULL()) { - a = 255; - } else { - a = val->getInt(); - } - - stack->pushInt(BYTETORGBA(r, g, b, a)); - } - - ////////////////////////////////////////////////////////////////////////// - // MakeHSL - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MakeHSL") == 0) { - stack->correctParams(3); - int h = stack->pop()->getInt(); - int s = stack->pop()->getInt(); - int l = stack->pop()->getInt(); - - stack->pushInt(BaseUtils::HSLtoRGB(h, s, l)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetRValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetRValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetR(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetGValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetGValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetG(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetBValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetB(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetAValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetAValue") == 0) { - stack->correctParams(1); - - uint32 rgba = (uint32)stack->pop()->getInt(); - stack->pushInt(RGBCOLGetA(rgba)); - } - - ////////////////////////////////////////////////////////////////////////// - // GetHValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - BaseUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(H); - } - - ////////////////////////////////////////////////////////////////////////// - // GetSValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - BaseUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(S); - } - - ////////////////////////////////////////////////////////////////////////// - // GetLValue - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetLValue") == 0) { - stack->correctParams(1); - uint32 rgb = (uint32)stack->pop()->getInt(); - - byte H, S, L; - BaseUtils::RGBtoHSL(rgb, &H, &S, &L); - stack->pushInt(L); - } - - ////////////////////////////////////////////////////////////////////////// - // Debug - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Debug") == 0) { - stack->correctParams(0); - stack->pushNULL(); - } - - ////////////////////////////////////////////////////////////////////////// - // ToString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToString") == 0) { - stack->correctParams(1); - const char *str = stack->pop()->getString(); - char *str2 = new char[strlen(str) + 1]; - strcpy(str2, str); - stack->pushString(str2); - delete[] str2; - } - - ////////////////////////////////////////////////////////////////////////// - // ToInt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToInt") == 0) { - stack->correctParams(1); - int val = stack->pop()->getInt(); - stack->pushInt(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToFloat") == 0) { - stack->correctParams(1); - double val = stack->pop()->getFloat(); - stack->pushFloat(val); - } - - ////////////////////////////////////////////////////////////////////////// - // ToBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - stack->pushBool(val); - } - - ////////////////////////////////////////////////////////////////////////// - // failure - else { - script->runtimeError("Call to undefined function '%s'. Ignored.", name); - stack->correctParams(0); - stack->pushNULL(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::showCursor() { - if (_cursorHidden) { - return STATUS_OK; - } - - if (!_interactive && _gameRef->_state == GAME_RUNNING) { - if (_cursorNoninteractive) { - return drawCursor(_cursorNoninteractive); - } - } else { - if (_activeObject && !DID_FAIL(_activeObject->showCursor())) { - return STATUS_OK; - } else { - if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) { - return drawCursor(_activeCursor); - } else if (_cursor) { - return drawCursor(_cursor); - } - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { - return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadGame(int slot) { - //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); - - _loading = false; - _scheduledLoadSlot = -1; - - Common::String filename = SaveLoad::getSaveSlotFilename(slot); - - return loadGame(filename.c_str()); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadGame(const char *filename) { - return SaveLoad::loadGame(filename, _gameRef); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayWindows(bool inGame) { - bool res; - - // did we lose focus? focus topmost window - if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { - _focusedWindow = NULL; - for (int i = _windows.size() - 1; i >= 0; i--) { - if (_windows[i]->_visible && !_windows[i]->_disable) { - _focusedWindow = _windows[i]; - break; - } - } - } - - // display all windows - for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { - - res = _windows[i]->display(); - if (DID_FAIL(res)) { - return res; - } - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - delete _music[channel]; - _music[channel] = NULL; - - _music[channel] = new BaseSound(_gameRef); - if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { - if (_musicStartTime[channel]) { - _music[channel]->setPositionTime(_musicStartTime[channel]); - _musicStartTime[channel] = 0; - } - if (loopStart) { - _music[channel]->setLoopStart(loopStart); - } - return _music[channel]->play(looping); - } else { - delete _music[channel]; - _music[channel] = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::stopMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - _music[channel]->stop(); - delete _music[channel]; - _music[channel] = NULL; - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::pauseMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - return _music[channel]->pause(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::resumeMusic(int channel) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - if (_music[channel]) { - return _music[channel]->resume(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::setMusicStartTime(int channel, uint32 time) { - if (channel >= NUM_MUSIC_CHANNELS) { - _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); - return STATUS_FAILED; - } - - _musicStartTime[channel] = time; - if (_music[channel] && _music[channel]->isPlaying()) { - return _music[channel]->setPositionTime(time); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::loadSettings(const char *filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(SETTINGS) - TOKEN_TABLE(GAME) - TOKEN_TABLE(STRING_TABLE) - TOKEN_TABLE(RESOLUTION) - TOKEN_TABLE(REQUIRE_3D_ACCELERATION) - TOKEN_TABLE(REQUIRE_SOUND) - TOKEN_TABLE(HWTL_MODE) - TOKEN_TABLE(ALLOW_WINDOWED_MODE) - TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) - TOKEN_TABLE(ALLOW_ABOUT_TAB) - TOKEN_TABLE(ALLOW_ADVANCED) - TOKEN_TABLE(ALLOW_DESKTOP_RES) - TOKEN_TABLE(REGISTRY_PATH) - TOKEN_TABLE(RICH_SAVED_GAMES) - TOKEN_TABLE(SAVED_GAME_EXT) - TOKEN_TABLE(GUID) - TOKEN_TABLE_END - - - byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (origBuffer == NULL) { - _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret = STATUS_OK; - - byte *buffer = origBuffer; - byte *params; - int cmd; - BaseParser parser; - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { - _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); - return STATUS_FAILED; - } - buffer = params; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_GAME: - delete[] _settingsGameFile; - _settingsGameFile = new char[strlen((char *)params) + 1]; - if (_settingsGameFile) { - strcpy(_settingsGameFile, (char *)params); - } - break; - - case TOKEN_STRING_TABLE: - if (DID_FAIL(_stringTable->loadFile((char *)params))) { - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_RESOLUTION: - parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); - break; - - case TOKEN_REQUIRE_3D_ACCELERATION: - parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); - break; - - case TOKEN_REQUIRE_SOUND: - parser.scanStr((char *)params, "%b", &_settingsRequireSound); - break; - - case TOKEN_HWTL_MODE: - parser.scanStr((char *)params, "%d", &_settingsTLMode); - break; - - case TOKEN_ALLOW_WINDOWED_MODE: - parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); - break; - - case TOKEN_ALLOW_DESKTOP_RES: - parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); - break; - - case TOKEN_ALLOW_ADVANCED: - parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); - break; - - case TOKEN_ALLOW_ACCESSIBILITY_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); - break; - - case TOKEN_ALLOW_ABOUT_TAB: - parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); - break; - - case TOKEN_REGISTRY_PATH: - //BaseEngine::instance().getRegistry()->setBasePath((char *)params); - break; - - case TOKEN_RICH_SAVED_GAMES: - parser.scanStr((char *)params, "%b", &_richSavedGames); - break; - - case TOKEN_SAVED_GAME_EXT: - BaseUtils::setString(&_savedGameExt, (char *)params); - break; - - case TOKEN_GUID: - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); - ret = STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC) { - _gameRef->LOG(0, "Error loading game settings '%s'", filename); - ret = STATUS_FAILED; - } - - _settingsAllowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. - _compressedSavegames = true; - - delete[] origBuffer; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) { - cleanup(); - } - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_activeObject)); - persistMgr->transfer(TMEMBER(_capturedObject)); - persistMgr->transfer(TMEMBER(_cursorNoninteractive)); - persistMgr->transfer(TMEMBER(_editorMode)); - persistMgr->transfer(TMEMBER(_fader)); - persistMgr->transfer(TMEMBER(_freezeLevel)); - persistMgr->transfer(TMEMBER(_focusedWindow)); - persistMgr->transfer(TMEMBER(_fontStorage)); - persistMgr->transfer(TMEMBER(_interactive)); - persistMgr->transfer(TMEMBER(_keyboardState)); - persistMgr->transfer(TMEMBER(_lastTime)); - persistMgr->transfer(TMEMBER(_mainObject)); - for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { - persistMgr->transfer(TMEMBER(_music[i])); - persistMgr->transfer(TMEMBER(_musicStartTime[i])); - } - - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_offsetPercentX)); - persistMgr->transfer(TMEMBER(_offsetPercentY)); - - persistMgr->transfer(TMEMBER(_origInteractive)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_personalizedSave)); - persistMgr->transfer(TMEMBER(_quitting)); - - _regObjects.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_scEngine)); - //persistMgr->transfer(TMEMBER(_soundMgr)); - persistMgr->transfer(TMEMBER_INT(_state)); - //persistMgr->transfer(TMEMBER(_surfaceStorage)); - persistMgr->transfer(TMEMBER(_subtitles)); - persistMgr->transfer(TMEMBER(_subtitlesSpeed)); - persistMgr->transfer(TMEMBER(_systemFont)); - persistMgr->transfer(TMEMBER(_videoFont)); - persistMgr->transfer(TMEMBER(_videoSubtitles)); - - persistMgr->transfer(TMEMBER(_timer)); - persistMgr->transfer(TMEMBER(_timerDelta)); - persistMgr->transfer(TMEMBER(_timerLast)); - - persistMgr->transfer(TMEMBER(_liveTimer)); - persistMgr->transfer(TMEMBER(_liveTimerDelta)); - persistMgr->transfer(TMEMBER(_liveTimerLast)); - - persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); - persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); - persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); - persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); - persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - - _renderer->persistSaveLoadImages(persistMgr); - - persistMgr->transfer(TMEMBER_INT(_textEncoding)); - persistMgr->transfer(TMEMBER(_textRTL)); - - persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); - persistMgr->transfer(TMEMBER(_suspendedRendering)); - - persistMgr->transfer(TMEMBER(_mouseLockRect)); - - _windows.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_suppressScriptErrors)); - persistMgr->transfer(TMEMBER(_autorunDisabled)); - - persistMgr->transfer(TMEMBER(_autoSaveOnExit)); - persistMgr->transfer(TMEMBER(_autoSaveSlot)); - persistMgr->transfer(TMEMBER(_cursorHidden)); - - if (!persistMgr->getIsSaving()) { - _quitting = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::focusWindow(UIWindow *window) { - UIWindow *prev = _focusedWindow; - - for (uint32 i = 0; i < _windows.size(); i++) { - if (_windows[i] == window) { - if (i < _windows.size() - 1) { - _windows.remove_at(i); - _windows.add(window); - - _gameRef->_focusedWindow = window; - } - - if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) { - return focusWindow(prev); - } else { - return STATUS_OK; - } - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::freeze(bool includingMusic) { - if (_freezeLevel == 0) { - _scEngine->pauseAll(); - _soundMgr->pauseAll(includingMusic); - _origState = _state; - _origInteractive = _interactive; - _interactive = true; - } - _state = GAME_FROZEN; - _freezeLevel++; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::unfreeze() { - if (_freezeLevel == 0) { - return STATUS_OK; - } - - _freezeLevel--; - if (_freezeLevel == 0) { - _state = _origState; - _interactive = _origInteractive; - _scEngine->resumeAll(); - _soundMgr->resumeAll(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::handleKeypress(Common::Event *event, bool printable) { - if (isVideoPlaying()) { - if (event->kbd.keycode == Common::KEYCODE_ESCAPE) { - stopVideo(); - } - return true; - } - - if (event->type == Common::EVENT_QUIT) { - onWindowClose(); - return true; - } - - _keyboardState->handleKeyPress(event); - _keyboardState->readKey(event); -// TODO - - if (_focusedWindow) { - if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { - /*if (event->type != SDL_TEXTINPUT) {*/ - if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) { - _gameRef->_focusedWindow->applyEvent("Keypress"); - } else { - applyEvent("Keypress"); - } - /*}*/ - } - return true; - } else { /*if (event->type != SDL_TEXTINPUT)*/ - applyEvent("Keypress"); - return true; - } - - return false; -} - -void BaseGame::handleKeyRelease(Common::Event *event) { - _keyboardState->handleKeyRelease(event); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::handleMouseWheel(int delta) { - bool handled = false; - if (_focusedWindow) { - handled = _gameRef->_focusedWindow->handleMouseWheel(delta); - - if (!handled) { - if (delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); - handled = true; - } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { - _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); - handled = true; - } - - } - } - - if (!handled) { - if (delta < 0) { - applyEvent("MouseWheelDown"); - } else { - applyEvent("MouseWheelUp"); - } - } - - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { - if (verMajor) { - *verMajor = DCGF_VER_MAJOR; - } - if (verMinor) { - *verMinor = DCGF_VER_MINOR; - } - - if (extMajor) { - *extMajor = 0; - } - if (extMinor) { - *extMinor = 0; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setWindowTitle() { - if (_renderer) { - char title[512]; - strcpy(title, _caption[0]); - if (title[0] != '\0') { - strcat(title, " - "); - } - strcat(title, "WME Lite"); - - - Utf8String utf8Title; - if (_textEncoding == TEXT_UTF8) { - utf8Title = Utf8String(title); - } else { - warning("BaseGame::SetWindowTitle - Ignoring textencoding"); - utf8Title = Utf8String(title); - /* WideString wstr = StringUtil::AnsiToWide(Title); - title = StringUtil::WideToUtf8(wstr);*/ - } - warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::setActiveObject(BaseObject *obj) { - // not-active when game is frozen - if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { - obj = NULL; - } - - if (obj == _activeObject) { - return STATUS_OK; - } - - if (_activeObject) { - _activeObject->applyEvent("MouseLeave"); - } - //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); - _activeObject = obj; - if (_activeObject) { - _activeObject->applyEvent("MouseEntry"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::pushViewport(BaseViewport *viewport) { - _viewportSP++; - if (_viewportSP >= (int32)_viewportStack.size()) { - _viewportStack.add(viewport); - } else { - _viewportStack[_viewportSP] = viewport; - } - - _renderer->setViewport(viewport->getRect()); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::popViewport() { - _viewportSP--; - if (_viewportSP < -1) { - _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); - } - - if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { - _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); - } else _renderer->setViewport(_renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { - if (rect == NULL) { - return STATUS_FAILED; - } else { - if (_viewportSP >= 0) { - BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); - if (custom) { - *custom = true; - } - } else { - BasePlatform::setRect(rect, _renderer->_drawOffsetX, - _renderer->_drawOffsetY, - _renderer->_width + _renderer->_drawOffsetX, - _renderer->_height + _renderer->_drawOffsetY); - if (custom) { - *custom = false; - } - } - - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { - if (_viewportSP >= 0) { - if (offsetX) { - *offsetX = _viewportStack[_viewportSP]->_offsetX; - } - if (offsetY) { - *offsetY = _viewportStack[_viewportSP]->_offsetY; - } - } else { - if (offsetX) { - *offsetX = 0; - } - if (offsetY) { - *offsetY = 0; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::setInteractive(bool state) { - _interactive = state; - if (_transMgr) { - _transMgr->_origInteractive = state; - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseGame::resetMousePos() { - Common::Point p; - p.x = _mousePos.x + _renderer->_drawOffsetX; - p.y = _mousePos.y + _renderer->_drawOffsetY; - - BasePlatform::setCursorPos(p.x, p.y); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayContent(bool doUpdate, bool displayAll) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayContentSimple() { - // fill black - _renderer->fill(0, 0, 0); - _renderer->displayIndicator(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::updateMusicCrossfade() { - /* byte globMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ - - if (!_musicCrossfadeRunning) { - return STATUS_OK; - } - if (_state == GAME_FROZEN) { - return STATUS_OK; - } - - if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { - _musicCrossfadeRunning = false; - return STATUS_OK; - } - - if (!_music[_musicCrossfadeChannel1]->isPlaying()) { - _music[_musicCrossfadeChannel1]->play(); - } - if (!_music[_musicCrossfadeChannel2]->isPlaying()) { - _music[_musicCrossfadeChannel2]->play(); - } - - uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; - - if (currentTime >= _musicCrossfadeLength) { - _musicCrossfadeRunning = false; - //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel2]->setVolumePercent(100); - - _music[_musicCrossfadeChannel1]->stop(); - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent(100); - - - if (_musicCrossfadeSwap) { - // swap channels - BaseSound *dummy = _music[_musicCrossfadeChannel1]; - int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; - - _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; - _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; - - _music[_musicCrossfadeChannel2] = dummy; - _musicStartTime[_musicCrossfadeChannel2] = dummyInt; - } - } else { - //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); - _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); - - //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::resetContent() { - _scEngine->clearGlobals(); - //_timer = 0; - //_liveTimer = 0; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::DEBUG_DumpClassRegistry() { - warning("DEBUG_DumpClassRegistry - untested"); - Common::DumpFile *f = new Common::DumpFile; - f->open("zz_class_reg_dump.log"); - - SystemClassRegistry::getInstance()->dumpClasses(f); - - f->close(); - delete f; - _gameRef->quickMessage("Classes dump completed."); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::invalidateDeviceObjects() { - for (uint32 i = 0; i < _regObjects.size(); i++) { - _regObjects[i]->invalidateDeviceObjects(); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::restoreDeviceObjects() { - for (uint32 i = 0; i < _regObjects.size(); i++) { - _regObjects[i]->restoreDeviceObjects(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::setWaitCursor(const char *filename) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - - _cursorNoninteractive = new BaseSprite(_gameRef); - if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { - delete _cursorNoninteractive; - _cursorNoninteractive = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isVideoPlaying() { - if (_videoPlayer->isPlaying()) { - return true; - } - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - return true; - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::stopVideo() { - if (_videoPlayer->isPlaying()) { - _videoPlayer->stop(); - } - if (_theoraPlayer && _theoraPlayer->isPlaying()) { - _theoraPlayer->stop(); - delete _theoraPlayer; - _theoraPlayer = NULL; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::drawCursor(BaseSprite *cursor) { - if (!cursor) { - return STATUS_FAILED; - } - if (cursor != _lastCursor) { - cursor->reset(); - _lastCursor = cursor; - } - return cursor->draw(_mousePos.x, _mousePos.y); -} - - -////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onActivate(bool activate, bool refreshMouse) { - if (_shuttingDown || !_renderer) { - return STATUS_OK; - } - - _renderer->_active = activate; - - if (refreshMouse) { - Point32 p; - getMousePos(&p); - setActiveObject(_renderer->getObjectAt(p.x, p.y)); - } - - if (activate) { - _soundMgr->resumeAll(); - } else { - _soundMgr->pauseAll(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseLeftDown() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftClick"); - } - } - - if (_activeObject != NULL) { - _capturedObject = _activeObject; - } - _mouseLeftDown = true; - BasePlatform::setCapture(/*_renderer->_window*/); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseLeftUp() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); - } - - BasePlatform::releaseCapture(); - _capturedObject = NULL; - _mouseLeftDown = false; - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseLeftDblClick() { - if (_state == GAME_RUNNING && !_interactive) { - return STATUS_OK; - } - - if (_activeObject) { - _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("LeftDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseRightDblClick() { - if (_state == GAME_RUNNING && !_interactive) { - return STATUS_OK; - } - - if (_activeObject) { - _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightDoubleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseRightDown() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseRightUp() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("RightRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseMiddleDown() { - if (_state == GAME_RUNNING && !_interactive) { - return STATUS_OK; - } - - if (_activeObject) { - _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleClick"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onMouseMiddleUp() { - if (_activeObject) { - _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); - } - - bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); - if (!handled) { - if (_activeObject != NULL) { - _activeObject->applyEvent("MiddleRelease"); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onPaint() { - if (_renderer && _renderer->_windowed && _renderer->_ready) { - _renderer->initLoop(); - displayContent(false, true); - displayDebugInfo(); - _renderer->windowedBlt(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onWindowClose() { - if (canHandleEvent("QuitGame")) { - if (_state != GAME_FROZEN) { - _gameRef->applyEvent("QuitGame"); - } - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::displayDebugInfo() { - char str[100]; - - if (_debugShowFPS) { - sprintf(str, "FPS: %d", _gameRef->_fps); - _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); - } - - if (_gameRef->_debugDebugMode) { - if (!_gameRef->_renderer->_windowed) { - sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); - } else { - sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); - } - - strcat(str, " ("); - strcat(str, _renderer->getName().c_str()); - strcat(str, ")"); - _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); - - _renderer->displayDebugInfo(); - - int scrTotal, scrRunning, scrWaiting, scrPersistent; - scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); - sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); - _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); - - - sprintf(str, "Timer: %d", _timer); - _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); - - if (_activeObject != NULL) { - _systemFont->drawText((const byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); - } - - sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); - _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); - - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::getMousePos(Point32 *pos) { - BasePlatform::getCursorPos(pos); - - pos->x -= _renderer->_drawOffsetX; - pos->y -= _renderer->_drawOffsetY; - - /* - // Windows can squish maximized window if it's larger than desktop - // so we need to modify mouse position appropriately (tnx mRax) - if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { - Common::Rect rc; - ::GetClientRect(_renderer->_window, &rc); - Pos->x *= _gameRef->_renderer->_realWidth; - Pos->x /= (rc.right - rc.left); - Pos->y *= _gameRef->_renderer->_realHeight; - Pos->y /= (rc.bottom - rc.top); - } - */ - - if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { - if (!BasePlatform::ptInRect(&_mouseLockRect, *pos)) { - pos->x = MAX(_mouseLockRect.left, pos->x); - pos->y = MAX(_mouseLockRect.top, pos->y); - - pos->x = MIN(_mouseLockRect.right, pos->x); - pos->y = MIN(_mouseLockRect.bottom, pos->y); - - Point32 newPos = *pos; - - newPos.x += _renderer->_drawOffsetX; - newPos.y += _renderer->_drawOffsetY; - - BasePlatform::setCursorPos(newPos.x, newPos.y); - } - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. - if (!_miniUpdateEnabled) { - return; - } - - if (g_system->getMillis() - _lastMiniUpdate > 200) { - _lastMiniUpdate = g_system->getMillis(); - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::onScriptShutdown(ScScript *script) { - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isLeftDoubleClick() { - return isDoubleClick(0); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isRightDoubleClick() { - return isDoubleClick(1); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseGame::isDoubleClick(int buttonIndex) { - uint32 maxDoubleCLickTime = 500; - int maxMoveX = 4; - int maxMoveY = 4; - - Point32 pos; - BasePlatform::getCursorPos(&pos); - - int moveX = abs(pos.x - _lastClick[buttonIndex].posX); - int moveY = abs(pos.y - _lastClick[buttonIndex].posY); - - - if (_lastClick[buttonIndex].time == 0 || g_system->getMillis() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { - _lastClick[buttonIndex].time = g_system->getMillis(); - _lastClick[buttonIndex].posX = pos.x; - _lastClick[buttonIndex].posY = pos.y; - return false; - } else { - _lastClick[buttonIndex].time = 0; - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::autoSaveOnExit() { - _soundMgr->saveSettings(); - ConfMan.flushToDisk(); - - if (!_autoSaveOnExit) { - return; - } - if (_state == GAME_FROZEN) { - return; - } - - saveGame(_autoSaveSlot, "autosave", true); -} - -////////////////////////////////////////////////////////////////////////// -void BaseGame::addMem(int bytes) { - _usedMem += bytes; -} - -////////////////////////////////////////////////////////////////////////// -AnsiString BaseGame::getDeviceType() const { - return "computer"; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_fader.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/saveload.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/video/video_player.h" +#include "engines/wintermute/video/video_theora_player.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/utils/crc.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/ui/ui_window.h" +#include "engines/wintermute/wintermute.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/config-manager.h" +#include "common/savefile.h" +#include "common/textconsole.h" +#include "common/util.h" +#include "common/keyboard.h" +#include "common/system.h" +#include "common/file.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseGame, true) + + +////////////////////////////////////////////////////////////////////// +BaseGame::BaseGame(const Common::String &gameId) : BaseObject(this), _gameId(gameId) { + _shuttingDown = false; + + _state = GAME_RUNNING; + _origState = GAME_RUNNING; + _freezeLevel = 0; + + _interactive = true; + _origInteractive = false; + + _surfaceStorage = NULL; + _fontStorage = NULL; + _renderer = NULL; + _soundMgr = NULL; + _transMgr = NULL; + _scEngine = NULL; + _keyboardState = NULL; + + _mathClass = NULL; + + _debugLogFile = NULL; + _debugDebugMode = false; + _debugShowFPS = false; + + _systemFont = NULL; + _videoFont = NULL; + + _videoPlayer = NULL; + _theoraPlayer = NULL; + + _mainObject = NULL; + _activeObject = NULL; + + _fader = NULL; + + _offsetX = _offsetY = 0; + _offsetPercentX = _offsetPercentY = 0.0f; + + _subtitles = true; + _videoSubtitles = true; + + _timer = 0; + _timerDelta = 0; + _timerLast = 0; + + _liveTimer = 0; + _liveTimerDelta = 0; + _liveTimerLast = 0; + + _sequence = 0; + + _mousePos.x = _mousePos.y = 0; + _mouseLeftDown = _mouseRightDown = _mouseMidlleDown = false; + _capturedObject = NULL; + + // FPS counters + _lastTime = _fpsTime = _deltaTime = _framesRendered = _fps = 0; + + _cursorNoninteractive = NULL; + + _useD3D = false; + + _stringTable = new BaseStringTable(this); + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + _settingsResWidth = 800; + _settingsResHeight = 600; + _settingsRequireAcceleration = false; + _settingsRequireSound = false; + _settingsTLMode = 0; + _settingsAllowWindowed = true; + _settingsGameFile = NULL; + _settingsAllowAdvanced = false; + _settingsAllowAccessTab = true; + _settingsAllowAboutTab = true; + _settingsAllowDesktopRes = false; + + _editorForceScripts = false; + _editorAlwaysRegister = false; + + _focusedWindow = NULL; + + _loadInProgress = false; + + _quitting = false; + _loading = false; + _scheduledLoadSlot = -1; + + _personalizedSave = false; + _compressedSavegames = true; + + _editorMode = false; + //_doNotExpandStrings = false; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + _smartCache = false; + _surfaceGCCycleTime = 10000; + + _reportTextureFormat = false; + + _viewportSP = -1; + + _subtitlesSpeed = 70; + + _forceNonStreamedSounds = false; + + _thumbnailWidth = _thumbnailHeight = 0; + + _richSavedGames = false; + _savedGameExt = NULL; + BaseUtils::setString(&_savedGameExt, "dsv"); + + _musicCrossfadeRunning = false; + _musicCrossfadeStartTime = 0; + _musicCrossfadeLength = 0; + _musicCrossfadeChannel1 = -1; + _musicCrossfadeChannel2 = -1; + _musicCrossfadeSwap = false; + + _localSaveDir = NULL; + BaseUtils::setString(&_localSaveDir, "saves"); + _saveDirChecked = false; + + _loadingIcon = NULL; + _loadingIconX = _loadingIconY = 0; + _loadingIconPersistent = false; + + _textEncoding = TEXT_ANSI; + _textRTL = false; + + _soundBufferSizeSec = 3; + _suspendedRendering = false; + + _lastCursor = NULL; + + + BasePlatform::setRectEmpty(&_mouseLockRect); + + _suppressScriptErrors = false; + _lastMiniUpdate = 0; + _miniUpdateEnabled = false; + + _cachedThumbnail = NULL; + + _autorunDisabled = false; + + // compatibility bits + _compatKillMethodThreads = false; + + _usedMem = 0; + + + _autoSaveOnExit = true; + _autoSaveSlot = 999; + _cursorHidden = false; + + // Block kept as a reminder that the engine CAN run in constrained/touch-mode + /*#ifdef __IPHONEOS__ + _touchInterface = true; + _constrainedMemory = true; // TODO differentiate old and new iOS devices + #else*/ + _touchInterface = false; + _constrainedMemory = false; +//#endif + +} + + +////////////////////////////////////////////////////////////////////// +BaseGame::~BaseGame() { + _shuttingDown = true; + + LOG(0, ""); + LOG(0, "Shutting down..."); + + ConfMan.setBool("last_run", true); + + cleanup(); + + delete[] _localSaveDir; + delete[] _settingsGameFile; + delete[] _savedGameExt; + + delete _cachedThumbnail; + + delete _mathClass; + + delete _transMgr; + delete _scEngine; + delete _fontStorage; + delete _surfaceStorage; + delete _videoPlayer; + delete _theoraPlayer; + delete _soundMgr; + //SAFE_DELETE(_keyboardState); + + delete _renderer; + delete _stringTable; + + _localSaveDir = NULL; + _settingsGameFile = NULL; + _savedGameExt = NULL; + + _cachedThumbnail = NULL; + + _mathClass = NULL; + + _transMgr = NULL; + _scEngine = NULL; + _fontStorage = NULL; + _surfaceStorage = NULL; + _videoPlayer = NULL; + _theoraPlayer = NULL; + _soundMgr = NULL; + + _renderer = NULL; + _stringTable = NULL; + + DEBUG_DebugDisable(); + debugC(kWintermuteDebugLog, "--- shutting down normally ---\n"); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::cleanup() { + delete _loadingIcon; + _loadingIcon = NULL; + + _engineLogCallback = NULL; + _engineLogCallbackData = NULL; + + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + delete _music[i]; + _music[i] = NULL; + _musicStartTime[i] = 0; + } + + unregisterObject(_fader); + _fader = NULL; + + for (uint32 i = 0; i < _regObjects.size(); i++) { + delete _regObjects[i]; + _regObjects[i] = NULL; + } + _regObjects.clear(); + + _windows.clear(); // refs only + _focusedWindow = NULL; // ref only + + delete _cursorNoninteractive; + delete _cursor; + delete _activeCursor; + _cursorNoninteractive = NULL; + _cursor = NULL; + _activeCursor = NULL; + + delete _scValue; + delete _sFX; + _scValue = NULL; + _sFX = NULL; + + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->_owner = NULL; + _scripts[i]->finish(); + } + _scripts.clear(); + + _fontStorage->removeFont(_systemFont); + _systemFont = NULL; + + _fontStorage->removeFont(_videoFont); + _videoFont = NULL; + + for (uint32 i = 0; i < _quickMessages.size(); i++) { + delete _quickMessages[i]; + } + _quickMessages.clear(); + + _viewportStack.clear(); + _viewportSP = -1; + + setName(NULL); + setFilename(NULL); + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _lastCursor = NULL; + + delete _keyboardState; + _keyboardState = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize1() { + bool loaded = false; // Not really a loop, but a goto-replacement. + while (!loaded) { + _surfaceStorage = new BaseSurfaceStorage(this); + if (_surfaceStorage == NULL) { + break; + } + + _fontStorage = new BaseFontStorage(this); + if (_fontStorage == NULL) { + break; + } + + _soundMgr = new BaseSoundMgr(this); + if (_soundMgr == NULL) { + break; + } + + _mathClass = new SXMath(this); + if (_mathClass == NULL) { + break; + } + + _scEngine = new ScEngine(this); + if (_scEngine == NULL) { + break; + } + + _videoPlayer = new VideoPlayer(this); + if (_videoPlayer == NULL) { + break; + } + + _transMgr = new BaseTransitionMgr(this); + if (_transMgr == NULL) { + break; + } + + _keyboardState = new BaseKeyboardState(this); + if (_keyboardState == NULL) { + break; + } + + _fader = new BaseFader(this); + if (_fader == NULL) { + break; + } + registerObject(_fader); + + loaded = true; + } + if (loaded == true) { + return STATUS_OK; + } else { + delete _mathClass; + delete _keyboardState; + delete _transMgr; + delete _surfaceStorage; + delete _fontStorage; + delete _soundMgr; + delete _scEngine; + delete _videoPlayer; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize2() { // we know whether we are going to be accelerated + _renderer = makeOSystemRenderer(this); + if (_renderer == NULL) { + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initialize3() { // renderer is initialized + _posX = _renderer->_width / 2; + _posY = _renderer->_height / 2; + _renderer->initIndicator(); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DebugEnable(const char *filename) { + _debugDebugMode = true; + + int secs = g_system->getMillis() / 1000; + int hours = secs / 3600; + secs = secs % 3600; + int mins = secs / 60; + secs = secs % 60; + +#ifdef _DEBUG + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Debug Build) *******************", hours, mins, secs); +#else + LOG(0, "********** DEBUG LOG OPENED %02d-%02d-%02d (Release Build) *****************", hours, mins, secs); +#endif + + LOG(0, "%s ver %d.%d.%d%s, Compiled on " __DATE__ ", " __TIME__, DCGF_NAME, DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, DCGF_VER_SUFFIX); + + AnsiString platform = BasePlatform::getPlatformName(); + LOG(0, "Platform: %s", platform.c_str()); + LOG(0, ""); +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DebugDisable() { + if (_debugLogFile != NULL) { + LOG(0, "********** DEBUG LOG CLOSED ********************************************"); + //fclose((FILE *)_debugLogFile); + _debugLogFile = NULL; + } + _debugDebugMode = false; +} + + +////////////////////////////////////////////////////////////////////// +void BaseGame::LOG(bool res, const char *fmt, ...) { + uint32 secs = g_system->getMillis() / 1000; + uint32 hours = secs / 3600; + secs = secs % 3600; + uint32 mins = secs / 60; + secs = secs % 60; + + char buff[512]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + // redirect to an engine's own callback + if (_engineLogCallback) { + _engineLogCallback(buff, res, _engineLogCallbackData); + } + + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + + //fprintf((FILE *)_debugLogFile, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + //fflush((FILE *)_debugLogFile); + + //QuickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setEngineLogCallback(ENGINE_LOG_CALLBACK callback, void *data) { + _engineLogCallback = callback; + _engineLogCallbackData = data; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initLoop() { + _viewportSP = -1; + + _currentTime = g_system->getMillis(); + + _renderer->initLoop(); + updateMusicCrossfade(); + + _surfaceStorage->initLoop(); + _fontStorage->initLoop(); + + + //_activeObject = NULL; + + // count FPS + _deltaTime = _currentTime - _lastTime; + _lastTime = _currentTime; + _fpsTime += _deltaTime; + + _liveTimerDelta = _liveTimer - _liveTimerLast; + _liveTimerLast = _liveTimer; + _liveTimer += MIN((uint32)1000, _deltaTime); + + if (_state != GAME_FROZEN) { + _timerDelta = _timer - _timerLast; + _timerLast = _timer; + _timer += MIN((uint32)1000, _deltaTime); + } else { + _timerDelta = 0; + } + + _framesRendered++; + if (_fpsTime > 1000) { + _fps = _framesRendered; + _framesRendered = 0; + _fpsTime = 0; + } + //_gameRef->LOG(0, "%d", _fps); + + getMousePos(&_mousePos); + + _focusedWindow = NULL; + for (int i = _windows.size() - 1; i >= 0; i--) { + if (_windows[i]->_visible) { + _focusedWindow = _windows[i]; + break; + } + } + + updateSounds(); + + if (_fader) { + _fader->update(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseGame::initInput() { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseGame::getSequence() { + return ++_sequence; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setOffset(int offsetX, int offsetY) { + _offsetX = offsetX; + _offsetY = offsetY; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::getOffset(int *offsetX, int *offsetY) { + if (offsetX != NULL) { + *offsetX = _offsetX; + } + if (offsetY != NULL) { + *offsetY = _offsetY; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseGame::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing GAME file '%s'", filename); + } + + delete[] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(GAME) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(SYSTEM_FONT) +TOKEN_DEF(VIDEO_FONT) +TOKEN_DEF(EVENTS) +TOKEN_DEF(CURSOR) +TOKEN_DEF(ACTIVE_CURSOR) +TOKEN_DEF(NONINTERACTIVE_CURSOR) +TOKEN_DEF(STRING_TABLE) +TOKEN_DEF(RESOLUTION) +TOKEN_DEF(SETTINGS) +TOKEN_DEF(REQUIRE_3D_ACCELERATION) +TOKEN_DEF(REQUIRE_SOUND) +TOKEN_DEF(HWTL_MODE) +TOKEN_DEF(ALLOW_WINDOWED_MODE) +TOKEN_DEF(ALLOW_ACCESSIBILITY_TAB) +TOKEN_DEF(ALLOW_ABOUT_TAB) +TOKEN_DEF(ALLOW_ADVANCED) +TOKEN_DEF(ALLOW_DESKTOP_RES) +TOKEN_DEF(REGISTRY_PATH) +TOKEN_DEF(PERSONAL_SAVEGAMES) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(PROPERTY) +TOKEN_DEF(SUBTITLES_SPEED) +TOKEN_DEF(SUBTITLES) +TOKEN_DEF(VIDEO_SUBTITLES) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(THUMBNAIL_WIDTH) +TOKEN_DEF(THUMBNAIL_HEIGHT) +TOKEN_DEF(INDICATOR_X) +TOKEN_DEF(INDICATOR_Y) +TOKEN_DEF(INDICATOR_WIDTH) +TOKEN_DEF(INDICATOR_HEIGHT) +TOKEN_DEF(INDICATOR_COLOR) +TOKEN_DEF(SAVE_IMAGE_X) +TOKEN_DEF(SAVE_IMAGE_Y) +TOKEN_DEF(SAVE_IMAGE) +TOKEN_DEF(LOAD_IMAGE_X) +TOKEN_DEF(LOAD_IMAGE_Y) +TOKEN_DEF(LOAD_IMAGE) +TOKEN_DEF(LOCAL_SAVE_DIR) +TOKEN_DEF(RICH_SAVED_GAMES) +TOKEN_DEF(SAVED_GAME_EXT) +TOKEN_DEF(GUID) +TOKEN_DEF(COMPAT_KILL_METHOD_THREADS) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(GAME) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(SYSTEM_FONT) + TOKEN_TABLE(VIDEO_FONT) + TOKEN_TABLE(EVENTS) + TOKEN_TABLE(CURSOR) + TOKEN_TABLE(ACTIVE_CURSOR) + TOKEN_TABLE(NONINTERACTIVE_CURSOR) + TOKEN_TABLE(PERSONAL_SAVEGAMES) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(SUBTITLES_SPEED) + TOKEN_TABLE(SUBTITLES) + TOKEN_TABLE(VIDEO_SUBTITLES) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(THUMBNAIL_WIDTH) + TOKEN_TABLE(THUMBNAIL_HEIGHT) + TOKEN_TABLE(INDICATOR_X) + TOKEN_TABLE(INDICATOR_Y) + TOKEN_TABLE(INDICATOR_WIDTH) + TOKEN_TABLE(INDICATOR_HEIGHT) + TOKEN_TABLE(INDICATOR_COLOR) + TOKEN_TABLE(SAVE_IMAGE_X) + TOKEN_TABLE(SAVE_IMAGE_Y) + TOKEN_TABLE(SAVE_IMAGE) + TOKEN_TABLE(LOAD_IMAGE_X) + TOKEN_TABLE(LOAD_IMAGE_Y) + TOKEN_TABLE(LOAD_IMAGE) + TOKEN_TABLE(LOCAL_SAVE_DIR) + TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) + TOKEN_TABLE_END + + // Declare a few variables necessary for moving data from these settings over to the renderer: + // The values are the same as the defaults set in BaseRenderer. + int loadImageX = 0; + int loadImageY = 0; + int saveImageX = 0; + int saveImageY = 0; + int indicatorX = -1; + int indicatorY = -1; + int indicatorWidth = -1; + int indicatorHeight = 8; + uint32 indicatorColor = BYTETORGBA(255, 0, 0, 128); + Common::String loadImageName = ""; + Common::String saveImageName = ""; + + byte *params; + int cmd; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_GAME) { + _gameRef->LOG(0, "'GAME' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_SYSTEM_FONT: + if (_systemFont) { + _fontStorage->removeFont(_systemFont); + } + _systemFont = NULL; + + _systemFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + case TOKEN_VIDEO_FONT: + if (_videoFont) { + _fontStorage->removeFont(_videoFont); + } + _videoFont = NULL; + + _videoFont = _gameRef->_fontStorage->addFont((char *)params); + break; + + + case TOKEN_CURSOR: + delete _cursor; + _cursor = new BaseSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile((char *)params))) { + delete _cursor; + _cursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_ACTIVE_CURSOR: + delete _activeCursor; + _activeCursor = NULL; + _activeCursor = new BaseSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile((char *)params))) { + delete _activeCursor; + _activeCursor = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NONINTERACTIVE_CURSOR: + delete _cursorNoninteractive; + _cursorNoninteractive = new BaseSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile((char *)params))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_PERSONAL_SAVEGAMES: + parser.scanStr((char *)params, "%b", &_personalizedSave); + break; + + case TOKEN_SUBTITLES: + parser.scanStr((char *)params, "%b", &_subtitles); + break; + + case TOKEN_SUBTITLES_SPEED: + parser.scanStr((char *)params, "%d", &_subtitlesSpeed); + break; + + case TOKEN_VIDEO_SUBTITLES: + parser.scanStr((char *)params, "%b", &_videoSubtitles); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + + case TOKEN_THUMBNAIL_WIDTH: + parser.scanStr((char *)params, "%d", &_thumbnailWidth); + break; + + case TOKEN_THUMBNAIL_HEIGHT: + parser.scanStr((char *)params, "%d", &_thumbnailHeight); + break; + + case TOKEN_INDICATOR_X: + parser.scanStr((char *)params, "%d", &indicatorX); + break; + + case TOKEN_INDICATOR_Y: + parser.scanStr((char *)params, "%d", &indicatorY); + break; + + case TOKEN_INDICATOR_COLOR: { + int r, g, b, a; + parser.scanStr((char *)params, "%d,%d,%d,%d", &r, &g, &b, &a); + indicatorColor = BYTETORGBA(r, g, b, a); + } + break; + + case TOKEN_INDICATOR_WIDTH: + parser.scanStr((char *)params, "%d", &indicatorWidth); + break; + + case TOKEN_INDICATOR_HEIGHT: + parser.scanStr((char *)params, "%d", &indicatorHeight); + break; + + case TOKEN_SAVE_IMAGE: + saveImageName = (char *) params; + break; + + case TOKEN_SAVE_IMAGE_X: + parser.scanStr((char *)params, "%d", &saveImageX); + break; + + case TOKEN_SAVE_IMAGE_Y: + parser.scanStr((char *)params, "%d", &saveImageY); + break; + + case TOKEN_LOAD_IMAGE: + loadImageName = (char *) params; + break; + + case TOKEN_LOAD_IMAGE_X: + parser.scanStr((char *)params, "%d", &loadImageX); + break; + + case TOKEN_LOAD_IMAGE_Y: + parser.scanStr((char *)params, "%d", &loadImageY); + break; + + case TOKEN_LOCAL_SAVE_DIR: + BaseUtils::setString(&_localSaveDir, (char *)params); + break; + + case TOKEN_COMPAT_KILL_METHOD_THREADS: + parser.scanStr((char *)params, "%b", &_compatKillMethodThreads); + break; + } + } + + _renderer->setIndicator(indicatorWidth, indicatorHeight, indicatorX, indicatorY, indicatorColor); + _renderer->initIndicator(); // In case we just reset the values. + _renderer->setSaveImage(saveImageName.c_str(), saveImageX, saveImageY); + _renderer->setLoadingScreen(loadImageName.c_str(), loadImageX, loadImageY); + + if (!_systemFont) { + _systemFont = _gameRef->_fontStorage->addFont("system_font.fnt"); + } + + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in GAME definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading GAME definition"); + return STATUS_FAILED; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + LOG(0, stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + bool res = BaseObject::scCallMethod(script, stack, thisStack, name); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // Msg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Msg") == 0) { + stack->correctParams(1); + quickMessage(stack->pop()->getString()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RunScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RunScript") == 0) { + _gameRef->LOG(0, "**Warning** The 'RunScript' method is now obsolete. Use 'AttachScript' instead (same syntax)"); + stack->correctParams(1); + if (DID_FAIL(addScript(stack->pop()->getString()))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadStringTable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadStringTable") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + ScValue *val = stack->pop(); + + bool clearOld; + if (val->isNULL()) { + clearOld = true; + } else { + clearOld = val->getBool(); + } + + if (DID_FAIL(_stringTable->loadFile(filename, clearOld))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ValidObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ValidObject") == 0) { + stack->correctParams(1); + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *) obj)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + resetContent(); + stack->pushNULL(); + + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // UnloadObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UnloadObject") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + BaseObject *obj = (BaseObject *)val->getNative(); + unregisterObject(obj); + if (val->getType() == VAL_VARIABLE_REF) { + val->setNULL(); + } + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadWindow") == 0) { + stack->correctParams(1); + UIWindow *win = new UIWindow(_gameRef); + if (win && DID_SUCCEED(win->loadFile(stack->pop()->getString()))) { + _windows.add(win); + registerObject(win); + stack->pushNative(win, true); + } else { + delete win; + win = NULL; + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ExpandString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExpandString") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + char *str = new char[strlen(val->getString()) + 1]; + strcpy(str, val->getString()); + _stringTable->expand(&str); + stack->pushString(str); + delete[] str; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayMusic / PlayMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayMusic") == 0 || strcmp(name, "PlayMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "PlayMusic") == 0) { + stack->correctParams(3); + } else { + stack->correctParams(4); + channel = stack->pop()->getInt(); + } + + const char *filename = stack->pop()->getString(); + ScValue *valLooping = stack->pop(); + bool looping = valLooping->isNULL() ? true : valLooping->getBool(); + + ScValue *valLoopStart = stack->pop(); + uint32 loopStart = (uint32)(valLoopStart->isNULL() ? 0 : valLoopStart->getInt()); + + + if (DID_FAIL(playMusic(channel, filename, looping, loopStart))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopMusic / StopMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopMusic") == 0 || strcmp(name, "StopMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "StopMusic") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(stopMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseMusic / PauseMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseMusic") == 0 || strcmp(name, "PauseMusicChannel") == 0) { + int channel = 0; + + if (strcmp(name, "PauseMusic") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(pauseMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeMusic / ResumeMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeMusic") == 0 || strcmp(name, "ResumeMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "ResumeMusic") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (DID_FAIL(resumeMusic(channel))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusic / GetMusicChannel + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusic") == 0 || strcmp(name, "GetMusicChannel") == 0) { + int channel = 0; + if (strcmp(name, "GetMusic") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS) { + stack->pushNULL(); + } else { + if (!_music[channel] || !_music[channel]->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_music[channel]->getFilename()); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicPosition / SetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicPosition") == 0 || strcmp(name, "SetMusicChannelPosition") == 0 || strcmp(name, "SetMusicPositionChannel") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicPosition") == 0) { + stack->correctParams(1); + } else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + uint32 time = stack->pop()->getInt(); + + if (DID_FAIL(setMusicStartTime(channel, time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicPosition / GetMusicChannelPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicPosition") == 0 || strcmp(name, "GetMusicChannelPosition") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicPosition") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getPositionTime()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsMusicPlaying / IsMusicChannelPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsMusicPlaying") == 0 || strcmp(name, "IsMusicChannelPlaying") == 0) { + int channel = 0; + if (strcmp(name, "IsMusicPlaying") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + stack->pushBool(_music[channel]->isPlaying()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMusicVolume / SetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMusicVolume") == 0 || strcmp(name, "SetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "SetMusicVolume") == 0) { + stack->correctParams(1); + } else { + stack->correctParams(2); + channel = stack->pop()->getInt(); + } + + int volume = stack->pop()->getInt(); + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushBool(false); + } else { + if (DID_FAIL(_music[channel]->setVolumePercent(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetMusicVolume / GetMusicChannelVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMusicVolume") == 0 || strcmp(name, "GetMusicChannelVolume") == 0) { + int channel = 0; + if (strcmp(name, "GetMusicVolume") == 0) { + stack->correctParams(0); + } else { + stack->correctParams(1); + channel = stack->pop()->getInt(); + } + + if (channel < 0 || channel >= NUM_MUSIC_CHANNELS || !_music[channel]) { + stack->pushInt(0); + } else { + stack->pushInt(_music[channel]->getVolumePercent()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicCrossfade + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicCrossfade") == 0) { + stack->correctParams(4); + int channel1 = stack->pop()->getInt(0); + int channel2 = stack->pop()->getInt(0); + uint32 fadeLength = (uint32)stack->pop()->getInt(0); + bool swap = stack->pop()->getBool(true); + + if (_musicCrossfadeRunning) { + script->runtimeError("Game.MusicCrossfade: Music crossfade is already in progress."); + stack->pushBool(false); + return STATUS_OK; + } + + _musicCrossfadeStartTime = _liveTimer; + _musicCrossfadeChannel1 = channel1; + _musicCrossfadeChannel2 = channel2; + _musicCrossfadeLength = fadeLength; + _musicCrossfadeSwap = swap; + + _musicCrossfadeRunning = true; + + stack->pushBool(true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundLength + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundLength") == 0) { + stack->correctParams(1); + + int length = 0; + const char *filename = stack->pop()->getString(); + + BaseSound *sound = new BaseSound(_gameRef); + if (sound && DID_SUCCEED(sound->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + length = sound->getLength(); + delete sound; + sound = NULL; + } + stack->pushInt(length); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetMousePos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMousePos") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + x = MAX(x, 0); + x = MIN(x, _renderer->_width); + y = MAX(y, 0); + y = MIN(y, _renderer->_height); + Point32 p; + p.x = x + _renderer->_drawOffsetX; + p.y = y + _renderer->_drawOffsetY; + + BasePlatform::setCursorPos(p.x, p.y); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LockMouseRect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LockMouseRect") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + if (right < left) { + BaseUtils::swap(&left, &right); + } + if (bottom < top) { + BaseUtils::swap(&top, &bottom); + } + + BasePlatform::setRect(&_mouseLockRect, left, top, right, bottom); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayVideo + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayVideo") == 0) { + _gameRef->LOG(0, "Warning: Game.PlayVideo() is now deprecated. Use Game.PlayTheora() instead."); + + stack->correctParams(6); + const char *filename = stack->pop()->getString(); + warning("PlayVideo: %s - not implemented yet", filename); + ScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) { + type = (int)VID_PLAY_STRETCH; + } else { + type = valType->getInt(); + } + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + + ScValue *valSub = stack->pop(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } + + if (DID_SUCCEED(_gameRef->_videoPlayer->initialize(filename, subtitleFile))) { + if (DID_SUCCEED(_gameRef->_videoPlayer->play((TVideoPlayback)type, xVal, yVal, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else { + stack->pushBool(false); + } + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlayTheora + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlayTheora") == 0) { + stack->correctParams(7); + const char *filename = stack->pop()->getString(); + ScValue *valType = stack->pop(); + int type; + if (valType->isNULL()) { + type = (int)VID_PLAY_STRETCH; + } else { + type = valType->getInt(); + } + + int xVal = stack->pop()->getInt(); + int yVal = stack->pop()->getInt(); + bool freezeMusic = stack->pop()->getBool(true); + bool dropFrames = stack->pop()->getBool(true); + + ScValue *valSub = stack->pop(); + const char *subtitleFile = valSub->isNULL() ? NULL : valSub->getString(); + + if (type < (int)VID_PLAY_POS || type > (int)VID_PLAY_CENTER) { + type = (int)VID_PLAY_STRETCH; + } + + delete _theoraPlayer; + _theoraPlayer = new VideoTheoraPlayer(this); + if (_theoraPlayer && DID_SUCCEED(_theoraPlayer->initialize(filename, subtitleFile))) { + _theoraPlayer->_dontDropFrames = !dropFrames; + if (DID_SUCCEED(_theoraPlayer->play((TVideoPlayback)type, xVal, yVal, true, freezeMusic))) { + stack->pushBool(true); + script->sleep(0); + } else { + stack->pushBool(false); + } + } else { + stack->pushBool(false); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // QuitGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "QuitGame") == 0) { + stack->correctParams(0); + stack->pushNULL(); + _quitting = true; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int val = stack->pop()->getInt(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + ConfMan.setInt(privKey, val); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadNumber + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadNumber") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + int initVal = stack->pop()->getInt(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + int result = initVal; + if (ConfMan.hasKey(privKey)) { + result = ConfMan.getInt(privKey); + } + stack->pushInt(result); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegWriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegWriteString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *val = stack->pop()->getString(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String privVal = StringUtil::encodeSetting(val); + ConfMan.set(privKey, privVal); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RegReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RegReadString") == 0) { + stack->correctParams(2); + const char *key = stack->pop()->getString(); + const char *initVal = stack->pop()->getString(); + Common::String privKey = "priv_" + StringUtil::encodeSetting(key); + Common::String result = initVal; + if (ConfMan.hasKey(privKey)) { + result = StringUtil::decodeSetting(ConfMan.get(key)); + } + stack->pushString(result.c_str()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveGame") == 0) { + stack->correctParams(3); + int slot = stack->pop()->getInt(); + const char *xdesc = stack->pop()->getString(); + bool quick = stack->pop()->getBool(false); + + char *desc = new char[strlen(xdesc) + 1]; + strcpy(desc, xdesc); + stack->pushBool(true); + if (DID_FAIL(saveGame(slot, desc, quick))) { + stack->pop(); + stack->pushBool(false); + } + delete[] desc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadGame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadGame") == 0) { + stack->correctParams(1); + _scheduledLoadSlot = stack->pop()->getInt(); + _loading = true; + stack->pushBool(false); + script->sleep(0); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSaveSlotUsed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSaveSlotUsed") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + stack->pushBool(SaveLoad::isSaveSlotUsed(slot)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSaveSlotDescription + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSaveSlotDescription") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + char desc[512]; + desc[0] = '\0'; + SaveLoad::getSaveSlotDescription(slot, desc); + stack->pushString(desc); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmptySaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmptySaveSlot") == 0) { + stack->correctParams(1); + int slot = stack->pop()->getInt(); + SaveLoad::emptySaveSlot(slot); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSFXVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalSpeechVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMusicVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetGlobalMasterVolume") == 0) { + stack->correctParams(1); + _gameRef->_soundMgr->setMasterVolumePercent((byte)stack->pop()->getInt()); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSFXVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalSpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalSpeechVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMusicVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetGlobalMasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGlobalMasterVolume") == 0) { + stack->correctParams(0); + stack->pushInt(_soundMgr->getMasterVolumePercent()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetActiveCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setActiveCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursor") == 0) { + stack->correctParams(0); + if (!_activeCursor || !_activeCursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_activeCursor->getFilename()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetActiveCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetActiveCursorObject") == 0) { + stack->correctParams(0); + if (!_activeCursor) { + stack->pushNULL(); + } else { + stack->pushNative(_activeCursor, true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveActiveCursor") == 0) { + stack->correctParams(0); + delete _activeCursor; + _activeCursor = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasActiveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasActiveCursor") == 0) { + stack->correctParams(0); + + if (_activeCursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FileExists + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FileExists") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + bool exists = BaseFileManager::getEngineInstance()->hasFile(filename); // Had absPathWarning = false + stack->pushBool(exists); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeOut / FadeOutAsync / SystemFadeOut / SystemFadeOutAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOut") == 0 || strcmp(name, "FadeOutAsync") == 0 || strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeOut") == 0 || strcmp(name, "SystemFadeOutAsync") == 0); + + _fader->fadeOut(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeOutAsync") != 0 && strcmp(name, "SystemFadeOutAsync") != 0) { + script->waitFor(_fader); + } + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeIn / FadeInAsync / SystemFadeIn / SystemFadeInAsync + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeIn") == 0 || strcmp(name, "FadeInAsync") == 0 || strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0) { + stack->correctParams(5); + uint32 duration = stack->pop()->getInt(500); + byte red = stack->pop()->getInt(0); + byte green = stack->pop()->getInt(0); + byte blue = stack->pop()->getInt(0); + byte alpha = stack->pop()->getInt(0xFF); + + bool system = (strcmp(name, "SystemFadeIn") == 0 || strcmp(name, "SystemFadeInAsync") == 0); + + _fader->fadeIn(BYTETORGBA(red, green, blue, alpha), duration, system); + if (strcmp(name, "FadeInAsync") != 0 && strcmp(name, "SystemFadeInAsync") != 0) { + script->waitFor(_fader); + } + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFadeColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFadeColor") == 0) { + stack->correctParams(0); + stack->pushInt(_fader->getCurrentColor()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Screenshot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Screenshot") == 0) { + stack->correctParams(1); + char filename[MAX_PATH_LENGTH]; + + ScValue *val = stack->pop(); + + warning("BGame::ScCallMethod - Screenshot not reimplemented"); //TODO + int fileNum = 0; + + while (true) { + sprintf(filename, "%s%03d.bmp", val->isNULL() ? getName() : val->getString(), fileNum); + if (!Common::File::exists(filename)) { + break; + } + fileNum++; + } + + bool ret = false; + BaseImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + delete image; + } else { + ret = false; + } + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenshotEx + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenshotEx") == 0) { + stack->correctParams(3); + const char *filename = stack->pop()->getString(); + int sizeX = stack->pop()->getInt(_renderer->_width); + int sizeY = stack->pop()->getInt(_renderer->_height); + + bool ret = false; + BaseImage *image = _gameRef->_renderer->takeScreenshot(); + if (image) { + ret = DID_SUCCEED(image->resize(sizeX, sizeY)); + if (ret) { + ret = DID_SUCCEED(image->saveBMPFile(filename)); + } + delete image; + } else { + ret = false; + } + + stack->pushBool(ret); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CreateWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CreateWindow") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + UIWindow *win = new UIWindow(_gameRef); + _windows.add(win); + registerObject(win); + if (!val->isNULL()) { + win->setName(val->getString()); + } + stack->pushNative(win, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteWindow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteWindow") == 0) { + stack->correctParams(1); + BaseObject *obj = (BaseObject *)stack->pop()->getNative(); + for (uint32 i = 0; i < _windows.size(); i++) { + if (_windows[i] == obj) { + unregisterObject(_windows[i]); + stack->pushBool(true); + return STATUS_OK; + } + } + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenDocument + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenDocument") == 0) { + stack->correctParams(0); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_DumpClassRegistry + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_DumpClassRegistry") == 0) { + stack->correctParams(0); + DEBUG_DumpClassRegistry(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetLoadingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetLoadingScreen") == 0) { + stack->correctParams(3); + ScValue *val = stack->pop(); + int loadImageX = stack->pop()->getInt(); + int loadImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + _renderer->setLoadingScreen(NULL, loadImageX, loadImageY); + } else { + _renderer->setLoadingScreen(val->getString(), loadImageX, loadImageY); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSavingScreen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSavingScreen") == 0) { + stack->correctParams(3); + ScValue *val = stack->pop(); + int saveImageX = stack->pop()->getInt(); + int saveImageY = stack->pop()->getInt(); + + if (val->isNULL()) { + _renderer->setSaveImage(NULL, saveImageX, saveImageY); + } else { + _renderer->setSaveImage(NULL, saveImageX, saveImageY); + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetWaitCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setWaitCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveWaitCursor") == 0) { + stack->correctParams(0); + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursor") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive || !_cursorNoninteractive->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursorNoninteractive->getFilename()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetWaitCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWaitCursorObject") == 0) { + stack->correctParams(0); + if (!_cursorNoninteractive) { + stack->pushNULL(); + } else { + stack->pushNative(_cursorNoninteractive, true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ClearScriptCache + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ClearScriptCache") == 0) { + stack->correctParams(0); + stack->pushBool(DID_SUCCEED(_scEngine->emptyScriptCache())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisplayLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisplayLoadingIcon") == 0) { + stack->correctParams(4); + + const char *filename = stack->pop()->getString(); + _loadingIconX = stack->pop()->getInt(); + _loadingIconY = stack->pop()->getInt(); + _loadingIconPersistent = stack->pop()->getBool(); + + delete _loadingIcon; + _loadingIcon = new BaseSprite(this); + if (!_loadingIcon || DID_FAIL(_loadingIcon->loadFile(filename))) { + delete _loadingIcon; + _loadingIcon = NULL; + } else { + displayContent(false, true); + _gameRef->_renderer->flip(); + _gameRef->_renderer->initLoop(); + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideLoadingIcon + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideLoadingIcon") == 0) { + stack->correctParams(0); + delete _loadingIcon; + _loadingIcon = NULL; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DumpTextureStats + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DumpTextureStats") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + + _renderer->dumpData(filename); + + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccOutputText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccOutputText") == 0) { + stack->correctParams(2); + /* const char *str = */ stack->pop()->getString(); + /* int type = */ stack->pop()->getInt(); + // do nothing + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StoreSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StoreSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = new BaseSaveThumbHelper(this); + if (DID_FAIL(_cachedThumbnail->storeThumbnail())) { + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushBool(false); + } else { + stack->pushBool(true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteSaveThumbnail + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteSaveThumbnail") == 0) { + stack->correctParams(0); + delete _cachedThumbnail; + _cachedThumbnail = NULL; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFileChecksum + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFileChecksum") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool asHex = stack->pop()->getBool(false); + + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename, false); + if (file) { + crc remainder = crc_initialize(); + byte buf[1024]; + int bytesRead = 0; + + while (bytesRead < file->size()) { + int bufSize = MIN((uint32)1024, (uint32)(file->size() - bytesRead)); + bytesRead += file->read(buf, bufSize); + + for (int i = 0; i < bufSize; i++) { + remainder = crc_process_byte(buf[i], remainder); + } + } + crc checksum = crc_finalize(remainder); + + if (asHex) { + char hex[100]; + sprintf(hex, "%x", checksum); + stack->pushString(hex); + } else { + stack->pushInt(checksum); + } + + BaseFileManager::getEngineInstance()->closeFile(file); + file = NULL; + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EnableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EnableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->enableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DisableScriptProfiling + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DisableScriptProfiling") == 0) { + stack->correctParams(0); + _scEngine->disableProfiling(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ShowStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ShowStatusLine") == 0) { + stack->correctParams(0); + // Block kept to show intention of opcode. + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(TRUE); + #endif*/ + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HideStatusLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HideStatusLine") == 0) { + stack->correctParams(0); + // Block kept to show intention of opcode. + /*#ifdef __IPHONEOS__ + IOS_ShowStatusLine(FALSE); + #endif*/ + stack->pushNULL(); + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseGame::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("game"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(getName()); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Hwnd (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Hwnd") == 0) { + _scValue->setInt((int)_renderer->_window); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentTime") == 0) { + _scValue->setInt((int)_timer); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowsTime (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowsTime") == 0) { + _scValue->setInt((int)g_system->getMillis()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // WindowedMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WindowedMode") == 0) { + _scValue->setBool(_renderer->_windowed); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _scValue->setInt(_mousePos.x); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _scValue->setInt(_mousePos.y); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + _scValue->setNative(_mainObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ActiveObject (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ActiveObject") == 0) { + _scValue->setNative(_activeObject, true); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenWidth (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenWidth") == 0) { + _scValue->setInt(_renderer->_width); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScreenHeight (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScreenHeight") == 0) { + _scValue->setInt(_renderer->_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + _scValue->setBool(_interactive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DebugMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DebugMode") == 0) { + _scValue->setBool(_debugDebugMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundAvailable (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundAvailable") == 0) { + _scValue->setBool(_soundMgr->_soundAvailable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _scValue->setInt(_soundMgr->getMasterVolumePercent()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Keyboard (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Keyboard") == 0) { + if (_keyboardState) { + _scValue->setNative(_keyboardState, true); + } else { + _scValue->setNULL(); + } + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _scValue->setBool(_subtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _scValue->setInt(_subtitlesSpeed); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _scValue->setBool(_videoSubtitles); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FPS (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FPS") == 0) { + _scValue->setInt(_fps); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AcceleratedMode / Accelerated (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + _scValue->setBool(_useD3D); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + _scValue->setInt(_textEncoding); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _scValue->setBool(_textRTL); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _scValue->setInt(_soundBufferSizeSec); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _scValue->setBool(_suspendedRendering); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _scValue->setBool(_suppressScriptErrors); + return _scValue; + } + + + ////////////////////////////////////////////////////////////////////////// + // Frozen + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Frozen") == 0) { + _scValue->setBool(_state == GAME_FROZEN); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSTalk + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSTalk") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSCaptions + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSCaptions") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccTTSKeypress + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccTTSKeypress") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardEnabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardEnabled") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardCursorSkip + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccKeyboardPause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccKeyboardPause") == 0) { + _scValue->setBool(false); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _scValue->setBool(_autorunDisabled); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveDirectory (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveDirectory") == 0) { + AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. + _scValue->setString(dataDir.c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _scValue->setBool(_autoSaveOnExit); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _scValue->setInt(_autoSaveSlot); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _scValue->setBool(_cursorHidden); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Platform (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Platform") == 0) { + _scValue->setString(BasePlatform::getPlatformName().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // DeviceType (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeviceType") == 0) { + _scValue->setString(getDeviceType().c_str()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MostRecentSaveSlot (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MostRecentSaveSlot") == 0) { + if (!ConfMan.hasKey("most_recent_saveslot")) { + _scValue->setInt(-1); + } else { + _scValue->setInt(ConfMan.getInt("most_recent_saveslot")); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Store (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Store") == 0) { + _scValue->setNULL(); + error("Request for a SXStore-object, which is not supported by ScummVM"); + + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseX") == 0) { + _mousePos.x = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MouseY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MouseY") == 0) { + _mousePos.y = value->getInt(); + resetMousePos(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + bool res = BaseObject::scSetProperty(name, value); + setWindowTitle(); + return res; + } + + ////////////////////////////////////////////////////////////////////////// + // MainObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MainObject") == 0) { + BaseScriptable *obj = value->getNative(); + if (obj == NULL || validObject((BaseObject *)obj)) { + _mainObject = (BaseObject *)obj; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Interactive") == 0) { + setInteractive(value->getBool()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SFXVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SFXVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSFXSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SpeechVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SpeechVolume") == 0) { + _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kSpeechSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MusicVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MusicVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); + _gameRef->_soundMgr->setVolumePercent(Audio::Mixer::kMusicSoundType, (byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MasterVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MasterVolume") == 0) { + _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); + _gameRef->_soundMgr->setMasterVolumePercent((byte)value->getInt()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Subtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Subtitles") == 0) { + _subtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SubtitlesSpeed + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SubtitlesSpeed") == 0) { + _subtitlesSpeed = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // VideoSubtitles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VideoSubtitles") == 0) { + _videoSubtitles = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextEncoding + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextEncoding") == 0) { + int enc = value->getInt(); + if (enc < 0) { + enc = 0; + } + if (enc >= NUM_TEXT_ENCODINGS) { + enc = NUM_TEXT_ENCODINGS - 1; + } + _textEncoding = (TTextEncoding)enc; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // TextRTL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextRTL") == 0) { + _textRTL = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundBufferSize + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundBufferSize") == 0) { + _soundBufferSizeSec = value->getInt(); + _soundBufferSizeSec = MAX(3, _soundBufferSizeSec); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuspendedRendering + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuspendedRendering") == 0) { + _suspendedRendering = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SuppressScriptErrors + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SuppressScriptErrors") == 0) { + _suppressScriptErrors = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutorunDisabled + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutorunDisabled") == 0) { + _autorunDisabled = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveOnExit + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveOnExit") == 0) { + _autoSaveOnExit = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AutoSaveSlot + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AutoSaveSlot") == 0) { + _autoSaveSlot = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CursorHidden + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CursorHidden") == 0) { + _cursorHidden = value->getBool(); + return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseGame::scToString() { + return "[game object]"; +} + + + +#define QUICK_MSG_DURATION 3000 +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayQuickMsg() { + if (_quickMessages.size() == 0 || !_systemFont) { + return STATUS_OK; + } + + // update + for (uint32 i = 0; i < _quickMessages.size(); i++) { + if (_currentTime - _quickMessages[i]->_startTime >= QUICK_MSG_DURATION) { + delete _quickMessages[i]; + _quickMessages.remove_at(i); + i--; + } + } + + int posY = 20; + + // display + for (uint32 i = 0; i < _quickMessages.size(); i++) { + _systemFont->drawText((byte *)_quickMessages[i]->getText(), 0, posY, _renderer->_width); + posY += _systemFont->getTextHeight((byte *)_quickMessages[i]->getText(), _renderer->_width); + } + return STATUS_OK; +} + + +#define MAX_QUICK_MSG 5 +////////////////////////////////////////////////////////////////////////// +void BaseGame::quickMessage(const char *text) { + if (_quickMessages.size() >= MAX_QUICK_MSG) { + delete _quickMessages[0]; + _quickMessages.remove_at(0); + } + _quickMessages.add(new BaseQuickMsg(_gameRef, text)); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::quickMessageForm(char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + quickMessage(buff); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::registerObject(BaseObject *object) { + _regObjects.add(object); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::unregisterObject(BaseObject *object) { + if (!object) { + return STATUS_OK; + } + + // is it a window? + for (uint32 i = 0; i < _windows.size(); i++) { + if ((BaseObject *)_windows[i] == object) { + _windows.remove_at(i); + + // get new focused window + if (_focusedWindow == object) { + _focusedWindow = NULL; + } + + break; + } + } + + // is it active object? + if (_activeObject == object) { + _activeObject = NULL; + } + + // is it main object? + if (_mainObject == object) { + _mainObject = NULL; + } + + // destroy object + for (uint32 i = 0; i < _regObjects.size(); i++) { + if (_regObjects[i] == object) { + _regObjects.remove_at(i); + if (!_loadInProgress) { + SystemClassRegistry::getInstance()->enumInstances(invalidateValues, "ScValue", (void *)object); + } + delete object; + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::invalidateValues(void *value, void *data) { + ScValue *val = (ScValue *)value; + if (val->isNative() && val->getNative() == data) { + if (!val->_persistent && ((BaseScriptable *)data)->_refCount == 1) { + ((BaseScriptable *)data)->_refCount++; + } + val->setNative(NULL); + val->setNULL(); + } +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::validObject(BaseObject *object) { + if (!object) { + return false; + } + if (object == this) { + return true; + } + + for (uint32 i = 0; i < _regObjects.size(); i++) { + if (_regObjects[i] == object) { + return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name) { + ScValue *thisObj; + + ////////////////////////////////////////////////////////////////////////// + // LOG + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "LOG") == 0) { + stack->correctParams(1); + _gameRef->LOG(0, "sc: %s", stack->pop()->getString()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // String + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "String") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXString(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MemBuffer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MemBuffer") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXMemBuffer(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // File + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "File") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXFile(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Date + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Date") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXDate(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Array + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Array") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXArray(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Object + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Object") == 0) { + thisObj = thisStack->getTop(); + + thisObj->setNative(makeSXObject(_gameRef, stack)); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Sleep + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sleep") == 0) { + stack->correctParams(1); + + script->sleep((uint32)stack->pop()->getInt()); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // WaitFor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WaitFor") == 0) { + stack->correctParams(1); + + BaseScriptable *obj = stack->pop()->getNative(); + if (validObject((BaseObject *)obj)) { + script->waitForExclusive((BaseObject *)obj); + } + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // Random + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Random") == 0) { + stack->correctParams(2); + + int from = stack->pop()->getInt(); + int to = stack->pop()->getInt(); + + stack->pushInt(BaseUtils::randomInt(from, to)); + } + + ////////////////////////////////////////////////////////////////////////// + // SetScriptTimeSlice + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetScriptTimeSlice") == 0) { + stack->correctParams(1); + + script->_timeSlice = (uint32)stack->pop()->getInt(); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeRGBA / MakeRGB / RGB + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeRGBA") == 0 || strcmp(name, "MakeRGB") == 0 || strcmp(name, "RGB") == 0) { + stack->correctParams(4); + int r = stack->pop()->getInt(); + int g = stack->pop()->getInt(); + int b = stack->pop()->getInt(); + int a; + ScValue *val = stack->pop(); + if (val->isNULL()) { + a = 255; + } else { + a = val->getInt(); + } + + stack->pushInt(BYTETORGBA(r, g, b, a)); + } + + ////////////////////////////////////////////////////////////////////////// + // MakeHSL + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MakeHSL") == 0) { + stack->correctParams(3); + int h = stack->pop()->getInt(); + int s = stack->pop()->getInt(); + int l = stack->pop()->getInt(); + + stack->pushInt(BaseUtils::HSLtoRGB(h, s, l)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetRValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetRValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetR(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetGValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetGValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetG(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetBValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetB(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetAValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetAValue") == 0) { + stack->correctParams(1); + + uint32 rgba = (uint32)stack->pop()->getInt(); + stack->pushInt(RGBCOLGetA(rgba)); + } + + ////////////////////////////////////////////////////////////////////////// + // GetHValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(H); + } + + ////////////////////////////////////////////////////////////////////////// + // GetSValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(S); + } + + ////////////////////////////////////////////////////////////////////////// + // GetLValue + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetLValue") == 0) { + stack->correctParams(1); + uint32 rgb = (uint32)stack->pop()->getInt(); + + byte H, S, L; + BaseUtils::RGBtoHSL(rgb, &H, &S, &L); + stack->pushInt(L); + } + + ////////////////////////////////////////////////////////////////////////// + // Debug + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Debug") == 0) { + stack->correctParams(0); + stack->pushNULL(); + } + + ////////////////////////////////////////////////////////////////////////// + // ToString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToString") == 0) { + stack->correctParams(1); + const char *str = stack->pop()->getString(); + char *str2 = new char[strlen(str) + 1]; + strcpy(str2, str); + stack->pushString(str2); + delete[] str2; + } + + ////////////////////////////////////////////////////////////////////////// + // ToInt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToInt") == 0) { + stack->correctParams(1); + int val = stack->pop()->getInt(); + stack->pushInt(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToFloat") == 0) { + stack->correctParams(1); + double val = stack->pop()->getFloat(); + stack->pushFloat(val); + } + + ////////////////////////////////////////////////////////////////////////// + // ToBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + stack->pushBool(val); + } + + ////////////////////////////////////////////////////////////////////////// + // failure + else { + script->runtimeError("Call to undefined function '%s'. Ignored.", name); + stack->correctParams(0); + stack->pushNULL(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::showCursor() { + if (_cursorHidden) { + return STATUS_OK; + } + + if (!_interactive && _gameRef->_state == GAME_RUNNING) { + if (_cursorNoninteractive) { + return drawCursor(_cursorNoninteractive); + } + } else { + if (_activeObject && !DID_FAIL(_activeObject->showCursor())) { + return STATUS_OK; + } else { + if (_activeObject && _activeCursor && _activeObject->getExtendedFlag("usable")) { + return drawCursor(_activeCursor); + } else if (_cursor) { + return drawCursor(_cursor); + } + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::saveGame(int slot, const char *desc, bool quickSave) { + return SaveLoad::saveGame(slot, desc, quickSave, _gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadGame(int slot) { + //_gameRef->LOG(0, "Load start %d", BaseUtils::GetUsedMemMB()); + + _loading = false; + _scheduledLoadSlot = -1; + + Common::String filename = SaveLoad::getSaveSlotFilename(slot); + + return loadGame(filename.c_str()); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadGame(const char *filename) { + return SaveLoad::loadGame(filename, _gameRef); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayWindows(bool inGame) { + bool res; + + // did we lose focus? focus topmost window + if (_focusedWindow == NULL || !_focusedWindow->_visible || _focusedWindow->_disable) { + _focusedWindow = NULL; + for (int i = _windows.size() - 1; i >= 0; i--) { + if (_windows[i]->_visible && !_windows[i]->_disable) { + _focusedWindow = _windows[i]; + break; + } + } + } + + // display all windows + for (uint32 i = 0; i < _windows.size(); i++) { + if (_windows[i]->_visible && _windows[i]->_inGame == inGame) { + + res = _windows[i]->display(); + if (DID_FAIL(res)) { + return res; + } + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::playMusic(int channel, const char *filename, bool looping, uint32 loopStart) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + delete _music[channel]; + _music[channel] = NULL; + + _music[channel] = new BaseSound(_gameRef); + if (_music[channel] && DID_SUCCEED(_music[channel]->setSound(filename, Audio::Mixer::kMusicSoundType, true))) { + if (_musicStartTime[channel]) { + _music[channel]->setPositionTime(_musicStartTime[channel]); + _musicStartTime[channel] = 0; + } + if (loopStart) { + _music[channel]->setLoopStart(loopStart); + } + return _music[channel]->play(looping); + } else { + delete _music[channel]; + _music[channel] = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::stopMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + _music[channel]->stop(); + delete _music[channel]; + _music[channel] = NULL; + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::pauseMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + return _music[channel]->pause(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::resumeMusic(int channel) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + if (_music[channel]) { + return _music[channel]->resume(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::setMusicStartTime(int channel, uint32 time) { + if (channel >= NUM_MUSIC_CHANNELS) { + _gameRef->LOG(0, "**Error** Attempting to use music channel %d (max num channels: %d)", channel, NUM_MUSIC_CHANNELS); + return STATUS_FAILED; + } + + _musicStartTime[channel] = time; + if (_music[channel] && _music[channel]->isPlaying()) { + return _music[channel]->setPositionTime(time); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::loadSettings(const char *filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(SETTINGS) + TOKEN_TABLE(GAME) + TOKEN_TABLE(STRING_TABLE) + TOKEN_TABLE(RESOLUTION) + TOKEN_TABLE(REQUIRE_3D_ACCELERATION) + TOKEN_TABLE(REQUIRE_SOUND) + TOKEN_TABLE(HWTL_MODE) + TOKEN_TABLE(ALLOW_WINDOWED_MODE) + TOKEN_TABLE(ALLOW_ACCESSIBILITY_TAB) + TOKEN_TABLE(ALLOW_ABOUT_TAB) + TOKEN_TABLE(ALLOW_ADVANCED) + TOKEN_TABLE(ALLOW_DESKTOP_RES) + TOKEN_TABLE(REGISTRY_PATH) + TOKEN_TABLE(RICH_SAVED_GAMES) + TOKEN_TABLE(SAVED_GAME_EXT) + TOKEN_TABLE(GUID) + TOKEN_TABLE_END + + + byte *origBuffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (origBuffer == NULL) { + _gameRef->LOG(0, "BaseGame::LoadSettings failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret = STATUS_OK; + + byte *buffer = origBuffer; + byte *params; + int cmd; + BaseParser parser; + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SETTINGS) { + _gameRef->LOG(0, "'SETTINGS' keyword expected in game settings file."); + return STATUS_FAILED; + } + buffer = params; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_GAME: + delete[] _settingsGameFile; + _settingsGameFile = new char[strlen((char *)params) + 1]; + if (_settingsGameFile) { + strcpy(_settingsGameFile, (char *)params); + } + break; + + case TOKEN_STRING_TABLE: + if (DID_FAIL(_stringTable->loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_RESOLUTION: + parser.scanStr((char *)params, "%d,%d", &_settingsResWidth, &_settingsResHeight); + break; + + case TOKEN_REQUIRE_3D_ACCELERATION: + parser.scanStr((char *)params, "%b", &_settingsRequireAcceleration); + break; + + case TOKEN_REQUIRE_SOUND: + parser.scanStr((char *)params, "%b", &_settingsRequireSound); + break; + + case TOKEN_HWTL_MODE: + parser.scanStr((char *)params, "%d", &_settingsTLMode); + break; + + case TOKEN_ALLOW_WINDOWED_MODE: + parser.scanStr((char *)params, "%b", &_settingsAllowWindowed); + break; + + case TOKEN_ALLOW_DESKTOP_RES: + parser.scanStr((char *)params, "%b", &_settingsAllowDesktopRes); + break; + + case TOKEN_ALLOW_ADVANCED: + parser.scanStr((char *)params, "%b", &_settingsAllowAdvanced); + break; + + case TOKEN_ALLOW_ACCESSIBILITY_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAccessTab); + break; + + case TOKEN_ALLOW_ABOUT_TAB: + parser.scanStr((char *)params, "%b", &_settingsAllowAboutTab); + break; + + case TOKEN_REGISTRY_PATH: + //BaseEngine::instance().getRegistry()->setBasePath((char *)params); + break; + + case TOKEN_RICH_SAVED_GAMES: + parser.scanStr((char *)params, "%b", &_richSavedGames); + break; + + case TOKEN_SAVED_GAME_EXT: + BaseUtils::setString(&_savedGameExt, (char *)params); + break; + + case TOKEN_GUID: + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in game settings '%s'", filename); + ret = STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC) { + _gameRef->LOG(0, "Error loading game settings '%s'", filename); + ret = STATUS_FAILED; + } + + _settingsAllowWindowed = true; // TODO: These two settings should probably be cleaned out altogether. + _compressedSavegames = true; + + delete[] origBuffer; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::persist(BasePersistenceManager *persistMgr) { + if (!persistMgr->getIsSaving()) { + cleanup(); + } + + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_activeObject)); + persistMgr->transfer(TMEMBER(_capturedObject)); + persistMgr->transfer(TMEMBER(_cursorNoninteractive)); + persistMgr->transfer(TMEMBER(_editorMode)); + persistMgr->transfer(TMEMBER(_fader)); + persistMgr->transfer(TMEMBER(_freezeLevel)); + persistMgr->transfer(TMEMBER(_focusedWindow)); + persistMgr->transfer(TMEMBER(_fontStorage)); + persistMgr->transfer(TMEMBER(_interactive)); + persistMgr->transfer(TMEMBER(_keyboardState)); + persistMgr->transfer(TMEMBER(_lastTime)); + persistMgr->transfer(TMEMBER(_mainObject)); + for (int i = 0; i < NUM_MUSIC_CHANNELS; i++) { + persistMgr->transfer(TMEMBER(_music[i])); + persistMgr->transfer(TMEMBER(_musicStartTime[i])); + } + + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_offsetPercentX)); + persistMgr->transfer(TMEMBER(_offsetPercentY)); + + persistMgr->transfer(TMEMBER(_origInteractive)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_personalizedSave)); + persistMgr->transfer(TMEMBER(_quitting)); + + _regObjects.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_scEngine)); + //persistMgr->transfer(TMEMBER(_soundMgr)); + persistMgr->transfer(TMEMBER_INT(_state)); + //persistMgr->transfer(TMEMBER(_surfaceStorage)); + persistMgr->transfer(TMEMBER(_subtitles)); + persistMgr->transfer(TMEMBER(_subtitlesSpeed)); + persistMgr->transfer(TMEMBER(_systemFont)); + persistMgr->transfer(TMEMBER(_videoFont)); + persistMgr->transfer(TMEMBER(_videoSubtitles)); + + persistMgr->transfer(TMEMBER(_timer)); + persistMgr->transfer(TMEMBER(_timerDelta)); + persistMgr->transfer(TMEMBER(_timerLast)); + + persistMgr->transfer(TMEMBER(_liveTimer)); + persistMgr->transfer(TMEMBER(_liveTimerDelta)); + persistMgr->transfer(TMEMBER(_liveTimerLast)); + + persistMgr->transfer(TMEMBER(_musicCrossfadeRunning)); + persistMgr->transfer(TMEMBER(_musicCrossfadeStartTime)); + persistMgr->transfer(TMEMBER(_musicCrossfadeLength)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); + persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); + persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); + + _renderer->persistSaveLoadImages(persistMgr); + + persistMgr->transfer(TMEMBER_INT(_textEncoding)); + persistMgr->transfer(TMEMBER(_textRTL)); + + persistMgr->transfer(TMEMBER(_soundBufferSizeSec)); + persistMgr->transfer(TMEMBER(_suspendedRendering)); + + persistMgr->transfer(TMEMBER(_mouseLockRect)); + + _windows.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_suppressScriptErrors)); + persistMgr->transfer(TMEMBER(_autorunDisabled)); + + persistMgr->transfer(TMEMBER(_autoSaveOnExit)); + persistMgr->transfer(TMEMBER(_autoSaveSlot)); + persistMgr->transfer(TMEMBER(_cursorHidden)); + + if (!persistMgr->getIsSaving()) { + _quitting = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::focusWindow(UIWindow *window) { + UIWindow *prev = _focusedWindow; + + for (uint32 i = 0; i < _windows.size(); i++) { + if (_windows[i] == window) { + if (i < _windows.size() - 1) { + _windows.remove_at(i); + _windows.add(window); + + _gameRef->_focusedWindow = window; + } + + if (window->_mode == WINDOW_NORMAL && prev != window && _gameRef->validObject(prev) && (prev->_mode == WINDOW_EXCLUSIVE || prev->_mode == WINDOW_SYSTEM_EXCLUSIVE)) { + return focusWindow(prev); + } else { + return STATUS_OK; + } + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::freeze(bool includingMusic) { + if (_freezeLevel == 0) { + _scEngine->pauseAll(); + _soundMgr->pauseAll(includingMusic); + _origState = _state; + _origInteractive = _interactive; + _interactive = true; + } + _state = GAME_FROZEN; + _freezeLevel++; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::unfreeze() { + if (_freezeLevel == 0) { + return STATUS_OK; + } + + _freezeLevel--; + if (_freezeLevel == 0) { + _state = _origState; + _interactive = _origInteractive; + _scEngine->resumeAll(); + _soundMgr->resumeAll(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::handleKeypress(Common::Event *event, bool printable) { + if (isVideoPlaying()) { + if (event->kbd.keycode == Common::KEYCODE_ESCAPE) { + stopVideo(); + } + return true; + } + + if (event->type == Common::EVENT_QUIT) { + onWindowClose(); + return true; + } + + _keyboardState->handleKeyPress(event); + _keyboardState->readKey(event); +// TODO + + if (_focusedWindow) { + if (!_gameRef->_focusedWindow->handleKeypress(event, _keyboardState->_currentPrintable)) { + /*if (event->type != SDL_TEXTINPUT) {*/ + if (_gameRef->_focusedWindow->canHandleEvent("Keypress")) { + _gameRef->_focusedWindow->applyEvent("Keypress"); + } else { + applyEvent("Keypress"); + } + /*}*/ + } + return true; + } else { /*if (event->type != SDL_TEXTINPUT)*/ + applyEvent("Keypress"); + return true; + } + + return false; +} + +void BaseGame::handleKeyRelease(Common::Event *event) { + _keyboardState->handleKeyRelease(event); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::handleMouseWheel(int delta) { + bool handled = false; + if (_focusedWindow) { + handled = _gameRef->_focusedWindow->handleMouseWheel(delta); + + if (!handled) { + if (delta < 0 && _gameRef->_focusedWindow->canHandleEvent("MouseWheelDown")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelDown"); + handled = true; + } else if (_gameRef->_focusedWindow->canHandleEvent("MouseWheelUp")) { + _gameRef->_focusedWindow->applyEvent("MouseWheelUp"); + handled = true; + } + + } + } + + if (!handled) { + if (delta < 0) { + applyEvent("MouseWheelDown"); + } else { + applyEvent("MouseWheelUp"); + } + } + + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor) { + if (verMajor) { + *verMajor = DCGF_VER_MAJOR; + } + if (verMinor) { + *verMinor = DCGF_VER_MINOR; + } + + if (extMajor) { + *extMajor = 0; + } + if (extMinor) { + *extMinor = 0; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setWindowTitle() { + if (_renderer) { + char title[512]; + strcpy(title, _caption[0]); + if (title[0] != '\0') { + strcat(title, " - "); + } + strcat(title, "WME Lite"); + + + Utf8String utf8Title; + if (_textEncoding == TEXT_UTF8) { + utf8Title = Utf8String(title); + } else { + warning("BaseGame::SetWindowTitle - Ignoring textencoding"); + utf8Title = Utf8String(title); + /* WideString wstr = StringUtil::AnsiToWide(Title); + title = StringUtil::WideToUtf8(wstr);*/ + } + warning("BaseGame::SetWindowTitle: Ignoring value: %s", utf8Title.c_str()); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::setActiveObject(BaseObject *obj) { + // not-active when game is frozen + if (obj && !_gameRef->_interactive && !obj->_nonIntMouseEvents) { + obj = NULL; + } + + if (obj == _activeObject) { + return STATUS_OK; + } + + if (_activeObject) { + _activeObject->applyEvent("MouseLeave"); + } + //if (ValidObject(_activeObject)) _activeObject->applyEvent("MouseLeave"); + _activeObject = obj; + if (_activeObject) { + _activeObject->applyEvent("MouseEntry"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::pushViewport(BaseViewport *viewport) { + _viewportSP++; + if (_viewportSP >= (int32)_viewportStack.size()) { + _viewportStack.add(viewport); + } else { + _viewportStack[_viewportSP] = viewport; + } + + _renderer->setViewport(viewport->getRect()); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::popViewport() { + _viewportSP--; + if (_viewportSP < -1) { + _gameRef->LOG(0, "Fatal: Viewport stack underflow!"); + } + + if (_viewportSP >= 0 && _viewportSP < (int32)_viewportStack.size()) { + _renderer->setViewport(_viewportStack[_viewportSP]->getRect()); + } else _renderer->setViewport(_renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::getCurrentViewportRect(Rect32 *rect, bool *custom) { + if (rect == NULL) { + return STATUS_FAILED; + } else { + if (_viewportSP >= 0) { + BasePlatform::copyRect(rect, _viewportStack[_viewportSP]->getRect()); + if (custom) { + *custom = true; + } + } else { + BasePlatform::setRect(rect, _renderer->_drawOffsetX, + _renderer->_drawOffsetY, + _renderer->_width + _renderer->_drawOffsetX, + _renderer->_height + _renderer->_drawOffsetY); + if (custom) { + *custom = false; + } + } + + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::getCurrentViewportOffset(int *offsetX, int *offsetY) { + if (_viewportSP >= 0) { + if (offsetX) { + *offsetX = _viewportStack[_viewportSP]->_offsetX; + } + if (offsetY) { + *offsetY = _viewportStack[_viewportSP]->_offsetY; + } + } else { + if (offsetX) { + *offsetX = 0; + } + if (offsetY) { + *offsetY = 0; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::windowLoadHook(UIWindow *win, char **buf, char **params) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::setInteractive(bool state) { + _interactive = state; + if (_transMgr) { + _transMgr->_origInteractive = state; + } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseGame::resetMousePos() { + Common::Point p; + p.x = _mousePos.x + _renderer->_drawOffsetX; + p.y = _mousePos.y + _renderer->_drawOffsetY; + + BasePlatform::setCursorPos(p.x, p.y); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayContent(bool doUpdate, bool displayAll) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayContentSimple() { + // fill black + _renderer->fill(0, 0, 0); + _renderer->displayIndicator(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::updateMusicCrossfade() { + /* byte globMusicVol = _soundMgr->getVolumePercent(SOUND_MUSIC); */ + + if (!_musicCrossfadeRunning) { + return STATUS_OK; + } + if (_state == GAME_FROZEN) { + return STATUS_OK; + } + + if (_musicCrossfadeChannel1 < 0 || _musicCrossfadeChannel1 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel1]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + if (_musicCrossfadeChannel2 < 0 || _musicCrossfadeChannel2 >= NUM_MUSIC_CHANNELS || !_music[_musicCrossfadeChannel2]) { + _musicCrossfadeRunning = false; + return STATUS_OK; + } + + if (!_music[_musicCrossfadeChannel1]->isPlaying()) { + _music[_musicCrossfadeChannel1]->play(); + } + if (!_music[_musicCrossfadeChannel2]->isPlaying()) { + _music[_musicCrossfadeChannel2]->play(); + } + + uint32 currentTime = _gameRef->_liveTimer - _musicCrossfadeStartTime; + + if (currentTime >= _musicCrossfadeLength) { + _musicCrossfadeRunning = false; + //_music[_musicCrossfadeChannel2]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel2]->setVolumePercent(100); + + _music[_musicCrossfadeChannel1]->stop(); + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent(100); + + + if (_musicCrossfadeSwap) { + // swap channels + BaseSound *dummy = _music[_musicCrossfadeChannel1]; + int dummyInt = _musicStartTime[_musicCrossfadeChannel1]; + + _music[_musicCrossfadeChannel1] = _music[_musicCrossfadeChannel2]; + _musicStartTime[_musicCrossfadeChannel1] = _musicStartTime[_musicCrossfadeChannel2]; + + _music[_musicCrossfadeChannel2] = dummy; + _musicStartTime[_musicCrossfadeChannel2] = dummyInt; + } + } else { + //_music[_musicCrossfadeChannel1]->setVolume(GlobMusicVol - (float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + //_music[_musicCrossfadeChannel2]->setVolume((float)CurrentTime / (float)_musicCrossfadeLength * GlobMusicVol); + _music[_musicCrossfadeChannel1]->setVolumePercent((int)(100.0f - (float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + _music[_musicCrossfadeChannel2]->setVolumePercent((int)((float)currentTime / (float)_musicCrossfadeLength * 100.0f)); + + //_gameRef->QuickMessageForm("%d %d", _music[_musicCrossfadeChannel1]->GetVolume(), _music[_musicCrossfadeChannel2]->GetVolume()); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::resetContent() { + _scEngine->clearGlobals(); + //_timer = 0; + //_liveTimer = 0; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::DEBUG_DumpClassRegistry() { + warning("DEBUG_DumpClassRegistry - untested"); + Common::DumpFile *f = new Common::DumpFile; + f->open("zz_class_reg_dump.log"); + + SystemClassRegistry::getInstance()->dumpClasses(f); + + f->close(); + delete f; + _gameRef->quickMessage("Classes dump completed."); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::invalidateDeviceObjects() { + for (uint32 i = 0; i < _regObjects.size(); i++) { + _regObjects[i]->invalidateDeviceObjects(); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::restoreDeviceObjects() { + for (uint32 i = 0; i < _regObjects.size(); i++) { + _regObjects[i]->restoreDeviceObjects(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::setWaitCursor(const char *filename) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + + _cursorNoninteractive = new BaseSprite(_gameRef); + if (!_cursorNoninteractive || DID_FAIL(_cursorNoninteractive->loadFile(filename))) { + delete _cursorNoninteractive; + _cursorNoninteractive = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isVideoPlaying() { + if (_videoPlayer->isPlaying()) { + return true; + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + return true; + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::stopVideo() { + if (_videoPlayer->isPlaying()) { + _videoPlayer->stop(); + } + if (_theoraPlayer && _theoraPlayer->isPlaying()) { + _theoraPlayer->stop(); + delete _theoraPlayer; + _theoraPlayer = NULL; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::drawCursor(BaseSprite *cursor) { + if (!cursor) { + return STATUS_FAILED; + } + if (cursor != _lastCursor) { + cursor->reset(); + _lastCursor = cursor; + } + return cursor->draw(_mousePos.x, _mousePos.y); +} + + +////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onActivate(bool activate, bool refreshMouse) { + if (_shuttingDown || !_renderer) { + return STATUS_OK; + } + + _renderer->_active = activate; + + if (refreshMouse) { + Point32 p; + getMousePos(&p); + setActiveObject(_renderer->getObjectAt(p.x, p.y)); + } + + if (activate) { + _soundMgr->resumeAll(); + } else { + _soundMgr->pauseAll(); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseLeftDown() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_LEFT); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftClick"); + } + } + + if (_activeObject != NULL) { + _capturedObject = _activeObject; + } + _mouseLeftDown = true; + BasePlatform::setCapture(/*_renderer->_window*/); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseLeftUp() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_LEFT); + } + + BasePlatform::releaseCapture(); + _capturedObject = NULL; + _mouseLeftDown = false; + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseLeftDblClick() { + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } + + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_LEFT); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("LeftDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("LeftDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseRightDblClick() { + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } + + if (_activeObject) { + _activeObject->handleMouse(MOUSE_DBLCLICK, MOUSE_BUTTON_RIGHT); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightDoubleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightDoubleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseRightDown() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_RIGHT); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseRightUp() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_RIGHT); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("RightRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("RightRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseMiddleDown() { + if (_state == GAME_RUNNING && !_interactive) { + return STATUS_OK; + } + + if (_activeObject) { + _activeObject->handleMouse(MOUSE_CLICK, MOUSE_BUTTON_MIDDLE); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleClick")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleClick"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onMouseMiddleUp() { + if (_activeObject) { + _activeObject->handleMouse(MOUSE_RELEASE, MOUSE_BUTTON_MIDDLE); + } + + bool handled = _state == GAME_RUNNING && DID_SUCCEED(applyEvent("MiddleRelease")); + if (!handled) { + if (_activeObject != NULL) { + _activeObject->applyEvent("MiddleRelease"); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onPaint() { + if (_renderer && _renderer->_windowed && _renderer->_ready) { + _renderer->initLoop(); + displayContent(false, true); + displayDebugInfo(); + _renderer->windowedBlt(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onWindowClose() { + if (canHandleEvent("QuitGame")) { + if (_state != GAME_FROZEN) { + _gameRef->applyEvent("QuitGame"); + } + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::displayDebugInfo() { + char str[100]; + + if (_debugShowFPS) { + sprintf(str, "FPS: %d", _gameRef->_fps); + _systemFont->drawText((byte *)str, 0, 0, 100, TAL_LEFT); + } + + if (_gameRef->_debugDebugMode) { + if (!_gameRef->_renderer->_windowed) { + sprintf(str, "Mode: %dx%dx%d", _renderer->_width, _renderer->_height, _renderer->_bPP); + } else { + sprintf(str, "Mode: %dx%d windowed", _renderer->_width, _renderer->_height); + } + + strcat(str, " ("); + strcat(str, _renderer->getName().c_str()); + strcat(str, ")"); + _systemFont->drawText((byte *)str, 0, 0, _renderer->_width, TAL_RIGHT); + + _renderer->displayDebugInfo(); + + int scrTotal, scrRunning, scrWaiting, scrPersistent; + scrTotal = _scEngine->getNumScripts(&scrRunning, &scrWaiting, &scrPersistent); + sprintf(str, "Running scripts: %d (r:%d w:%d p:%d)", scrTotal, scrRunning, scrWaiting, scrPersistent); + _systemFont->drawText((byte *)str, 0, 70, _renderer->_width, TAL_RIGHT); + + + sprintf(str, "Timer: %d", _timer); + _gameRef->_systemFont->drawText((byte *)str, 0, 130, _renderer->_width, TAL_RIGHT); + + if (_activeObject != NULL) { + _systemFont->drawText((const byte *)_activeObject->getName(), 0, 150, _renderer->_width, TAL_RIGHT); + } + + sprintf(str, "GfxMem: %dMB", _usedMem / (1024 * 1024)); + _systemFont->drawText((byte *)str, 0, 170, _renderer->_width, TAL_RIGHT); + + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::getMousePos(Point32 *pos) { + BasePlatform::getCursorPos(pos); + + pos->x -= _renderer->_drawOffsetX; + pos->y -= _renderer->_drawOffsetY; + + /* + // Windows can squish maximized window if it's larger than desktop + // so we need to modify mouse position appropriately (tnx mRax) + if (_renderer->_windowed && ::IsZoomed(_renderer->_window)) { + Common::Rect rc; + ::GetClientRect(_renderer->_window, &rc); + Pos->x *= _gameRef->_renderer->_realWidth; + Pos->x /= (rc.right - rc.left); + Pos->y *= _gameRef->_renderer->_realHeight; + Pos->y /= (rc.bottom - rc.top); + } + */ + + if (_mouseLockRect.left != 0 && _mouseLockRect.right != 0 && _mouseLockRect.top != 0 && _mouseLockRect.bottom != 0) { + if (!BasePlatform::ptInRect(&_mouseLockRect, *pos)) { + pos->x = MAX(_mouseLockRect.left, pos->x); + pos->y = MAX(_mouseLockRect.top, pos->y); + + pos->x = MIN(_mouseLockRect.right, pos->x); + pos->y = MIN(_mouseLockRect.bottom, pos->y); + + Point32 newPos = *pos; + + newPos.x += _renderer->_drawOffsetX; + newPos.y += _renderer->_drawOffsetY; + + BasePlatform::setCursorPos(newPos.x, newPos.y); + } + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::miniUpdate() { // TODO: Is this really necessary, it used to update sound, but the mixer does that now. + if (!_miniUpdateEnabled) { + return; + } + + if (g_system->getMillis() - _lastMiniUpdate > 200) { + _lastMiniUpdate = g_system->getMillis(); + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::onScriptShutdown(ScScript *script) { + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isLeftDoubleClick() { + return isDoubleClick(0); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isRightDoubleClick() { + return isDoubleClick(1); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseGame::isDoubleClick(int buttonIndex) { + uint32 maxDoubleCLickTime = 500; + int maxMoveX = 4; + int maxMoveY = 4; + + Point32 pos; + BasePlatform::getCursorPos(&pos); + + int moveX = abs(pos.x - _lastClick[buttonIndex].posX); + int moveY = abs(pos.y - _lastClick[buttonIndex].posY); + + + if (_lastClick[buttonIndex].time == 0 || g_system->getMillis() - _lastClick[buttonIndex].time > maxDoubleCLickTime || moveX > maxMoveX || moveY > maxMoveY) { + _lastClick[buttonIndex].time = g_system->getMillis(); + _lastClick[buttonIndex].posX = pos.x; + _lastClick[buttonIndex].posY = pos.y; + return false; + } else { + _lastClick[buttonIndex].time = 0; + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::autoSaveOnExit() { + _soundMgr->saveSettings(); + ConfMan.flushToDisk(); + + if (!_autoSaveOnExit) { + return; + } + if (_state == GAME_FROZEN) { + return; + } + + saveGame(_autoSaveSlot, "autosave", true); +} + +////////////////////////////////////////////////////////////////////////// +void BaseGame::addMem(int bytes) { + _usedMem += bytes; +} + +////////////////////////////////////////////////////////////////////////// +AnsiString BaseGame::getDeviceType() const { + return "computer"; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index aecbe31722..93cbc4536b 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -1,362 +1,362 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_GAME_H -#define WINTERMUTE_BASE_GAME_H - -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/math/rect32.h" -#include "common/events.h" - -namespace Wintermute { - -typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); - -class BaseSoundMgr; -class BaseFader; -class BaseFont; -class BaseFileManager; -class BaseTransitionMgr; -class ScEngine; -class BaseFontStorage; -class BaseStringTable; -class BaseQuickMsg; -class UIWindow; -class BaseViewport; -class BaseRenderer; -class BaseRegistry; -class BaseSaveThumbHelper; -class BaseSurfaceStorage; -class SXMath; -class BaseKeyboardState; -class VideoPlayer; -class VideoTheoraPlayer; - -#define NUM_MUSIC_CHANNELS 5 - -class BaseGame: public BaseObject { -public: - DECLARE_PERSISTENT(BaseGame, BaseObject) - - virtual bool onScriptShutdown(ScScript *script); - - virtual bool onActivate(bool activate, bool refreshMouse); - virtual bool onMouseLeftDown(); - virtual bool onMouseLeftUp(); - virtual bool onMouseLeftDblClick(); - virtual bool onMouseRightDblClick(); - virtual bool onMouseRightDown(); - virtual bool onMouseRightUp(); - virtual bool onMouseMiddleDown(); - virtual bool onMouseMiddleUp(); - virtual bool onPaint(); - virtual bool onWindowClose(); - - bool isLeftDoubleClick(); - bool isRightDoubleClick(); - - bool _autorunDisabled; - - uint32 _lastMiniUpdate; - bool _miniUpdateEnabled; - - virtual void miniUpdate(); - - void getMousePos(Point32 *Pos); - Rect32 _mouseLockRect; - - bool _shuttingDown; - - virtual bool displayDebugInfo(); - bool _debugShowFPS; - - bool _suspendedRendering; - int _soundBufferSizeSec; - - TTextEncoding _textEncoding; - bool _textRTL; - - virtual bool resetContent(); - - void DEBUG_DumpClassRegistry(); - bool setWaitCursor(const char *filename); - - int _thumbnailWidth; - int _thumbnailHeight; - - bool _editorMode; - void getOffset(int *offsetX, int *offsetY); - void setOffset(int offsetX, int offsetY); - int getSequence(); - - int _offsetY; - int _offsetX; - float _offsetPercentX; - float _offsetPercentY; - BaseObject *_mainObject; - - bool initInput(); - bool initLoop(); - uint32 _currentTime; - uint32 _deltaTime; - BaseFont *_systemFont; - BaseFont *_videoFont; - bool initialize1(); - bool initialize2(); - bool initialize3(); - BaseTransitionMgr *_transMgr; - - void LOG(bool res, const char *fmt, ...); - - BaseRenderer *_renderer; - BaseSoundMgr *_soundMgr; - ScEngine *_scEngine; - SXMath *_mathClass; - BaseSurfaceStorage *_surfaceStorage; - BaseFontStorage *_fontStorage; - BaseGame(const Common::String &gameId); - virtual ~BaseGame(); - - void DEBUG_DebugDisable(); - void DEBUG_DebugEnable(const char *filename = NULL); - bool _debugDebugMode; - - void *_debugLogFile; - int _sequence; - virtual bool loadFile(const char *filename); - virtual bool loadBuffer(byte *buffer, bool complete = true); - - int _viewportSP; - - BaseStringTable *_stringTable; - int _settingsResWidth; - int _settingsResHeight; - char *_settingsGameFile; - bool _suppressScriptErrors; - bool _mouseLeftDown; // TODO: Hide - - virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - // compatibility bits - bool _compatKillMethodThreads; - - const char* getGameId() { return _gameId.c_str(); } - void setGameId(const Common::String& gameId) { _gameId = gameId; } - uint32 _surfaceGCCycleTime; - bool _smartCache; // RO - bool _subtitles; // RO - - int _scheduledLoadSlot; - bool _loading; - - virtual bool handleMouseWheel(int delta); - bool _quitting; - virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); - - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual void handleKeyRelease(Common::Event *event); - - bool unfreeze(); - bool freeze(bool includingMusic = true); - bool focusWindow(UIWindow *window); - bool _loadInProgress; - UIWindow *_focusedWindow; - bool _editorForceScripts; - - static void invalidateValues(void *value, void *data); - - bool loadSettings(const char *filename); - - bool displayWindows(bool inGame = false); - bool _useD3D; - virtual bool cleanup(); - bool loadGame(int slot); - bool loadGame(const char *filename); - bool saveGame(int slot, const char *desc, bool quickSave = false); - virtual bool showCursor(); - - BaseObject *_activeObject; - - bool _interactive; - TGameState _state; - TGameState _origState; - bool _origInteractive; - uint32 _timer; - uint32 _timerDelta; - uint32 _timerLast; - - uint32 _liveTimer; - uint32 _liveTimerDelta; - uint32 _liveTimerLast; - - BaseObject *_capturedObject; - Point32 _mousePos; - bool validObject(BaseObject *object); - bool unregisterObject(BaseObject *object); - bool registerObject(BaseObject *object); - void quickMessage(const char *text); - void quickMessageForm(char *fmt, ...); - bool displayQuickMsg(); - - virtual bool displayContent(bool update = true, bool displayAll = false); - virtual bool displayContentSimple(); - bool _forceNonStreamedSounds; - void resetMousePos(); - int _subtitlesSpeed; - void setInteractive(bool state); - virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); - virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); - bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); - bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); - bool popViewport(); - bool pushViewport(BaseViewport *Viewport); - bool setActiveObject(BaseObject *Obj); - BaseSprite *_lastCursor; - bool drawCursor(BaseSprite *Cursor); - - BaseSaveThumbHelper *_cachedThumbnail; - void addMem(int bytes); - bool _touchInterface; - bool _constrainedMemory; -protected: - BaseSprite *_loadingIcon; - int _loadingIconX; - int _loadingIconY; - int _loadingIconPersistent; - - BaseFader *_fader; - - int _freezeLevel; - VideoPlayer *_videoPlayer; - VideoTheoraPlayer *_theoraPlayer; -private: - bool _mouseRightDown; - bool _mouseMidlleDown; - bool _settingsRequireAcceleration; - bool _settingsAllowWindowed; - bool _settingsAllowAdvanced; - bool _settingsAllowAccessTab; - bool _settingsAllowAboutTab; - bool _settingsRequireSound; - bool _settingsAllowDesktopRes; - int _settingsTLMode; - virtual bool invalidateDeviceObjects(); - virtual bool restoreDeviceObjects(); - - char *_localSaveDir; - bool _saveDirChecked; - bool _richSavedGames; - char *_savedGameExt; - - bool _reportTextureFormat; - - // FPS stuff - uint32 _lastTime; - uint32 _fpsTime; - uint32 _framesRendered; - Common::String _gameId; - - void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); - ENGINE_LOG_CALLBACK _engineLogCallback; - void *_engineLogCallbackData; - - bool _videoSubtitles; - uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; - bool _compressedSavegames; - - bool _personalizedSave; - - void setWindowTitle(); - - bool resumeMusic(int channel); - bool setMusicStartTime(int channel, uint32 time); - bool pauseMusic(int channel); - bool stopMusic(int channel); - bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); - BaseSound *_music[NUM_MUSIC_CHANNELS]; - bool _musicCrossfadeRunning; - bool _musicCrossfadeSwap; - uint32 _musicCrossfadeStartTime; - uint32 _musicCrossfadeLength; - int _musicCrossfadeChannel1; - int _musicCrossfadeChannel2; - - BaseSprite *_cursorNoninteractive; - BaseKeyboardState *_keyboardState; - - uint32 _fps; - bool updateMusicCrossfade(); - - bool isVideoPlaying(); - bool stopVideo(); - - BaseArray _quickMessages; - BaseArray _windows; - BaseArray _viewportStack; - BaseArray _regObjects; - - AnsiString getDeviceType() const; - - struct LastClickInfo { - LastClickInfo() { - posX = posY = 0; - time = 0; - } - - int posX; - int posY; - uint32 time; - }; - - LastClickInfo _lastClick[2]; - bool isDoubleClick(int buttonIndex); - uint32 _usedMem; - - - -protected: - // WME Lite specific - bool _autoSaveOnExit; - int _autoSaveSlot; - bool _cursorHidden; - -public: - void autoSaveOnExit(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_GAME_H +#define WINTERMUTE_BASE_GAME_H + +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/math/rect32.h" +#include "common/events.h" + +namespace Wintermute { + +typedef void (*ENGINE_LOG_CALLBACK)(char *text, bool result, void *data); + +class BaseSoundMgr; +class BaseFader; +class BaseFont; +class BaseFileManager; +class BaseTransitionMgr; +class ScEngine; +class BaseFontStorage; +class BaseStringTable; +class BaseQuickMsg; +class UIWindow; +class BaseViewport; +class BaseRenderer; +class BaseRegistry; +class BaseSaveThumbHelper; +class BaseSurfaceStorage; +class SXMath; +class BaseKeyboardState; +class VideoPlayer; +class VideoTheoraPlayer; + +#define NUM_MUSIC_CHANNELS 5 + +class BaseGame: public BaseObject { +public: + DECLARE_PERSISTENT(BaseGame, BaseObject) + + virtual bool onScriptShutdown(ScScript *script); + + virtual bool onActivate(bool activate, bool refreshMouse); + virtual bool onMouseLeftDown(); + virtual bool onMouseLeftUp(); + virtual bool onMouseLeftDblClick(); + virtual bool onMouseRightDblClick(); + virtual bool onMouseRightDown(); + virtual bool onMouseRightUp(); + virtual bool onMouseMiddleDown(); + virtual bool onMouseMiddleUp(); + virtual bool onPaint(); + virtual bool onWindowClose(); + + bool isLeftDoubleClick(); + bool isRightDoubleClick(); + + bool _autorunDisabled; + + uint32 _lastMiniUpdate; + bool _miniUpdateEnabled; + + virtual void miniUpdate(); + + void getMousePos(Point32 *Pos); + Rect32 _mouseLockRect; + + bool _shuttingDown; + + virtual bool displayDebugInfo(); + bool _debugShowFPS; + + bool _suspendedRendering; + int _soundBufferSizeSec; + + TTextEncoding _textEncoding; + bool _textRTL; + + virtual bool resetContent(); + + void DEBUG_DumpClassRegistry(); + bool setWaitCursor(const char *filename); + + int _thumbnailWidth; + int _thumbnailHeight; + + bool _editorMode; + void getOffset(int *offsetX, int *offsetY); + void setOffset(int offsetX, int offsetY); + int getSequence(); + + int _offsetY; + int _offsetX; + float _offsetPercentX; + float _offsetPercentY; + BaseObject *_mainObject; + + bool initInput(); + bool initLoop(); + uint32 _currentTime; + uint32 _deltaTime; + BaseFont *_systemFont; + BaseFont *_videoFont; + bool initialize1(); + bool initialize2(); + bool initialize3(); + BaseTransitionMgr *_transMgr; + + void LOG(bool res, const char *fmt, ...); + + BaseRenderer *_renderer; + BaseSoundMgr *_soundMgr; + ScEngine *_scEngine; + SXMath *_mathClass; + BaseSurfaceStorage *_surfaceStorage; + BaseFontStorage *_fontStorage; + BaseGame(const Common::String &gameId); + virtual ~BaseGame(); + + void DEBUG_DebugDisable(); + void DEBUG_DebugEnable(const char *filename = NULL); + bool _debugDebugMode; + + void *_debugLogFile; + int _sequence; + virtual bool loadFile(const char *filename); + virtual bool loadBuffer(byte *buffer, bool complete = true); + + int _viewportSP; + + BaseStringTable *_stringTable; + int _settingsResWidth; + int _settingsResHeight; + char *_settingsGameFile; + bool _suppressScriptErrors; + bool _mouseLeftDown; // TODO: Hide + + virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + // compatibility bits + bool _compatKillMethodThreads; + + const char* getGameId() { return _gameId.c_str(); } + void setGameId(const Common::String& gameId) { _gameId = gameId; } + uint32 _surfaceGCCycleTime; + bool _smartCache; // RO + bool _subtitles; // RO + + int _scheduledLoadSlot; + bool _loading; + + virtual bool handleMouseWheel(int delta); + bool _quitting; + virtual bool getVersion(byte *verMajor, byte *verMinor, byte *extMajor, byte *extMinor); + + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual void handleKeyRelease(Common::Event *event); + + bool unfreeze(); + bool freeze(bool includingMusic = true); + bool focusWindow(UIWindow *window); + bool _loadInProgress; + UIWindow *_focusedWindow; + bool _editorForceScripts; + + static void invalidateValues(void *value, void *data); + + bool loadSettings(const char *filename); + + bool displayWindows(bool inGame = false); + bool _useD3D; + virtual bool cleanup(); + bool loadGame(int slot); + bool loadGame(const char *filename); + bool saveGame(int slot, const char *desc, bool quickSave = false); + virtual bool showCursor(); + + BaseObject *_activeObject; + + bool _interactive; + TGameState _state; + TGameState _origState; + bool _origInteractive; + uint32 _timer; + uint32 _timerDelta; + uint32 _timerLast; + + uint32 _liveTimer; + uint32 _liveTimerDelta; + uint32 _liveTimerLast; + + BaseObject *_capturedObject; + Point32 _mousePos; + bool validObject(BaseObject *object); + bool unregisterObject(BaseObject *object); + bool registerObject(BaseObject *object); + void quickMessage(const char *text); + void quickMessageForm(char *fmt, ...); + bool displayQuickMsg(); + + virtual bool displayContent(bool update = true, bool displayAll = false); + virtual bool displayContentSimple(); + bool _forceNonStreamedSounds; + void resetMousePos(); + int _subtitlesSpeed; + void setInteractive(bool state); + virtual bool windowLoadHook(UIWindow *win, char **buf, char **params); + virtual bool windowScriptMethodHook(UIWindow *win, ScScript *script, ScStack *stack, const char *name); + bool getCurrentViewportOffset(int *offsetX = NULL, int *offsetY = NULL); + bool getCurrentViewportRect(Rect32 *rect, bool *custom = NULL); + bool popViewport(); + bool pushViewport(BaseViewport *Viewport); + bool setActiveObject(BaseObject *Obj); + BaseSprite *_lastCursor; + bool drawCursor(BaseSprite *Cursor); + + BaseSaveThumbHelper *_cachedThumbnail; + void addMem(int bytes); + bool _touchInterface; + bool _constrainedMemory; +protected: + BaseSprite *_loadingIcon; + int _loadingIconX; + int _loadingIconY; + int _loadingIconPersistent; + + BaseFader *_fader; + + int _freezeLevel; + VideoPlayer *_videoPlayer; + VideoTheoraPlayer *_theoraPlayer; +private: + bool _mouseRightDown; + bool _mouseMidlleDown; + bool _settingsRequireAcceleration; + bool _settingsAllowWindowed; + bool _settingsAllowAdvanced; + bool _settingsAllowAccessTab; + bool _settingsAllowAboutTab; + bool _settingsRequireSound; + bool _settingsAllowDesktopRes; + int _settingsTLMode; + virtual bool invalidateDeviceObjects(); + virtual bool restoreDeviceObjects(); + + char *_localSaveDir; + bool _saveDirChecked; + bool _richSavedGames; + char *_savedGameExt; + + bool _reportTextureFormat; + + // FPS stuff + uint32 _lastTime; + uint32 _fpsTime; + uint32 _framesRendered; + Common::String _gameId; + + void setEngineLogCallback(ENGINE_LOG_CALLBACK callback = NULL, void *data = NULL); + ENGINE_LOG_CALLBACK _engineLogCallback; + void *_engineLogCallbackData; + + bool _videoSubtitles; + uint32 _musicStartTime[NUM_MUSIC_CHANNELS]; + bool _compressedSavegames; + + bool _personalizedSave; + + void setWindowTitle(); + + bool resumeMusic(int channel); + bool setMusicStartTime(int channel, uint32 time); + bool pauseMusic(int channel); + bool stopMusic(int channel); + bool playMusic(int channel, const char *filename, bool looping = true, uint32 loopStart = 0); + BaseSound *_music[NUM_MUSIC_CHANNELS]; + bool _musicCrossfadeRunning; + bool _musicCrossfadeSwap; + uint32 _musicCrossfadeStartTime; + uint32 _musicCrossfadeLength; + int _musicCrossfadeChannel1; + int _musicCrossfadeChannel2; + + BaseSprite *_cursorNoninteractive; + BaseKeyboardState *_keyboardState; + + uint32 _fps; + bool updateMusicCrossfade(); + + bool isVideoPlaying(); + bool stopVideo(); + + BaseArray _quickMessages; + BaseArray _windows; + BaseArray _viewportStack; + BaseArray _regObjects; + + AnsiString getDeviceType() const; + + struct LastClickInfo { + LastClickInfo() { + posX = posY = 0; + time = 0; + } + + int posX; + int posY; + uint32 time; + }; + + LastClickInfo _lastClick[2]; + bool isDoubleClick(int buttonIndex); + uint32 _usedMem; + + + +protected: + // WME Lite specific + bool _autoSaveOnExit; + int _autoSaveSlot; + bool _cursorHidden; + +public: + void autoSaveOnExit(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index d5c2027a0d..fd5f2b0e1d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -1,309 +1,309 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_keyboard_state.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "common/system.h" -#include "common/keyboard.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseKeyboardState, false) - -////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(inGame) { - _currentPrintable = false; - _currentCharCode = 0; - _currentKeyData = 0; - - _currentShift = false; - _currentAlt = false; - _currentControl = false; - - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -BaseKeyboardState::~BaseKeyboardState() { - delete[] _keyStates; -} - -void BaseKeyboardState::handleKeyPress(Common::Event *event) { - if (event->type == Common::EVENT_KEYDOWN) { - _keyStates[event->kbd.keycode] = true; - } -} - -void BaseKeyboardState::handleKeyRelease(Common::Event *event) { - if (event->type == Common::EVENT_KEYUP) { - _keyStates[event->kbd.keycode] = false; - } -} - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // IsKeyDown - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "IsKeyDown") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - int vKey; - - if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { - const char *str = val->getString(); - char temp = str[0]; - if (temp >= 'A' && temp <= 'Z') { - temp += ('a' - 'A'); - } - vKey = (int)temp; - } else { - vKey = val->getInt(); - } - - bool isDown = _keyStates[vKeyToKeyCode(vKey)]; - - stack->pushBool(isDown); - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseKeyboardState::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("keyboard"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Key - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { - if (_currentPrintable) { - char key[2]; - key[0] = (char)_currentCharCode; - key[1] = '\0'; - _scValue->setString(key); - } else { - _scValue->setString(""); - } - - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Printable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { - _scValue->setBool(_currentPrintable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // KeyCode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { - _scValue->setInt(_currentCharCode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsShift - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { - _scValue->setBool(_currentShift); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsAlt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { - _scValue->setBool(_currentAlt); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // IsControl - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { - _scValue->setBool(_currentControl); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - if (_renderer) SetWindowText(_renderer->_window, _name); - return STATUS_OK; - } - - else*/ return BaseScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseKeyboardState::scToString() { - return "[keyboard state]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::readKey(Common::Event *event) { - //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO - _currentCharCode = keyCodeToVKey(event); - if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || - (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0) || - (_currentCharCode == Common::KEYCODE_SPACE)) { - _currentPrintable = true; - } else { - _currentPrintable = false; - } - //_currentKeyData = KeyData; - - _currentControl = isControlDown(); - _currentAlt = isAltDown(); - _currentShift = isShiftDown(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { - //if (!persistMgr->getIsSaving()) cleanup(); - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_currentAlt)); - persistMgr->transfer(TMEMBER(_currentCharCode)); - persistMgr->transfer(TMEMBER(_currentControl)); - persistMgr->transfer(TMEMBER(_currentKeyData)); - persistMgr->transfer(TMEMBER(_currentPrintable)); - persistMgr->transfer(TMEMBER(_currentShift)); - - if (!persistMgr->getIsSaving()) { - _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum - for (int i = 0; i < 323; i++) { - _keyStates[i] = false; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::isShiftDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_SHIFT); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::isControlDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_CTRL); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseKeyboardState::isAltDown() { - int mod = g_system->getEventManager()->getModifierState(); - return (mod & Common::KBD_ALT); -} - -////////////////////////////////////////////////////////////////////////// -uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { - if (event->type != Common::EVENT_KEYDOWN) { - return 0; - } - - switch (event->kbd.keycode) { - case Common::KEYCODE_KP_ENTER: - return Common::KEYCODE_RETURN; - default: - return (uint32)event->kbd.keycode; - } -} - -enum VKeyCodes { - kVkSpace = 32, - kVkLeft = 37, - kVkUp = 38, - kVkRight = 39, - kVkDown = 40 -}; - -////////////////////////////////////////////////////////////////////////// -Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { - // todo - switch (vkey) { - case kVkSpace: - return Common::KEYCODE_SPACE; - break; - case kVkLeft: - return Common::KEYCODE_LEFT; - break; - case kVkRight: - return Common::KEYCODE_RIGHT; - break; - case kVkUp: - return Common::KEYCODE_UP; - break; - case kVkDown: - return Common::KEYCODE_DOWN; - break; - default: - warning("Unknown VKEY: %d", vkey); - return (Common::KeyCode)vkey; - break; - } - -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_keyboard_state.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/system.h" +#include "common/keyboard.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseKeyboardState, false) + +////////////////////////////////////////////////////////////////////////// +BaseKeyboardState::BaseKeyboardState(BaseGame *inGame) : BaseScriptable(inGame) { + _currentPrintable = false; + _currentCharCode = 0; + _currentKeyData = 0; + + _currentShift = false; + _currentAlt = false; + _currentControl = false; + + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +BaseKeyboardState::~BaseKeyboardState() { + delete[] _keyStates; +} + +void BaseKeyboardState::handleKeyPress(Common::Event *event) { + if (event->type == Common::EVENT_KEYDOWN) { + _keyStates[event->kbd.keycode] = true; + } +} + +void BaseKeyboardState::handleKeyRelease(Common::Event *event) { + if (event->type == Common::EVENT_KEYUP) { + _keyStates[event->kbd.keycode] = false; + } +} + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // IsKeyDown + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "IsKeyDown") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + int vKey; + + if (val->_type == VAL_STRING && strlen(val->getString()) > 0) { + const char *str = val->getString(); + char temp = str[0]; + if (temp >= 'A' && temp <= 'Z') { + temp += ('a' - 'A'); + } + vKey = (int)temp; + } else { + vKey = val->getInt(); + } + + bool isDown = _keyStates[vKeyToKeyCode(vKey)]; + + stack->pushBool(isDown); + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseKeyboardState::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("keyboard"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Key + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Key") == 0) { + if (_currentPrintable) { + char key[2]; + key[0] = (char)_currentCharCode; + key[1] = '\0'; + _scValue->setString(key); + } else { + _scValue->setString(""); + } + + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Printable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Printable") == 0) { + _scValue->setBool(_currentPrintable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // KeyCode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "KeyCode") == 0) { + _scValue->setInt(_currentCharCode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsShift + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsShift") == 0) { + _scValue->setBool(_currentShift); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsAlt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsAlt") == 0) { + _scValue->setBool(_currentAlt); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // IsControl + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsControl") == 0) { + _scValue->setBool(_currentControl); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + if (_renderer) SetWindowText(_renderer->_window, _name); + return STATUS_OK; + } + + else*/ return BaseScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseKeyboardState::scToString() { + return "[keyboard state]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::readKey(Common::Event *event) { + //_currentPrintable = (event->type == SDL_TEXTINPUT); // TODO + _currentCharCode = keyCodeToVKey(event); + if ((_currentCharCode <= Common::KEYCODE_z && _currentCharCode >= Common::KEYCODE_a) || + (_currentCharCode <= Common::KEYCODE_9 && _currentCharCode >= Common::KEYCODE_0) || + (_currentCharCode == Common::KEYCODE_SPACE)) { + _currentPrintable = true; + } else { + _currentPrintable = false; + } + //_currentKeyData = KeyData; + + _currentControl = isControlDown(); + _currentAlt = isAltDown(); + _currentShift = isShiftDown(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::persist(BasePersistenceManager *persistMgr) { + //if (!persistMgr->getIsSaving()) cleanup(); + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_currentAlt)); + persistMgr->transfer(TMEMBER(_currentCharCode)); + persistMgr->transfer(TMEMBER(_currentControl)); + persistMgr->transfer(TMEMBER(_currentKeyData)); + persistMgr->transfer(TMEMBER(_currentPrintable)); + persistMgr->transfer(TMEMBER(_currentShift)); + + if (!persistMgr->getIsSaving()) { + _keyStates = new uint8[323]; // Hardcoded size for the common/keyboard.h enum + for (int i = 0; i < 323; i++) { + _keyStates[i] = false; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::isShiftDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_SHIFT); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::isControlDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_CTRL); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseKeyboardState::isAltDown() { + int mod = g_system->getEventManager()->getModifierState(); + return (mod & Common::KBD_ALT); +} + +////////////////////////////////////////////////////////////////////////// +uint32 BaseKeyboardState::keyCodeToVKey(Common::Event *event) { + if (event->type != Common::EVENT_KEYDOWN) { + return 0; + } + + switch (event->kbd.keycode) { + case Common::KEYCODE_KP_ENTER: + return Common::KEYCODE_RETURN; + default: + return (uint32)event->kbd.keycode; + } +} + +enum VKeyCodes { + kVkSpace = 32, + kVkLeft = 37, + kVkUp = 38, + kVkRight = 39, + kVkDown = 40 +}; + +////////////////////////////////////////////////////////////////////////// +Common::KeyCode BaseKeyboardState::vKeyToKeyCode(uint32 vkey) { + // todo + switch (vkey) { + case kVkSpace: + return Common::KEYCODE_SPACE; + break; + case kVkLeft: + return Common::KEYCODE_LEFT; + break; + case kVkRight: + return Common::KEYCODE_RIGHT; + break; + case kVkUp: + return Common::KEYCODE_UP; + break; + case kVkDown: + return Common::KEYCODE_DOWN; + break; + default: + warning("Unknown VKEY: %d", vkey); + return (Common::KeyCode)vkey; + break; + } + +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index 4b1826d483..ebc0c83ee1 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -1,75 +1,75 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H -#define WINTERMUTE_BASE_KEYBOARD_STATE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/base_scriptable.h" -#include "common/keyboard.h" -#include "common/events.h" - -namespace Wintermute { - -class BaseKeyboardState : public BaseScriptable { -public: - uint32 _currentKeyData; - uint32 _currentCharCode; - bool _currentPrintable; - - bool _currentShift; - bool _currentAlt; - bool _currentControl; - - DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) - BaseKeyboardState(BaseGame *inGame); - virtual ~BaseKeyboardState(); - bool readKey(Common::Event *event); - - void handleKeyPress(Common::Event *event); - void handleKeyRelease(Common::Event *event); - static bool isShiftDown(); - static bool isControlDown(); - static bool isAltDown(); - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - -private: - uint8 *_keyStates; - uint32 keyCodeToVKey(Common::Event *event); - Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H +#define WINTERMUTE_BASE_KEYBOARD_STATE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" +#include "common/keyboard.h" +#include "common/events.h" + +namespace Wintermute { + +class BaseKeyboardState : public BaseScriptable { +public: + uint32 _currentKeyData; + uint32 _currentCharCode; + bool _currentPrintable; + + bool _currentShift; + bool _currentAlt; + bool _currentControl; + + DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) + BaseKeyboardState(BaseGame *inGame); + virtual ~BaseKeyboardState(); + bool readKey(Common::Event *event); + + void handleKeyPress(Common::Event *event); + void handleKeyRelease(Common::Event *event); + static bool isShiftDown(); + static bool isControlDown(); + static bool isAltDown(); + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + +private: + uint8 *_keyStates; + uint32 keyCodeToVKey(Common::Event *event); + Common::KeyCode vKeyToKeyCode(uint32 vkey); //TODO, reimplement using ScummVM-backend +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_named_object.cpp b/engines/wintermute/base/base_named_object.cpp index d95dd3e25b..915bf24d7f 100644 --- a/engines/wintermute/base/base_named_object.cpp +++ b/engines/wintermute/base/base_named_object.cpp @@ -1,71 +1,71 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_named_object.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject() : BaseClass() { - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { - _name = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseNamedObject::~BaseNamedObject(void) { - delete[] _name; - _name = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void BaseNamedObject::setName(const char *name) { - delete[] _name; - _name = NULL; - - if (name == NULL) { - return; - } - - _name = new char [strlen(name) + 1]; - if (_name != NULL) { - strcpy(_name, name); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_named_object.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject(BaseGame *inGame) : BaseClass(inGame) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject() : BaseClass() { + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::BaseNamedObject(TDynamicConstructor, TDynamicConstructor) { + _name = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseNamedObject::~BaseNamedObject(void) { + delete[] _name; + _name = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void BaseNamedObject::setName(const char *name) { + delete[] _name; + _name = NULL; + + if (name == NULL) { + return; + } + + _name = new char [strlen(name) + 1]; + if (_name != NULL) { + strcpy(_name, name); + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_named_object.h b/engines/wintermute/base/base_named_object.h index 9818708605..77a00cee45 100644 --- a/engines/wintermute/base/base_named_object.h +++ b/engines/wintermute/base/base_named_object.h @@ -1,51 +1,51 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_NAMED_OBJECT_H -#define WINTERMUTE_BASE_NAMED_OBJECT_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseNamedObject : public BaseClass { - char *_name; -public: - BaseNamedObject(BaseGame *inGame); - BaseNamedObject(); - virtual ~BaseNamedObject(void); - BaseNamedObject(TDynamicConstructor, TDynamicConstructor); - - const char *getName() { return _name; } - void setName(const char *name); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_NAMED_OBJECT_H +#define WINTERMUTE_BASE_NAMED_OBJECT_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseNamedObject : public BaseClass { + char *_name; +public: + BaseNamedObject(BaseGame *inGame); + BaseNamedObject(); + virtual ~BaseNamedObject(void); + BaseNamedObject(TDynamicConstructor, TDynamicConstructor); + + const char *getName() { return _name; } + void setName(const char *name); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index ff8fcd0bf2..b6a6887624 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -1,1246 +1,1246 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_string_table.h" -#include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/platform_osystem.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseObject, false) - -////////////////////////////////////////////////////////////////////// -BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { - _posX = _posY = 0; - _movable = true; - _zoomable = true; - _registrable = true; - _shadowable = true; - _rotatable = false; - _is3D = false; - - _alphaColor = 0; - _scale = -1; - _relativeScale = 0; - - _scaleX = -1; - _scaleY = -1; - - _ready = true; - - _soundEvent = NULL; - - _iD = _gameRef->getSequence(); - - BasePlatform::setRectEmpty(&_rect); - _rectSet = false; - - _cursor = NULL; - _activeCursor = NULL; - _sharedCursors = false; - - _sFX = NULL; - _sFXStart = 0; - _sFXVolume = 100; - _autoSoundPanning = true; - - _editorAlwaysRegister = false; - _editorSelected = false; - - _editorOnly = false; - - _rotate = 0.0f; - _rotateValid = false; - _relativeRotate = 0.0f; - - for (int i = 0; i < 7; i++) { - _caption[i] = NULL; - } - _saveState = true; - - _nonIntMouseEvents = false; - - // sound FX - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - _blendMode = BLEND_NORMAL; -} - - -////////////////////////////////////////////////////////////////////// -BaseObject::~BaseObject() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::cleanup() { - if (_gameRef && _gameRef->_activeObject == this) { - _gameRef->_activeObject = NULL; - } - - BaseScriptHolder::cleanup(); - delete[] _soundEvent; - _soundEvent = NULL; - - if (!_sharedCursors) { - delete _cursor; - delete _activeCursor; - _cursor = NULL; - _activeCursor = NULL; - } - delete _sFX; - _sFX = NULL; - - for (int i = 0; i < 7; i++) { - delete[] _caption[i]; - _caption[i] = NULL; - } - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseObject::setCaption(const char *caption, int caseVal) { - if (caseVal == 0) { - caseVal = 1; - } - if (caseVal < 1 || caseVal > 7) { - return; - } - - delete[] _caption[caseVal - 1]; - _caption[caseVal - 1] = new char[strlen(caption) + 1]; - if (_caption[caseVal - 1]) { - strcpy(_caption[caseVal - 1], caption); - _gameRef->_stringTable->expand(&_caption[caseVal - 1]); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseObject::getCaption(int caseVal) { - if (caseVal == 0) { - caseVal = 1; - } - if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { - return ""; - } else { - return _caption[caseVal - 1]; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // SkipTo - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SkipTo") == 0) { - stack->correctParams(2); - _posX = stack->pop()->getInt(); - _posY = stack->pop()->getInt(); - afterMove(); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - stack->correctParams(1); - stack->pushString(getCaption(stack->pop()->getInt())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCursor") == 0) { - stack->correctParams(1); - if (DID_SUCCEED(setCursor(stack->pop()->getString()))) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveCursor") == 0) { - stack->correctParams(0); - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } else { - _cursor = NULL; - - } - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursor") == 0) { - stack->correctParams(0); - if (!_cursor || !_cursor->getFilename()) { - stack->pushNULL(); - } else { - stack->pushString(_cursor->getFilename()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetCursorObject - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetCursorObject") == 0) { - stack->correctParams(0); - if (!_cursor) { - stack->pushNULL(); - } else { - stack->pushNative(_cursor, true); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HasCursor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HasCursor") == 0) { - stack->correctParams(0); - - if (_cursor) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCaption") == 0) { - stack->correctParams(2); - setCaption(stack->pop()->getString(), stack->pop()->getInt()); - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LoadSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LoadSound") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - if (DID_SUCCEED(playSFX(filename, false, false))) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySound") == 0) { - stack->correctParams(3); - - const char *filename; - bool looping; - uint32 loopStart; - - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - ScValue *val3 = stack->pop(); - - if (val1->_type == VAL_BOOL) { - filename = NULL; - looping = val1->getBool(); - loopStart = val2->getInt(); - } else { - if (val1->isNULL()) { - filename = NULL; - } else { - filename = val1->getString(); - } - looping = val2->isNULL() ? false : val2->getBool(); - loopStart = val3->getInt(); - } - - if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PlaySoundEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PlaySoundEvent") == 0) { - stack->correctParams(2); - - const char *filename; - const char *eventName; - - ScValue *val1 = stack->pop(); - ScValue *val2 = stack->pop(); - - if (val2->isNULL()) { - filename = NULL; - eventName = val1->getString(); - } else { - filename = val1->getString(); - eventName = val2->getString(); - } - - if (DID_FAIL(playSFX(filename, false, true, eventName))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // StopSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "StopSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(stopSFX())) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PauseSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PauseSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(pauseSFX())) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ResumeSound - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ResumeSound") == 0) { - stack->correctParams(0); - - if (DID_FAIL(resumeSFX())) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsSoundPlaying - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsSoundPlaying") == 0) { - stack->correctParams(0); - - if (_sFX && _sFX->isPlaying()) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundPosition") == 0) { - stack->correctParams(1); - - uint32 time = stack->pop()->getInt(); - if (DID_FAIL(setSFXTime(time))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundPosition") == 0) { - stack->correctParams(0); - - if (!_sFX) { - stack->pushInt(0); - } else { - stack->pushInt(_sFX->getPositionTime()); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSoundVolume") == 0) { - stack->correctParams(1); - - int volume = stack->pop()->getInt(); - if (DID_FAIL(setSFXVolume(volume))) { - stack->pushBool(false); - } else { - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetSoundVolume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSoundVolume") == 0) { - stack->correctParams(0); - - if (!_sFX) { - stack->pushInt(_sFXVolume); - } else { - stack->pushInt(_sFX->getVolumePercent()); - } - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SoundFXNone - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXNone") == 0) { - stack->correctParams(0); - _sFXType = SFX_NONE; - _sFXParam1 = 0; - _sFXParam2 = 0; - _sFXParam3 = 0; - _sFXParam4 = 0; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXEcho - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXEcho") == 0) { - stack->correctParams(4); - _sFXType = SFX_ECHO; - _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) - _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) - _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundFXReverb - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundFXReverb") == 0) { - stack->correctParams(4); - _sFXType = SFX_REVERB; - _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) - _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) - _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) - _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) - stack->pushNULL(); - - return STATUS_OK; - } else { - return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseObject::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("object"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { - _scValue->setString(getCaption(1)); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Height (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(getHeight()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Ready (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { - _scValue->setBool(_ready); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _scValue->setBool(_movable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _scValue->setBool(_registrable); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _scValue->setBool(_zoomable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _scValue->setBool(_rotatable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _scValue->setInt((int)_alphaColor); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - _scValue->setInt((int)_blendMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (_scale < 0) { - _scValue->setNULL(); - } else { - _scValue->setFloat((double)_scale); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (_scaleX < 0) { - _scValue->setNULL(); - } else { - _scValue->setFloat((double)_scaleX); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (_scaleY < 0) { - _scValue->setNULL(); - } else { - _scValue->setFloat((double)_scaleY); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _scValue->setFloat((double)_relativeScale); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (!_rotateValid) { - _scValue->setNULL(); - } else { - _scValue->setFloat((double)_rotate); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _scValue->setFloat((double)_relativeRotate); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _scValue->setBool(_shadowable); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _scValue->setBool(_autoSoundPanning); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _scValue->setBool(_saveState); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _scValue->setBool(_nonIntMouseEvents); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - _scValue->setNULL(); - return _scValue; - } else { - return BaseScriptHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Caption - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Caption") == 0) { - setCaption(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - afterMove(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Movable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { - _movable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Registrable/Interactive - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { - _registrable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Zoomable/Scalable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { - _zoomable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotatable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { - _rotatable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - _alphaColor = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // BlendMode - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { - int i = value->getInt(); - if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) { - i = BLEND_NORMAL; - } - _blendMode = (TSpriteBlendMode)i; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { - if (value->isNULL()) { - _scale = -1; - } else { - _scale = (float)value->getFloat(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { - if (value->isNULL()) { - _scaleX = -1; - } else { - _scaleX = (float)value->getFloat(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ScaleY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { - if (value->isNULL()) { - _scaleY = -1; - } else { - _scaleY = (float)value->getFloat(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeScale - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { - _relativeScale = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { - if (value->isNULL()) { - _rotate = 0.0f; - _rotateValid = false; - } else { - _rotate = (float)value->getFloat(); - _rotateValid = true; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RelativeRotate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { - _relativeRotate = (float)value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Colorable - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { - _shadowable = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SoundPanning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { - _autoSoundPanning = value->getBool(); - if (!_autoSoundPanning) { - resetSoundPan(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SaveState - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { - _saveState = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // NonIntMouseEvents - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { - _nonIntMouseEvents = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AccCaption - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { - return STATUS_OK; - } else { - return BaseScriptHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseObject::scToString() { - return "[object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::showCursor() { - if (_cursor) { - return _gameRef->drawCursor(_cursor); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::persist(BasePersistenceManager *persistMgr) { - BaseScriptHolder::persist(persistMgr); - - for (int i = 0; i < 7; i++) { - persistMgr->transfer(TMEMBER(_caption[i])); - } - persistMgr->transfer(TMEMBER(_activeCursor)); - persistMgr->transfer(TMEMBER(_alphaColor)); - persistMgr->transfer(TMEMBER(_autoSoundPanning)); - persistMgr->transfer(TMEMBER(_cursor)); - persistMgr->transfer(TMEMBER(_sharedCursors)); - persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); - persistMgr->transfer(TMEMBER(_editorOnly)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_iD)); - persistMgr->transfer(TMEMBER(_is3D)); - persistMgr->transfer(TMEMBER(_movable)); - persistMgr->transfer(TMEMBER(_posX)); - persistMgr->transfer(TMEMBER(_posY)); - persistMgr->transfer(TMEMBER(_relativeScale)); - persistMgr->transfer(TMEMBER(_rotatable)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_sFX)); - persistMgr->transfer(TMEMBER(_sFXStart)); - persistMgr->transfer(TMEMBER(_sFXVolume)); - persistMgr->transfer(TMEMBER(_ready)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_rectSet)); - persistMgr->transfer(TMEMBER(_registrable)); - persistMgr->transfer(TMEMBER(_shadowable)); - persistMgr->transfer(TMEMBER(_soundEvent)); - persistMgr->transfer(TMEMBER(_zoomable)); - - persistMgr->transfer(TMEMBER(_scaleX)); - persistMgr->transfer(TMEMBER(_scaleY)); - - persistMgr->transfer(TMEMBER(_rotate)); - persistMgr->transfer(TMEMBER(_rotateValid)); - persistMgr->transfer(TMEMBER(_relativeRotate)); - - persistMgr->transfer(TMEMBER(_saveState)); - persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); - - persistMgr->transfer(TMEMBER_INT(_sFXType)); - persistMgr->transfer(TMEMBER(_sFXParam1)); - persistMgr->transfer(TMEMBER(_sFXParam2)); - persistMgr->transfer(TMEMBER(_sFXParam3)); - persistMgr->transfer(TMEMBER(_sFXParam4)); - - - persistMgr->transfer(TMEMBER_INT(_blendMode)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setCursor(const char *filename) { - if (!_sharedCursors) { - delete _cursor; - _cursor = NULL; - } - - _sharedCursors = false; - _cursor = new BaseSprite(_gameRef); - if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { - delete _cursor; - _cursor = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setActiveCursor(const char *filename) { - delete _activeCursor; - _activeCursor = new BaseSprite(_gameRef); - if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { - delete _activeCursor; - _activeCursor = NULL; - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -int BaseObject::getHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleKeypress(Common::Event *event, bool printable) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::handleMouseWheel(int delta) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { - // just play loaded sound - if (filename == NULL && _sFX) { - if (_gameRef->_editorMode || _sFXStart) { - _sFX->setVolumePercent(_sFXVolume); - _sFX->setPositionTime(_sFXStart); - if (!_gameRef->_editorMode) { - _sFXStart = 0; - } - } - if (playNow) { - setSoundEvent(eventName); - if (loopStart) { - _sFX->setLoopStart(loopStart); - } - return _sFX->play(looping); - } else { - return STATUS_OK; - } - } - - if (filename == NULL) { - return STATUS_FAILED; - } - - // create new sound - delete _sFX; - - _sFX = new BaseSound(_gameRef); - if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { - _sFX->setVolumePercent(_sFXVolume); - if (_sFXStart) { - _sFX->setPositionTime(_sFXStart); - _sFXStart = 0; - } - _sFX->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - if (playNow) { - setSoundEvent(eventName); - if (loopStart) { - _sFX->setLoopStart(loopStart); - } - return _sFX->play(looping); - } else { - return STATUS_OK; - } - } else { - delete _sFX; - _sFX = NULL; - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::stopSFX(bool deleteSound) { - if (_sFX) { - _sFX->stop(); - if (deleteSound) { - delete _sFX; - _sFX = NULL; - } - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::pauseSFX() { - if (_sFX) { - return _sFX->pause(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::resumeSFX() { - if (_sFX) { - return _sFX->resume(); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setSFXTime(uint32 time) { - _sFXStart = time; - if (_sFX && _sFX->isPlaying()) { - return _sFX->setPositionTime(time); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::setSFXVolume(int volume) { - _sFXVolume = volume; - if (_sFX) { - return _sFX->setVolumePercent(volume); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::updateSounds() { - if (_soundEvent) { - if (_sFX && !_sFX->isPlaying()) { - applyEvent(_soundEvent); - setSoundEvent(NULL); - } - } - - if (_sFX) { - updateOneSound(_sFX); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::updateOneSound(BaseSound *sound) { - bool ret = STATUS_OK; - - if (sound) { - if (_autoSoundPanning) { - ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); - } - - ret = sound->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::resetSoundPan() { - if (!_sFX) { - return STATUS_OK; - } else { - return _sFX->setPan(0.0f); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::getExtendedFlag(const char *flagName) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::isReady() { - return _ready; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseObject::setSoundEvent(const char *eventName) { - delete[] _soundEvent; - _soundEvent = NULL; - if (eventName) { - _soundEvent = new char[strlen(eventName) + 1]; - if (_soundEvent) { - strcpy(_soundEvent, eventName); - } - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseObject::afterMove() { - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/platform_osystem.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseObject, false) + +////////////////////////////////////////////////////////////////////// +BaseObject::BaseObject(BaseGame *inGame) : BaseScriptHolder(inGame) { + _posX = _posY = 0; + _movable = true; + _zoomable = true; + _registrable = true; + _shadowable = true; + _rotatable = false; + _is3D = false; + + _alphaColor = 0; + _scale = -1; + _relativeScale = 0; + + _scaleX = -1; + _scaleY = -1; + + _ready = true; + + _soundEvent = NULL; + + _iD = _gameRef->getSequence(); + + BasePlatform::setRectEmpty(&_rect); + _rectSet = false; + + _cursor = NULL; + _activeCursor = NULL; + _sharedCursors = false; + + _sFX = NULL; + _sFXStart = 0; + _sFXVolume = 100; + _autoSoundPanning = true; + + _editorAlwaysRegister = false; + _editorSelected = false; + + _editorOnly = false; + + _rotate = 0.0f; + _rotateValid = false; + _relativeRotate = 0.0f; + + for (int i = 0; i < 7; i++) { + _caption[i] = NULL; + } + _saveState = true; + + _nonIntMouseEvents = false; + + // sound FX + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + _blendMode = BLEND_NORMAL; +} + + +////////////////////////////////////////////////////////////////////// +BaseObject::~BaseObject() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::cleanup() { + if (_gameRef && _gameRef->_activeObject == this) { + _gameRef->_activeObject = NULL; + } + + BaseScriptHolder::cleanup(); + delete[] _soundEvent; + _soundEvent = NULL; + + if (!_sharedCursors) { + delete _cursor; + delete _activeCursor; + _cursor = NULL; + _activeCursor = NULL; + } + delete _sFX; + _sFX = NULL; + + for (int i = 0; i < 7; i++) { + delete[] _caption[i]; + _caption[i] = NULL; + } + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseObject::setCaption(const char *caption, int caseVal) { + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7) { + return; + } + + delete[] _caption[caseVal - 1]; + _caption[caseVal - 1] = new char[strlen(caption) + 1]; + if (_caption[caseVal - 1]) { + strcpy(_caption[caseVal - 1], caption); + _gameRef->_stringTable->expand(&_caption[caseVal - 1]); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseObject::getCaption(int caseVal) { + if (caseVal == 0) { + caseVal = 1; + } + if (caseVal < 1 || caseVal > 7 || _caption[caseVal - 1] == NULL) { + return ""; + } else { + return _caption[caseVal - 1]; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::listen(BaseScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // SkipTo + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SkipTo") == 0) { + stack->correctParams(2); + _posX = stack->pop()->getInt(); + _posY = stack->pop()->getInt(); + afterMove(); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + stack->correctParams(1); + stack->pushString(getCaption(stack->pop()->getInt())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCursor") == 0) { + stack->correctParams(1); + if (DID_SUCCEED(setCursor(stack->pop()->getString()))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveCursor") == 0) { + stack->correctParams(0); + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } else { + _cursor = NULL; + + } + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursor") == 0) { + stack->correctParams(0); + if (!_cursor || !_cursor->getFilename()) { + stack->pushNULL(); + } else { + stack->pushString(_cursor->getFilename()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetCursorObject + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetCursorObject") == 0) { + stack->correctParams(0); + if (!_cursor) { + stack->pushNULL(); + } else { + stack->pushNative(_cursor, true); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HasCursor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HasCursor") == 0) { + stack->correctParams(0); + + if (_cursor) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCaption") == 0) { + stack->correctParams(2); + setCaption(stack->pop()->getString(), stack->pop()->getInt()); + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LoadSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LoadSound") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + if (DID_SUCCEED(playSFX(filename, false, false))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySound") == 0) { + stack->correctParams(3); + + const char *filename; + bool looping; + uint32 loopStart; + + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + ScValue *val3 = stack->pop(); + + if (val1->_type == VAL_BOOL) { + filename = NULL; + looping = val1->getBool(); + loopStart = val2->getInt(); + } else { + if (val1->isNULL()) { + filename = NULL; + } else { + filename = val1->getString(); + } + looping = val2->isNULL() ? false : val2->getBool(); + loopStart = val3->getInt(); + } + + if (DID_FAIL(playSFX(filename, looping, true, NULL, loopStart))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PlaySoundEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PlaySoundEvent") == 0) { + stack->correctParams(2); + + const char *filename; + const char *eventName; + + ScValue *val1 = stack->pop(); + ScValue *val2 = stack->pop(); + + if (val2->isNULL()) { + filename = NULL; + eventName = val1->getString(); + } else { + filename = val1->getString(); + eventName = val2->getString(); + } + + if (DID_FAIL(playSFX(filename, false, true, eventName))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // StopSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "StopSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(stopSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PauseSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PauseSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(pauseSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ResumeSound + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ResumeSound") == 0) { + stack->correctParams(0); + + if (DID_FAIL(resumeSFX())) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsSoundPlaying + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsSoundPlaying") == 0) { + stack->correctParams(0); + + if (_sFX && _sFX->isPlaying()) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundPosition") == 0) { + stack->correctParams(1); + + uint32 time = stack->pop()->getInt(); + if (DID_FAIL(setSFXTime(time))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundPosition") == 0) { + stack->correctParams(0); + + if (!_sFX) { + stack->pushInt(0); + } else { + stack->pushInt(_sFX->getPositionTime()); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSoundVolume") == 0) { + stack->correctParams(1); + + int volume = stack->pop()->getInt(); + if (DID_FAIL(setSFXVolume(volume))) { + stack->pushBool(false); + } else { + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetSoundVolume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSoundVolume") == 0) { + stack->correctParams(0); + + if (!_sFX) { + stack->pushInt(_sFXVolume); + } else { + stack->pushInt(_sFX->getVolumePercent()); + } + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SoundFXNone + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXNone") == 0) { + stack->correctParams(0); + _sFXType = SFX_NONE; + _sFXParam1 = 0; + _sFXParam2 = 0; + _sFXParam3 = 0; + _sFXParam4 = 0; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXEcho + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXEcho") == 0) { + stack->correctParams(4); + _sFXType = SFX_ECHO; + _sFXParam1 = (float)stack->pop()->getFloat(0); // Wet/Dry Mix [%] (0-100) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Feedback [%] (0-100) + _sFXParam3 = (float)stack->pop()->getFloat(333.0f); // Left Delay [ms] (1-2000) + _sFXParam4 = (float)stack->pop()->getFloat(333.0f); // Right Delay [ms] (1-2000) + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundFXReverb + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundFXReverb") == 0) { + stack->correctParams(4); + _sFXType = SFX_REVERB; + _sFXParam1 = (float)stack->pop()->getFloat(0); // In Gain [dB] (-96 - 0) + _sFXParam2 = (float)stack->pop()->getFloat(0); // Reverb Mix [dB] (-96 - 0) + _sFXParam3 = (float)stack->pop()->getFloat(1000.0f); // Reverb Time [ms] (0.001 - 3000) + _sFXParam4 = (float)stack->pop()->getFloat(0.001f); // HighFreq RT Ratio (0.001 - 0.999) + stack->pushNULL(); + + return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseObject::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("object"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Caption") == 0) { + _scValue->setString(getCaption(1)); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Height (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(getHeight()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Ready (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ready") == 0) { + _scValue->setBool(_ready); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _scValue->setBool(_movable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _scValue->setBool(_registrable); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _scValue->setBool(_zoomable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _scValue->setBool(_rotatable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _scValue->setInt((int)_alphaColor); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + _scValue->setInt((int)_blendMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (_scale < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scale); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (_scaleX < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleX); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (_scaleY < 0) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_scaleY); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _scValue->setFloat((double)_relativeScale); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (!_rotateValid) { + _scValue->setNULL(); + } else { + _scValue->setFloat((double)_rotate); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _scValue->setFloat((double)_relativeRotate); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _scValue->setBool(_shadowable); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _scValue->setBool(_autoSoundPanning); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _scValue->setBool(_saveState); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _scValue->setBool(_nonIntMouseEvents); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + _scValue->setNULL(); + return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Caption + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Caption") == 0) { + setCaption(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + afterMove(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Movable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Movable") == 0) { + _movable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Registrable/Interactive + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + _registrable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Zoomable/Scalable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + _zoomable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotatable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotatable") == 0) { + _rotatable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + _alphaColor = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // BlendMode + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "BlendMode") == 0) { + int i = value->getInt(); + if (i < BLEND_NORMAL || i >= NUM_BLEND_MODES) { + i = BLEND_NORMAL; + } + _blendMode = (TSpriteBlendMode)i; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale") == 0) { + if (value->isNULL()) { + _scale = -1; + } else { + _scale = (float)value->getFloat(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleX") == 0) { + if (value->isNULL()) { + _scaleX = -1; + } else { + _scaleX = (float)value->getFloat(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ScaleY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleY") == 0) { + if (value->isNULL()) { + _scaleY = -1; + } else { + _scaleY = (float)value->getFloat(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeScale + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeScale") == 0) { + _relativeScale = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotate") == 0) { + if (value->isNULL()) { + _rotate = 0.0f; + _rotateValid = false; + } else { + _rotate = (float)value->getFloat(); + _rotateValid = true; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RelativeRotate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RelativeRotate") == 0) { + _relativeRotate = (float)value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Colorable + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Colorable") == 0) { + _shadowable = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SoundPanning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SoundPanning") == 0) { + _autoSoundPanning = value->getBool(); + if (!_autoSoundPanning) { + resetSoundPan(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SaveState + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SaveState") == 0) { + _saveState = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // NonIntMouseEvents + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NonIntMouseEvents") == 0) { + _nonIntMouseEvents = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AccCaption + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccCaption") == 0) { + return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseObject::scToString() { + return "[object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::showCursor() { + if (_cursor) { + return _gameRef->drawCursor(_cursor); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); + + for (int i = 0; i < 7; i++) { + persistMgr->transfer(TMEMBER(_caption[i])); + } + persistMgr->transfer(TMEMBER(_activeCursor)); + persistMgr->transfer(TMEMBER(_alphaColor)); + persistMgr->transfer(TMEMBER(_autoSoundPanning)); + persistMgr->transfer(TMEMBER(_cursor)); + persistMgr->transfer(TMEMBER(_sharedCursors)); + persistMgr->transfer(TMEMBER(_editorAlwaysRegister)); + persistMgr->transfer(TMEMBER(_editorOnly)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_iD)); + persistMgr->transfer(TMEMBER(_is3D)); + persistMgr->transfer(TMEMBER(_movable)); + persistMgr->transfer(TMEMBER(_posX)); + persistMgr->transfer(TMEMBER(_posY)); + persistMgr->transfer(TMEMBER(_relativeScale)); + persistMgr->transfer(TMEMBER(_rotatable)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_sFX)); + persistMgr->transfer(TMEMBER(_sFXStart)); + persistMgr->transfer(TMEMBER(_sFXVolume)); + persistMgr->transfer(TMEMBER(_ready)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_rectSet)); + persistMgr->transfer(TMEMBER(_registrable)); + persistMgr->transfer(TMEMBER(_shadowable)); + persistMgr->transfer(TMEMBER(_soundEvent)); + persistMgr->transfer(TMEMBER(_zoomable)); + + persistMgr->transfer(TMEMBER(_scaleX)); + persistMgr->transfer(TMEMBER(_scaleY)); + + persistMgr->transfer(TMEMBER(_rotate)); + persistMgr->transfer(TMEMBER(_rotateValid)); + persistMgr->transfer(TMEMBER(_relativeRotate)); + + persistMgr->transfer(TMEMBER(_saveState)); + persistMgr->transfer(TMEMBER(_nonIntMouseEvents)); + + persistMgr->transfer(TMEMBER_INT(_sFXType)); + persistMgr->transfer(TMEMBER(_sFXParam1)); + persistMgr->transfer(TMEMBER(_sFXParam2)); + persistMgr->transfer(TMEMBER(_sFXParam3)); + persistMgr->transfer(TMEMBER(_sFXParam4)); + + + persistMgr->transfer(TMEMBER_INT(_blendMode)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setCursor(const char *filename) { + if (!_sharedCursors) { + delete _cursor; + _cursor = NULL; + } + + _sharedCursors = false; + _cursor = new BaseSprite(_gameRef); + if (!_cursor || DID_FAIL(_cursor->loadFile(filename))) { + delete _cursor; + _cursor = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setActiveCursor(const char *filename) { + delete _activeCursor; + _activeCursor = new BaseSprite(_gameRef); + if (!_activeCursor || DID_FAIL(_activeCursor->loadFile(filename))) { + delete _activeCursor; + _activeCursor = NULL; + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +int BaseObject::getHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleMouse(TMouseEvent event, TMouseButton button) { + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleKeypress(Common::Event *event, bool printable) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::handleMouseWheel(int delta) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::playSFX(const char *filename, bool looping, bool playNow, const char *eventName, uint32 loopStart) { + // just play loaded sound + if (filename == NULL && _sFX) { + if (_gameRef->_editorMode || _sFXStart) { + _sFX->setVolumePercent(_sFXVolume); + _sFX->setPositionTime(_sFXStart); + if (!_gameRef->_editorMode) { + _sFXStart = 0; + } + } + if (playNow) { + setSoundEvent(eventName); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } + return _sFX->play(looping); + } else { + return STATUS_OK; + } + } + + if (filename == NULL) { + return STATUS_FAILED; + } + + // create new sound + delete _sFX; + + _sFX = new BaseSound(_gameRef); + if (_sFX && DID_SUCCEED(_sFX->setSound(filename, Audio::Mixer::kSFXSoundType, true))) { + _sFX->setVolumePercent(_sFXVolume); + if (_sFXStart) { + _sFX->setPositionTime(_sFXStart); + _sFXStart = 0; + } + _sFX->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + if (playNow) { + setSoundEvent(eventName); + if (loopStart) { + _sFX->setLoopStart(loopStart); + } + return _sFX->play(looping); + } else { + return STATUS_OK; + } + } else { + delete _sFX; + _sFX = NULL; + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::stopSFX(bool deleteSound) { + if (_sFX) { + _sFX->stop(); + if (deleteSound) { + delete _sFX; + _sFX = NULL; + } + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::pauseSFX() { + if (_sFX) { + return _sFX->pause(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::resumeSFX() { + if (_sFX) { + return _sFX->resume(); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setSFXTime(uint32 time) { + _sFXStart = time; + if (_sFX && _sFX->isPlaying()) { + return _sFX->setPositionTime(time); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::setSFXVolume(int volume) { + _sFXVolume = volume; + if (_sFX) { + return _sFX->setVolumePercent(volume); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::updateSounds() { + if (_soundEvent) { + if (_sFX && !_sFX->isPlaying()) { + applyEvent(_soundEvent); + setSoundEvent(NULL); + } + } + + if (_sFX) { + updateOneSound(_sFX); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::updateOneSound(BaseSound *sound) { + bool ret = STATUS_OK; + + if (sound) { + if (_autoSoundPanning) { + ret = sound->setPan(_gameRef->_soundMgr->posToPan(_posX - _gameRef->_offsetX, _posY - _gameRef->_offsetY)); + } + + ret = sound->applyFX(_sFXType, _sFXParam1, _sFXParam2, _sFXParam3, _sFXParam4); + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::resetSoundPan() { + if (!_sFX) { + return STATUS_OK; + } else { + return _sFX->setPan(0.0f); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::getExtendedFlag(const char *flagName) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::isReady() { + return _ready; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseObject::setSoundEvent(const char *eventName) { + delete[] _soundEvent; + _soundEvent = NULL; + if (eventName) { + _soundEvent = new char[strlen(eventName) + 1]; + if (_soundEvent) { + strcpy(_soundEvent, eventName); + } + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseObject::afterMove() { + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index e1a21e91ba..34adbdb585 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -1,147 +1,147 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_OBJECT_H -#define WINTERMUTE_BASE_OBJECT_H - - -#include "engines/wintermute/base/base_script_holder.h" -#include "engines/wintermute/persistent.h" -#include "common/events.h" - -namespace Wintermute { - -class BaseSprite; -class BaseSound; -class BaseSurface; -class BaseScriptHolder; -class ScValue; -class ScStack; -class ScScript; -class BaseObject : public BaseScriptHolder { -protected: - bool _autoSoundPanning; - uint32 _sFXStart; - bool setSFXTime(uint32 time); - bool setSFXVolume(int volume); - bool resumeSFX(); - bool pauseSFX(); - bool stopSFX(bool deleteSound = true); - bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); - BaseSound *_sFX; - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - float _relativeRotate; - bool _rotateValid; - float _rotate; - void setSoundEvent(const char *eventName); - bool _rotatable; - float _scaleX; - float _scaleY; - float _relativeScale; - bool _editorSelected; - bool _editorAlwaysRegister; - bool _ready; - Rect32 _rect; - bool _rectSet; - int _iD; - char *_soundEvent; -public: - TSpriteBlendMode _blendMode; - virtual bool afterMove(); - float _scale; - uint32 _alphaColor; - virtual bool isReady(); - virtual bool getExtendedFlag(const char *flagName); - virtual bool resetSoundPan(); - virtual bool updateSounds(); - bool updateOneSound(BaseSound *sound); - int _sFXVolume; - - virtual bool handleMouseWheel(int delta); - virtual bool handleMouse(TMouseEvent event, TMouseButton button); - virtual bool handleKeypress(Common::Event *event, bool printable = false); - virtual int getHeight(); - bool setCursor(const char *filename); - bool setActiveCursor(const char *filename); - bool cleanup(); - const char *getCaption(int caseVal = 1); - void setCaption(const char *caption, int caseVal = 1); - - bool _editorOnly; - bool _is3D; - - DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) - virtual bool showCursor(); - BaseSprite *_cursor; - bool _sharedCursors; - BaseSprite *_activeCursor; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - virtual bool listen(BaseScriptHolder *param1, uint32 param2); - - bool _movable; - bool _zoomable; - bool _shadowable; - int _posY; - int _posX; - bool _registrable; - char *_caption[7]; - bool _saveState; - - BaseObject(BaseGame *inGame); - virtual ~BaseObject(); - // base - virtual bool update() { - return STATUS_FAILED; - }; - virtual bool display() { - return STATUS_FAILED; - }; - virtual bool invalidateDeviceObjects() { - return STATUS_OK; - }; - virtual bool restoreDeviceObjects() { - return STATUS_OK; - }; - bool _nonIntMouseEvents; - - -public: - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_OBJECT_H +#define WINTERMUTE_BASE_OBJECT_H + + +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/persistent.h" +#include "common/events.h" + +namespace Wintermute { + +class BaseSprite; +class BaseSound; +class BaseSurface; +class BaseScriptHolder; +class ScValue; +class ScStack; +class ScScript; +class BaseObject : public BaseScriptHolder { +protected: + bool _autoSoundPanning; + uint32 _sFXStart; + bool setSFXTime(uint32 time); + bool setSFXVolume(int volume); + bool resumeSFX(); + bool pauseSFX(); + bool stopSFX(bool deleteSound = true); + bool playSFX(const char *filename, bool looping = false, bool playNow = true, const char *eventName = NULL, uint32 loopStart = 0); + BaseSound *_sFX; + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + float _relativeRotate; + bool _rotateValid; + float _rotate; + void setSoundEvent(const char *eventName); + bool _rotatable; + float _scaleX; + float _scaleY; + float _relativeScale; + bool _editorSelected; + bool _editorAlwaysRegister; + bool _ready; + Rect32 _rect; + bool _rectSet; + int _iD; + char *_soundEvent; +public: + TSpriteBlendMode _blendMode; + virtual bool afterMove(); + float _scale; + uint32 _alphaColor; + virtual bool isReady(); + virtual bool getExtendedFlag(const char *flagName); + virtual bool resetSoundPan(); + virtual bool updateSounds(); + bool updateOneSound(BaseSound *sound); + int _sFXVolume; + + virtual bool handleMouseWheel(int delta); + virtual bool handleMouse(TMouseEvent event, TMouseButton button); + virtual bool handleKeypress(Common::Event *event, bool printable = false); + virtual int getHeight(); + bool setCursor(const char *filename); + bool setActiveCursor(const char *filename); + bool cleanup(); + const char *getCaption(int caseVal = 1); + void setCaption(const char *caption, int caseVal = 1); + + bool _editorOnly; + bool _is3D; + + DECLARE_PERSISTENT(BaseObject, BaseScriptHolder) + virtual bool showCursor(); + BaseSprite *_cursor; + bool _sharedCursors; + BaseSprite *_activeCursor; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + + bool _movable; + bool _zoomable; + bool _shadowable; + int _posY; + int _posX; + bool _registrable; + char *_caption[7]; + bool _saveState; + + BaseObject(BaseGame *inGame); + virtual ~BaseObject(); + // base + virtual bool update() { + return STATUS_FAILED; + }; + virtual bool display() { + return STATUS_FAILED; + }; + virtual bool invalidateDeviceObjects() { + return STATUS_OK; + }; + virtual bool restoreDeviceObjects() { + return STATUS_OK; + }; + bool _nonIntMouseEvents; + + +public: + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_parser.cpp b/engines/wintermute/base/base_parser.cpp index 007f93e443..9a0e9e3ad9 100644 --- a/engines/wintermute/base/base_parser.cpp +++ b/engines/wintermute/base/base_parser.cpp @@ -1,467 +1,467 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/util.h" - -#define WHITESPACE " \t\n\r" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////// -BaseParser::BaseParser() { - _whiteSpace = new char [strlen(WHITESPACE) + 1]; - strcpy(_whiteSpace, WHITESPACE); -} - - -////////////////////////////////////////////////////////////////////// -BaseParser::~BaseParser() { - if (_whiteSpace != NULL) { - delete[] _whiteSpace; - } -} - - -////////////////////////////////////////////////////////////////////// -char *BaseParser::getLastOffender() { - return _lastOffender; -} - - -////////////////////////////////////////////////////////////////////// -int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, char **data) { - skipCharacters(buf, _whiteSpace); - - // skip comment lines. - while (**buf == ';') { - *buf = strchr(*buf, '\n'); - _parserLine++; - skipCharacters(buf, _whiteSpace); - } - - if (! **buf) { // at end of file - return PARSERR_EOF; - } - - // find the token. - // TODO: for now just use brute force. Improve later. - while (tokens->id != 0) { - if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { - // here we could be matching PART of a string - // we could detect this here or the token list - // could just have the longer tokens first in the list - break; - } - ++tokens; - } - if (tokens->id == 0) { - char *p = strchr(*buf, '\n'); - if (p && p > *buf) { - strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean - } else { - strcpy(_lastOffender, ""); - } - - return PARSERR_TOKENNOTFOUND; - } - // skip the token - *buf += strlen(tokens->token); - skipCharacters(buf, _whiteSpace); - - // get optional name - *name = getSubText(buf, '\'', '\''); // single quotes - skipCharacters(buf, _whiteSpace); - - // get optional data - if (**buf == '=') { // An assignment rather than a command/object. - *data = getAssignmentText(buf); - } else { - *data = getSubText(buf, '{', '}'); - } - - return tokens->id; -} - - -////////////////////////////////////////////////////////////////////// -int32 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { - if (!*buf) { - return PARSERR_TOKENNOTFOUND; - } - BaseEngine::instance().getGameRef()->miniUpdate(); - char *name; - return getObject(buf, tokens, &name, params); -} - - -////////////////////////////////////////////////////////////////////// -void BaseParser::skipCharacters(char **buf, const char *toSkip) { - char ch; - while ((ch = **buf) != 0) { - if (ch == '\n') { - _parserLine++; - } - if (strchr(toSkip, ch) == NULL) { - return; - } - ++*buf; // skip this character - } - // we must be at the end of the buffer if we get here -} - - -////////////////////////////////////////////////////////////////////// -char *BaseParser::getSubText(char **buf, char open, char close) { - if (**buf == 0 || **buf != open) { - return 0; - } - ++*buf; // skip opening delimiter - char *result = *buf; - - // now find the closing delimiter - char theChar; - long skip = 1; - - if (open == close) { // we cant nest identical delimiters - open = 0; - } - while ((theChar = **buf) != 0) { - if (theChar == open) { - ++skip; - } - if (theChar == close) { - if (--skip == 0) { - **buf = 0; // null terminate the result string - ++*buf; // move past the closing delimiter - break; - } - } - ++*buf; // try next character - } - return result; -} - - -////////////////////////////////////////////////////////////////////// -char *BaseParser::getAssignmentText(char **buf) { - ++*buf; // skip the '=' - skipCharacters(buf, _whiteSpace); - char *result = *buf; - - - if (*result == '"') { - result = getSubText(buf, '"', '"'); - } else { - // now, we need to find the next whitespace to end the data - char theChar; - - while ((theChar = **buf) != 0) { - if (theChar <= 0x20) { // space and control chars - break; - } - ++*buf; - } - **buf = 0; // null terminate it - if (theChar) { // skip the terminator - ++*buf; - } - } - - return result; -} - -////////////////////////////////////////////////////////////////////// -Common::String BaseParser::getToken(char **buf) { - char token[100]; // TODO: Remove static - char *b = *buf, *t = token; - while (true) { - while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { - b++; - } - if (*b == ';') - while (*b && *b != '\n' && *b != 13 && *b != 10) { - b++; - } - else { - break; - } - } - - if (*b == '\'') { - b++; - while (*b && *b != '\'') { - *t++ = *b++; - } - *t++ = 0; - if (*b == '\'') { - b++; - } - } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || - *b == '%' || *b == ':' || *b == '{' || *b == '}') { - *t++ = *b++; - *t++ = 0; - } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { - *t++ = *b++; - *t++ = 0; - } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { - while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { - *t++ = *b++; - } - *t++ = 0; - } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { - while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { - *t++ = *b++; - } - *t++ = 0; - } else if (*b == 0) { - *buf = b; - return NULL; - } else { - // Error. - return NULL; - } - - *buf = b; - return token; -} - - -////////////////////////////////////////////////////////////////////// -float BaseParser::getTokenFloat(char **buf) { - Common::String token = getToken(buf); - const char *t = token.c_str(); - if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { - // Error situation. We handle this by return 0. - return 0.; - } - float rc = (float)atof(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -int BaseParser::getTokenInt(char **buf) { - Common::String token = getToken(buf); - const char *t = token.c_str(); - if (!((*t >= '0' && *t <= '9') || *t == '-')) { - // Error situation. We handle this by return 0. - return 0; - } - int rc = atoi(t); - return rc; -} - - -////////////////////////////////////////////////////////////////////// -void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { - Common::String token = getToken(buf); - const char *t = token.c_str(); - if (strcmp(t, tok)) { - return; // Error - } -} - - -////////////////////////////////////////////////////////////////////// -int BaseParser::scanStr(const char *in, const char *format, ...) { - va_list arg; - va_start(arg, format); - - int num = 0; - in += strspn(in, " \t\n\f"); - - while (*format && *in) { - if (*format == '%') { - format++; - switch (*format) { - case 'd': { - int *a = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - *a = atoi(in); - in += strspn(in, "0123456789+- \t\n\f"); - num++; - break; - } - case 'D': { - int i; - int *list = va_arg(arg, int *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { - list[i++] = atoi(in); - in += strspn(in, "0123456789+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') { - break; - } - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 'b': { - bool *a = va_arg(arg, bool *); - in += strspn(in, " \t\n\f"); - const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); - int l = (int)(in2 - in); - - *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || - !scumm_strnicmp(in, "1", l)); - - - in = in2 + strspn(in2, " \t\n\f"); - num++; - break; - } - case 'f': { - float *a = va_arg(arg, float *); - in += strspn(in, " \t\n\f"); - *a = (float)atof(in); - in += strspn(in, "0123456789.eE+- \t\n\f"); - num++; - break; - } - case 'F': { - int i; - float *list = va_arg(arg, float *); - int *nr = va_arg(arg, int *); - in += strspn(in, " \t\n\f"); - i = 0; - while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { - list[i++] = (float)atof(in); - in += strspn(in, "0123456789.eE+-"); - in += strspn(in, " \t\n\f"); - if (*in != ',') { - break; - } - in++; - in += strspn(in, " \t\n\f"); - } - *nr = i; - num++; - break; - } - case 's': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\'') { - in++; - const char *in2 = strchr(in, '\''); - if (in2) { - Common::strlcpy(a, in, (int)(in2 - in) + 1); - in = in2 + 1; - } else { - strcpy(a, in); - in = strchr(in, 0); - } - } else { - const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); - Common::strlcpy(a, in, (int)(in2 - in) + 1); - in = in2; - } - in += strspn(in, " \t\n\f"); - num++; - break; - } - case 'S': { - char *a = va_arg(arg, char *); - in += strspn(in, " \t\n\f"); - if (*in == '\"') { - in++; - while (*in != '\"') { - if (*in == '\\') { - in++; - switch (*in) { - case '\\': - *a++ = '\\'; - break; - case 'n': - *a++ = '\n'; - break; - case 'r': - *a++ = '\r'; - break; - case 't': - *a++ = '\t'; - break; - case '"': - *a++ = '"'; - break; - default: - *a++ = '\\'; - *a++ = *in; - break; - } //switch - in++; - } else { - *a++ = *in++; - } - } //while in string - in++; - num++; - } //if string started - - //terminate string - *a = '\0'; - break; - } - } - if (*format) { - format++; - } - } else if (*format == ' ') { - format++; - in += strspn(in, " \t\n\f"); - } else if (*in == *format) { - in++; - format++; - } else { - num = -1; - break; - } - } - - va_end(arg); - - return num; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/util.h" + +#define WHITESPACE " \t\n\r" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////// +BaseParser::BaseParser() { + _whiteSpace = new char [strlen(WHITESPACE) + 1]; + strcpy(_whiteSpace, WHITESPACE); +} + + +////////////////////////////////////////////////////////////////////// +BaseParser::~BaseParser() { + if (_whiteSpace != NULL) { + delete[] _whiteSpace; + } +} + + +////////////////////////////////////////////////////////////////////// +char *BaseParser::getLastOffender() { + return _lastOffender; +} + + +////////////////////////////////////////////////////////////////////// +int32 BaseParser::getObject(char **buf, const TokenDesc *tokens, char **name, char **data) { + skipCharacters(buf, _whiteSpace); + + // skip comment lines. + while (**buf == ';') { + *buf = strchr(*buf, '\n'); + _parserLine++; + skipCharacters(buf, _whiteSpace); + } + + if (! **buf) { // at end of file + return PARSERR_EOF; + } + + // find the token. + // TODO: for now just use brute force. Improve later. + while (tokens->id != 0) { + if (!scumm_strnicmp(tokens->token, *buf, strlen(tokens->token))) { + // here we could be matching PART of a string + // we could detect this here or the token list + // could just have the longer tokens first in the list + break; + } + ++tokens; + } + if (tokens->id == 0) { + char *p = strchr(*buf, '\n'); + if (p && p > *buf) { + strncpy(_lastOffender, *buf, MIN((uint32)255, (uint32)(p - *buf))); // TODO, clean + } else { + strcpy(_lastOffender, ""); + } + + return PARSERR_TOKENNOTFOUND; + } + // skip the token + *buf += strlen(tokens->token); + skipCharacters(buf, _whiteSpace); + + // get optional name + *name = getSubText(buf, '\'', '\''); // single quotes + skipCharacters(buf, _whiteSpace); + + // get optional data + if (**buf == '=') { // An assignment rather than a command/object. + *data = getAssignmentText(buf); + } else { + *data = getSubText(buf, '{', '}'); + } + + return tokens->id; +} + + +////////////////////////////////////////////////////////////////////// +int32 BaseParser::getCommand(char **buf, const TokenDesc *tokens, char **params) { + if (!*buf) { + return PARSERR_TOKENNOTFOUND; + } + BaseEngine::instance().getGameRef()->miniUpdate(); + char *name; + return getObject(buf, tokens, &name, params); +} + + +////////////////////////////////////////////////////////////////////// +void BaseParser::skipCharacters(char **buf, const char *toSkip) { + char ch; + while ((ch = **buf) != 0) { + if (ch == '\n') { + _parserLine++; + } + if (strchr(toSkip, ch) == NULL) { + return; + } + ++*buf; // skip this character + } + // we must be at the end of the buffer if we get here +} + + +////////////////////////////////////////////////////////////////////// +char *BaseParser::getSubText(char **buf, char open, char close) { + if (**buf == 0 || **buf != open) { + return 0; + } + ++*buf; // skip opening delimiter + char *result = *buf; + + // now find the closing delimiter + char theChar; + long skip = 1; + + if (open == close) { // we cant nest identical delimiters + open = 0; + } + while ((theChar = **buf) != 0) { + if (theChar == open) { + ++skip; + } + if (theChar == close) { + if (--skip == 0) { + **buf = 0; // null terminate the result string + ++*buf; // move past the closing delimiter + break; + } + } + ++*buf; // try next character + } + return result; +} + + +////////////////////////////////////////////////////////////////////// +char *BaseParser::getAssignmentText(char **buf) { + ++*buf; // skip the '=' + skipCharacters(buf, _whiteSpace); + char *result = *buf; + + + if (*result == '"') { + result = getSubText(buf, '"', '"'); + } else { + // now, we need to find the next whitespace to end the data + char theChar; + + while ((theChar = **buf) != 0) { + if (theChar <= 0x20) { // space and control chars + break; + } + ++*buf; + } + **buf = 0; // null terminate it + if (theChar) { // skip the terminator + ++*buf; + } + } + + return result; +} + +////////////////////////////////////////////////////////////////////// +Common::String BaseParser::getToken(char **buf) { + char token[100]; // TODO: Remove static + char *b = *buf, *t = token; + while (true) { + while (*b && (*b == ' ' || *b == '\n' || *b == 13 || *b == 10 || *b == '\t')) { + b++; + } + if (*b == ';') + while (*b && *b != '\n' && *b != 13 && *b != 10) { + b++; + } + else { + break; + } + } + + if (*b == '\'') { + b++; + while (*b && *b != '\'') { + *t++ = *b++; + } + *t++ = 0; + if (*b == '\'') { + b++; + } + } else if (*b == '(' || *b == ')' || *b == '=' || *b == ',' || *b == '[' || *b == ']' || + *b == '%' || *b == ':' || *b == '{' || *b == '}') { + *t++ = *b++; + *t++ = 0; + } else if (*b == '.' && (*(b + 1) < '0' || *(b + 1) > '9')) { + *t++ = *b++; + *t++ = 0; + } else if ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-') { + while (*b && ((*b >= '0' && *b <= '9') || *b == '.' || *b == '-')) { + *t++ = *b++; + } + *t++ = 0; + } else if ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_') { + while (*b && ((*b >= 'A' && *b <= 'Z') || (*b >= 'a' && *b <= 'z') || *b == '_')) { + *t++ = *b++; + } + *t++ = 0; + } else if (*b == 0) { + *buf = b; + return NULL; + } else { + // Error. + return NULL; + } + + *buf = b; + return token; +} + + +////////////////////////////////////////////////////////////////////// +float BaseParser::getTokenFloat(char **buf) { + Common::String token = getToken(buf); + const char *t = token.c_str(); + if (!((*t >= '0' && *t <= '9') || *t == '-' || *t == '.')) { + // Error situation. We handle this by return 0. + return 0.; + } + float rc = (float)atof(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +int BaseParser::getTokenInt(char **buf) { + Common::String token = getToken(buf); + const char *t = token.c_str(); + if (!((*t >= '0' && *t <= '9') || *t == '-')) { + // Error situation. We handle this by return 0. + return 0; + } + int rc = atoi(t); + return rc; +} + + +////////////////////////////////////////////////////////////////////// +void BaseParser::skipToken(char **buf, char *tok, char * /*msg*/) { + Common::String token = getToken(buf); + const char *t = token.c_str(); + if (strcmp(t, tok)) { + return; // Error + } +} + + +////////////////////////////////////////////////////////////////////// +int BaseParser::scanStr(const char *in, const char *format, ...) { + va_list arg; + va_start(arg, format); + + int num = 0; + in += strspn(in, " \t\n\f"); + + while (*format && *in) { + if (*format == '%') { + format++; + switch (*format) { + case 'd': { + int *a = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + *a = atoi(in); + in += strspn(in, "0123456789+- \t\n\f"); + num++; + break; + } + case 'D': { + int i; + int *list = va_arg(arg, int *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '+' || *in == '-') { + list[i++] = atoi(in); + in += strspn(in, "0123456789+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') { + break; + } + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 'b': { + bool *a = va_arg(arg, bool *); + in += strspn(in, " \t\n\f"); + const char *in2 = in + strspn(in, "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"); + int l = (int)(in2 - in); + + *a = (bool)(!scumm_strnicmp(in, "yes", l) || !scumm_strnicmp(in, "true", l) || !scumm_strnicmp(in, "on", l) || + !scumm_strnicmp(in, "1", l)); + + + in = in2 + strspn(in2, " \t\n\f"); + num++; + break; + } + case 'f': { + float *a = va_arg(arg, float *); + in += strspn(in, " \t\n\f"); + *a = (float)atof(in); + in += strspn(in, "0123456789.eE+- \t\n\f"); + num++; + break; + } + case 'F': { + int i; + float *list = va_arg(arg, float *); + int *nr = va_arg(arg, int *); + in += strspn(in, " \t\n\f"); + i = 0; + while ((*in >= '0' && *in <= '9') || *in == '.' || *in == '+' || *in == '-' || *in == 'e' || *in == 'E') { + list[i++] = (float)atof(in); + in += strspn(in, "0123456789.eE+-"); + in += strspn(in, " \t\n\f"); + if (*in != ',') { + break; + } + in++; + in += strspn(in, " \t\n\f"); + } + *nr = i; + num++; + break; + } + case 's': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\'') { + in++; + const char *in2 = strchr(in, '\''); + if (in2) { + Common::strlcpy(a, in, (int)(in2 - in) + 1); + in = in2 + 1; + } else { + strcpy(a, in); + in = strchr(in, 0); + } + } else { + const char *in2 = in + strspn(in, "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_0123456789."); + Common::strlcpy(a, in, (int)(in2 - in) + 1); + in = in2; + } + in += strspn(in, " \t\n\f"); + num++; + break; + } + case 'S': { + char *a = va_arg(arg, char *); + in += strspn(in, " \t\n\f"); + if (*in == '\"') { + in++; + while (*in != '\"') { + if (*in == '\\') { + in++; + switch (*in) { + case '\\': + *a++ = '\\'; + break; + case 'n': + *a++ = '\n'; + break; + case 'r': + *a++ = '\r'; + break; + case 't': + *a++ = '\t'; + break; + case '"': + *a++ = '"'; + break; + default: + *a++ = '\\'; + *a++ = *in; + break; + } //switch + in++; + } else { + *a++ = *in++; + } + } //while in string + in++; + num++; + } //if string started + + //terminate string + *a = '\0'; + break; + } + } + if (*format) { + format++; + } + } else if (*format == ' ') { + format++; + in += strspn(in, " \t\n\f"); + } else if (*in == *format) { + in++; + format++; + } else { + num = -1; + break; + } + } + + va_end(arg); + + return num; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_parser.h b/engines/wintermute/base/base_parser.h index 6b4f733d74..76ca8ea856 100644 --- a/engines/wintermute/base/base_parser.h +++ b/engines/wintermute/base/base_parser.h @@ -1,88 +1,88 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_PARSER_H -#define WINTERMUTE_BASE_PARSER_H - - -#define TOKEN_DEF_START \ - enum \ - { \ - TOKEN_NONE = 0, -#define TOKEN_DEF(name) \ - TOKEN_ ## name, -#define TOKEN_DEF_END \ - TOKEN_TOTAL_COUNT \ - }; -#define TOKEN_TABLE_START(name) \ - static const BaseParser::TokenDesc name [] = \ - { -#define TOKEN_TABLE(name) \ - { TOKEN_ ## name, #name }, -#define TOKEN_TABLE_END \ - { 0, 0 } \ - }; - -#define PARSERR_GENERIC -3 -#define PARSERR_EOF -2 -#define PARSERR_TOKENNOTFOUND -1 - -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { - -class BaseParser { -public: - struct TokenDesc { - int32 id; - const char *token; - }; - -public: - int scanStr(const char *in, const char *format, ...); - int32 getCommand(char **buf, const TokenDesc *tokens, char **params); - BaseParser(); - virtual ~BaseParser(); -private: - char *getLastOffender(); - void skipToken(char **buf, char *tok, char *msg = NULL); - int getTokenInt(char **buf); - float getTokenFloat(char **buf); - Common::String getToken(char **buf); - char *getAssignmentText(char **buf); - char *getSubText(char **buf, char open, char close); - void skipCharacters(char **buf, const char *toSkip); - int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data); - int _parserLine; - char _lastOffender[255]; - char *_whiteSpace; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PARSER_H +#define WINTERMUTE_BASE_PARSER_H + + +#define TOKEN_DEF_START \ + enum \ + { \ + TOKEN_NONE = 0, +#define TOKEN_DEF(name) \ + TOKEN_ ## name, +#define TOKEN_DEF_END \ + TOKEN_TOTAL_COUNT \ + }; +#define TOKEN_TABLE_START(name) \ + static const BaseParser::TokenDesc name [] = \ + { +#define TOKEN_TABLE(name) \ + { TOKEN_ ## name, #name }, +#define TOKEN_TABLE_END \ + { 0, 0 } \ + }; + +#define PARSERR_GENERIC -3 +#define PARSERR_EOF -2 +#define PARSERR_TOKENNOTFOUND -1 + +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { + +class BaseParser { +public: + struct TokenDesc { + int32 id; + const char *token; + }; + +public: + int scanStr(const char *in, const char *format, ...); + int32 getCommand(char **buf, const TokenDesc *tokens, char **params); + BaseParser(); + virtual ~BaseParser(); +private: + char *getLastOffender(); + void skipToken(char **buf, char *tok, char *msg = NULL); + int getTokenInt(char **buf); + float getTokenFloat(char **buf); + Common::String getToken(char **buf); + char *getAssignmentText(char **buf); + char *getSubText(char **buf, char open, char close); + void skipCharacters(char **buf, const char *toSkip); + int32 getObject(char **buf, const TokenDesc *tokens, char **name, char **data); + int _parserLine; + char _lastOffender[255]; + char *_whiteSpace; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_persistence_manager.cpp b/engines/wintermute/base/base_persistence_manager.cpp index 94588eff32..4cb67b87e1 100644 --- a/engines/wintermute/base/base_persistence_manager.cpp +++ b/engines/wintermute/base/base_persistence_manager.cpp @@ -1,828 +1,828 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_persistence_manager.h" -#include "engines/wintermute/base/base_save_thumb_helper.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/wintermute.h" -#include "graphics/decoders/bmp.h" -#include "common/memstream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/savefile.h" - -namespace Wintermute { - -#define SAVE_BUFFER_INIT_SIZE 100000 -#define SAVE_BUFFER_GROW_BY 50000 - -#define SAVE_MAGIC 0x45564153 -#define SAVE_MAGIC_2 0x32564153 - -////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { - _saving = false; -// _buffer = NULL; -// _bufferSize = 0; - _offset = 0; - _saveStream = NULL; - _loadStream = NULL; - _deleteSingleton = deleteSingleton; - if (BaseEngine::instance().getGameRef()) { - _gameRef = BaseEngine::instance().getGameRef(); - } else { - _gameRef = NULL; - } - - _richBuffer = NULL; - _richBufferSize = 0; - - _savedDescription = NULL; -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - _thumbnailData = NULL; - if (savePrefix) { - _savePrefix = savePrefix; - } else if (_gameRef) { - _savePrefix = _gameRef->getGameId(); - } else { - _savePrefix = "wmesav"; - } -} - - -////////////////////////////////////////////////////////////////////////// -BasePersistenceManager::~BasePersistenceManager() { - cleanup(); - if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) - BaseEngine::destroy(); -} - - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::cleanup() { - /* if (_buffer) { - if (_saving) free(_buffer); - else delete[] _buffer; // allocated by file manager - } - _buffer = NULL; - - _bufferSize = 0;*/ - _offset = 0; - - delete[] _richBuffer; - _richBuffer = NULL; - _richBufferSize = 0; - - delete[] _savedDescription; - _savedDescription = NULL; // ref to buffer -// _savedTimestamp = 0; - _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; - _savedExtMajor = _savedExtMinor = 0; - - _thumbnailDataSize = 0; - if (_thumbnailData) { - delete[] _thumbnailData; - _thumbnailData = NULL; - } - - delete _loadStream; - delete _saveStream; - _loadStream = NULL; - _saveStream = NULL; -} - -Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { - // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) - return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); -} - -void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { - Common::String filename = getFilenameForSlot(slot); - debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); - if (DID_FAIL(readHeader(filename))) { - warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); - return; - } - desc.setSaveSlot(slot); - desc.setDescription(_savedDescription); - desc.setDeletableFlag(true); - desc.setWriteProtectedFlag(false); - - if (_thumbnailDataSize > 0) { - Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); - Graphics::BitmapDecoder bmpDecoder; - if (bmpDecoder.loadStream(thumbStream)) { - Graphics::Surface *surf = new Graphics::Surface; - surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); - desc.setThumbnail(surf); - } - } - - desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); - desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); - desc.setPlayTime(0); -} - -void BasePersistenceManager::deleteSaveSlot(int slot) { - Common::String filename = getFilenameForSlot(slot); - g_system->getSavefileManager()->removeSavefile(filename); -} - -uint32 BasePersistenceManager::getMaxUsedSlot() { - Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); - Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); - Common::StringArray::iterator it = saves.begin(); - int ret = -1; - for (; it != saves.end(); ++it) { - int num = -1; - sscanf(it->c_str(), "save%d", &num); - ret = MAX(ret, num); - } - return ret; -} - -bool BasePersistenceManager::getSaveExists(int slot) { - Common::String filename = getFilenameForSlot(slot); - if (DID_FAIL(readHeader(filename))) { - return false; - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::initSave(const char *desc) { - if (!desc) { - return STATUS_FAILED; - } - - cleanup(); - _saving = true; - - _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); - - if (_saveStream) { - // get thumbnails - if (!_gameRef->_cachedThumbnail) { - _gameRef->_cachedThumbnail = new BaseSaveThumbHelper(_gameRef); - if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - } - } - - uint32 magic = DCGF_MAGIC; - putDWORD(magic); - - magic = SAVE_MAGIC_2; - putDWORD(magic); - - byte verMajor, verMinor, extMajor, extMinor; - _gameRef->getVersion(&verMajor, &verMinor, &extMajor, &extMinor); - //uint32 version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); - _saveStream->writeByte(verMajor); - _saveStream->writeByte(verMinor); - _saveStream->writeByte(extMajor); - _saveStream->writeByte(extMinor); - - // new in ver 2 - putDWORD((uint32)DCGF_VER_BUILD); - putString(_gameRef->getName()); - - // thumbnail data size - bool thumbnailOK = false; - - if (_gameRef->_cachedThumbnail) { - if (_gameRef->_cachedThumbnail->_thumbnail) { - Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); - if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { - _saveStream->writeUint32LE(thumbStream.size()); - _saveStream->write(thumbStream.getData(), thumbStream.size()); - } else { - _saveStream->writeUint32LE(0); - } - - thumbnailOK = true; - } - } - if (!thumbnailOK) { - putDWORD(0); - } - - // in any case, destroy the cached thumbnail once used - delete _gameRef->_cachedThumbnail; - _gameRef->_cachedThumbnail = NULL; - - uint32 dataOffset = _offset + - sizeof(uint32) + // data offset - sizeof(uint32) + strlen(desc) + 1 + // description - sizeof(uint32); // timestamp - - putDWORD(dataOffset); - putString(desc); - - g_system->getTimeAndDate(_savedTimestamp); - putTimeDate(_savedTimestamp); - _savedPlayTime = g_system->getMillis(); - _saveStream->writeUint32LE(_savedPlayTime); - } - return STATUS_OK; -} - -bool BasePersistenceManager::readHeader(const Common::String &filename) { - cleanup(); - - _saving = false; - - _loadStream = g_system->getSavefileManager()->openForLoading(filename); - //_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize); - if (_loadStream) { - uint32 magic; - magic = getDWORD(); - - if (magic != DCGF_MAGIC) { - cleanup(); - return STATUS_FAILED; - } - - magic = getDWORD(); - - if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { - _savedVerMajor = _loadStream->readByte(); - _savedVerMinor = _loadStream->readByte(); - _savedExtMajor = _loadStream->readByte(); - _savedExtMinor = _loadStream->readByte(); - - if (magic == SAVE_MAGIC_2) { - _savedVerBuild = (byte)getDWORD(); - _savedName = getStringObj(); - - // load thumbnail - _thumbnailDataSize = getDWORD(); - if (_thumbnailDataSize > 0) { - _thumbnailData = new byte[_thumbnailDataSize]; - if (_thumbnailData) { - getBytes(_thumbnailData, _thumbnailDataSize); - } else { - _thumbnailDataSize = 0; - } - } - } else { - _savedVerBuild = 35; // last build with ver1 savegames - } - - uint32 dataOffset = getDWORD(); - - _savedDescription = getString(); - _savedTimestamp = getTimeDate(); - _savedPlayTime = _loadStream->readUint32LE(); - - _offset = dataOffset; - - return STATUS_OK; - } - } - - cleanup(); - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::initLoad(const Common::String &filename) { - if (DID_FAIL(readHeader(filename))) { - cleanup(); - return STATUS_FAILED; - } - _saving = false; - - if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { - debugC(kWintermuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); - cleanup(); - return STATUS_FAILED; - } - - // if save is newer version than we are, fail - if (_savedVerMajor > DCGF_VER_MAJOR || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || - (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) - ) { - - debugC(kWintermuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); - debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - } - - // if save is older than the minimal version we support - if (_savedVerMajor < SAVEGAME_VER_MAJOR || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || - (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) - ) { - debugC(kWintermuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); - debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); - cleanup(); - return STATUS_FAILED; - - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::saveFile(const Common::String &filename) { - byte *prefixBuffer = _richBuffer; - uint32 prefixSize = _richBufferSize; - byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); - uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); - - Common::SaveFileManager *saveMan = ((WintermuteEngine *)g_engine)->getSaveFileMan(); - Common::OutSaveFile *file = saveMan->openForSaving(filename); - file->write(prefixBuffer, prefixSize); - file->write(buffer, bufferSize); - bool retVal = !file->err(); - file->finalize(); - delete file; - return retVal; -} - - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { - _saveStream->write(buffer, size); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { - _loadStream->read(buffer, size); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::putDWORD(uint32 val) { - _saveStream->writeUint32LE(val); -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BasePersistenceManager::getDWORD() { - uint32 ret = _loadStream->readUint32LE(); - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -void BasePersistenceManager::putString(const Common::String &val) { - if (!val.size()) { - putString("(null)"); - } else { - _saveStream->writeUint32LE(val.size()); - _saveStream->writeString(val); - } -} - -Common::String BasePersistenceManager::getStringObj() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - Common::String retString = ret; - delete[] ret; - - if (retString == "(null)") { - retString = ""; - } - - return retString; -} - -////////////////////////////////////////////////////////////////////////// -char *BasePersistenceManager::getString() { - uint32 len = _loadStream->readUint32LE(); - char *ret = new char[len + 1]; - _loadStream->read(ret, len); - ret[len] = '\0'; - - if (!strcmp(ret, "(null)")) { - delete[] ret; - return NULL; - } else { - return ret; - } -} - -bool BasePersistenceManager::putTimeDate(const TimeDate &t) { - _saveStream->writeSint32LE(t.tm_sec); - _saveStream->writeSint32LE(t.tm_min); - _saveStream->writeSint32LE(t.tm_hour); - _saveStream->writeSint32LE(t.tm_mday); - _saveStream->writeSint32LE(t.tm_mon); - _saveStream->writeSint32LE(t.tm_year); - // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next - - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; -} - -TimeDate BasePersistenceManager::getTimeDate() { - TimeDate t; - t.tm_sec = _loadStream->readSint32LE(); - t.tm_min = _loadStream->readSint32LE(); - t.tm_hour = _loadStream->readSint32LE(); - t.tm_mday = _loadStream->readSint32LE(); - t.tm_mon = _loadStream->readSint32LE(); - t.tm_year = _loadStream->readSint32LE(); - // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next - return t; -} - -void BasePersistenceManager::putFloat(float val) { - Common::String str = Common::String::format("F%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -float BasePersistenceManager::getFloat() { - char *str = getString(); - float value = 0.0f; - int ret = sscanf(str, "F%f", &value); - if (ret != 1) { - warning("%s not parsed as float", str); - } - delete[] str; - return value; -} - -void BasePersistenceManager::putDouble(double val) { - Common::String str = Common::String::format("D%f", val); - str.format("D%f", val); - _saveStream->writeUint32LE(str.size()); - _saveStream->writeString(str); -} - -double BasePersistenceManager::getDouble() { - char *str = getString(); - float value = 0.0f; // TODO: Do we ever really need to carry a full double-precision number? - int ret = sscanf(str, "D%f", &value); - if (ret != 1) { - warning("%s not parsed as double", str); - } - delete[] str; - return value; -} - -////////////////////////////////////////////////////////////////////////// -// bool -bool BasePersistenceManager::transfer(const char *name, bool *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// int -bool BasePersistenceManager::transfer(const char *name, int *val) { - if (_saving) { - _saveStream->writeSint32LE(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = _loadStream->readSint32LE(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// DWORD -bool BasePersistenceManager::transfer(const char *name, uint32 *val) { - if (_saving) { - _saveStream->writeUint32LE(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = _loadStream->readUint32LE(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// float -bool BasePersistenceManager::transfer(const char *name, float *val) { - if (_saving) { - putFloat(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = getFloat(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// double -bool BasePersistenceManager::transfer(const char *name, double *val) { - if (_saving) { - putDouble(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = getDouble(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// char* -bool BasePersistenceManager::transfer(const char *name, char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// const char* -bool BasePersistenceManager::transfer(const char *name, const char **val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - *val = str; - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -// Common::String -bool BasePersistenceManager::transfer(const char *name, Common::String *val) { - if (_saving) { - putString(*val); - return STATUS_OK; - } else { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - *val = str; - delete[] str; - } else { - *val = ""; - } - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { - size_t size; - - if (_saving) { - size = val.size(); - _saveStream->writeUint32LE(size); - - for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { - putString((*it).c_str()); - } - } else { - val.clear(); - size = _loadStream->readUint32LE(); - - for (size_t i = 0; i < size; i++) { - char *str = getString(); - if (_loadStream->err()) { - delete[] str; - return STATUS_FAILED; - } - if (str) { - val.push_back(str); - } - delete[] str; - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -// BYTE -bool BasePersistenceManager::transfer(const char *name, byte *val) { - if (_saving) { - _saveStream->writeByte(*val); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - *val = _loadStream->readByte(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// RECT -bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->left); - _saveStream->writeSint32LE(val->top); - _saveStream->writeSint32LE(val->right); - _saveStream->writeSint32LE(val->bottom); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - val->left = _loadStream->readSint32LE(); - val->top = _loadStream->readSint32LE(); - val->right = _loadStream->readSint32LE(); - val->bottom = _loadStream->readSint32LE(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// POINT -bool BasePersistenceManager::transfer(const char *name, Point32 *val) { - if (_saving) { - _saveStream->writeSint32LE(val->x); - _saveStream->writeSint32LE(val->y); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - val->x = _loadStream->readSint32LE(); - val->y = _loadStream->readSint32LE(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// Vector2 -bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { - if (_saving) { - putFloat(val->x); - putFloat(val->y); - if (_saveStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } else { - val->x = getFloat(); - val->y = getFloat(); - if (_loadStream->err()) { - return STATUS_FAILED; - } - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -// generic pointer -bool BasePersistenceManager::transfer(const char *name, void *val) { - int classID = -1, instanceID = -1; - - if (_saving) { - SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); - if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { - debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); - } - - _saveStream->writeUint32LE(classID); - _saveStream->writeUint32LE(instanceID); - } else { - classID = _loadStream->readUint32LE(); - instanceID = _loadStream->readUint32LE(); - - *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { - if (_saving) { - return true; - } - - // it's ok if we are same or newer than the saved game - if (verMajor > _savedVerMajor || - (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || - (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) - ) { - return false; - } - - return true; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/decoders/bmp.h" +#include "common/memstream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/savefile.h" + +namespace Wintermute { + +#define SAVE_BUFFER_INIT_SIZE 100000 +#define SAVE_BUFFER_GROW_BY 50000 + +#define SAVE_MAGIC 0x45564153 +#define SAVE_MAGIC_2 0x32564153 + +////////////////////////////////////////////////////////////////////////// +BasePersistenceManager::BasePersistenceManager(const char *savePrefix, bool deleteSingleton) { + _saving = false; +// _buffer = NULL; +// _bufferSize = 0; + _offset = 0; + _saveStream = NULL; + _loadStream = NULL; + _deleteSingleton = deleteSingleton; + if (BaseEngine::instance().getGameRef()) { + _gameRef = BaseEngine::instance().getGameRef(); + } else { + _gameRef = NULL; + } + + _richBuffer = NULL; + _richBufferSize = 0; + + _savedDescription = NULL; +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + _thumbnailData = NULL; + if (savePrefix) { + _savePrefix = savePrefix; + } else if (_gameRef) { + _savePrefix = _gameRef->getGameId(); + } else { + _savePrefix = "wmesav"; + } +} + + +////////////////////////////////////////////////////////////////////////// +BasePersistenceManager::~BasePersistenceManager() { + cleanup(); + if (_deleteSingleton && BaseEngine::instance().getGameRef() == NULL) + BaseEngine::destroy(); +} + + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::cleanup() { + /* if (_buffer) { + if (_saving) free(_buffer); + else delete[] _buffer; // allocated by file manager + } + _buffer = NULL; + + _bufferSize = 0;*/ + _offset = 0; + + delete[] _richBuffer; + _richBuffer = NULL; + _richBufferSize = 0; + + delete[] _savedDescription; + _savedDescription = NULL; // ref to buffer +// _savedTimestamp = 0; + _savedVerMajor = _savedVerMinor = _savedVerBuild = 0; + _savedExtMajor = _savedExtMinor = 0; + + _thumbnailDataSize = 0; + if (_thumbnailData) { + delete[] _thumbnailData; + _thumbnailData = NULL; + } + + delete _loadStream; + delete _saveStream; + _loadStream = NULL; + _saveStream = NULL; +} + +Common::String BasePersistenceManager::getFilenameForSlot(int slot) const { + // 3 Digits, to allow for one save-slot for autosave + slot 1 - 100 (which will be numbered 0-99 filename-wise) + return Common::String::format("%s-save%03d.wsv", _savePrefix.c_str(), slot); +} + +void BasePersistenceManager::getSaveStateDesc(int slot, SaveStateDescriptor &desc) { + Common::String filename = getFilenameForSlot(slot); + debugC(kWintermuteDebugSaveGame, "Trying to list savegame %s in slot %d", filename.c_str(), slot); + if (DID_FAIL(readHeader(filename))) { + warning("getSavedDesc(%d) - Failed for %s", slot, filename.c_str()); + return; + } + desc.setSaveSlot(slot); + desc.setDescription(_savedDescription); + desc.setDeletableFlag(true); + desc.setWriteProtectedFlag(false); + + if (_thumbnailDataSize > 0) { + Common::MemoryReadStream thumbStream(_thumbnailData, _thumbnailDataSize); + Graphics::BitmapDecoder bmpDecoder; + if (bmpDecoder.loadStream(thumbStream)) { + Graphics::Surface *surf = new Graphics::Surface; + surf = bmpDecoder.getSurface()->convertTo(g_system->getOverlayFormat()); + desc.setThumbnail(surf); + } + } + + desc.setSaveDate(_savedTimestamp.tm_year, _savedTimestamp.tm_mon, _savedTimestamp.tm_mday); + desc.setSaveTime(_savedTimestamp.tm_hour, _savedTimestamp.tm_min); + desc.setPlayTime(0); +} + +void BasePersistenceManager::deleteSaveSlot(int slot) { + Common::String filename = getFilenameForSlot(slot); + g_system->getSavefileManager()->removeSavefile(filename); +} + +uint32 BasePersistenceManager::getMaxUsedSlot() { + Common::String saveMask = Common::String::format("%s-save???.wsv", _savePrefix.c_str()); + Common::StringArray saves = g_system->getSavefileManager()->listSavefiles(saveMask); + Common::StringArray::iterator it = saves.begin(); + int ret = -1; + for (; it != saves.end(); ++it) { + int num = -1; + sscanf(it->c_str(), "save%d", &num); + ret = MAX(ret, num); + } + return ret; +} + +bool BasePersistenceManager::getSaveExists(int slot) { + Common::String filename = getFilenameForSlot(slot); + if (DID_FAIL(readHeader(filename))) { + return false; + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::initSave(const char *desc) { + if (!desc) { + return STATUS_FAILED; + } + + cleanup(); + _saving = true; + + _saveStream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES); + + if (_saveStream) { + // get thumbnails + if (!_gameRef->_cachedThumbnail) { + _gameRef->_cachedThumbnail = new BaseSaveThumbHelper(_gameRef); + if (DID_FAIL(_gameRef->_cachedThumbnail->storeThumbnail(true))) { + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + } + } + + uint32 magic = DCGF_MAGIC; + putDWORD(magic); + + magic = SAVE_MAGIC_2; + putDWORD(magic); + + byte verMajor, verMinor, extMajor, extMinor; + _gameRef->getVersion(&verMajor, &verMinor, &extMajor, &extMinor); + //uint32 version = MAKELONG(MAKEWORD(VerMajor, VerMinor), MAKEWORD(ExtMajor, ExtMinor)); + _saveStream->writeByte(verMajor); + _saveStream->writeByte(verMinor); + _saveStream->writeByte(extMajor); + _saveStream->writeByte(extMinor); + + // new in ver 2 + putDWORD((uint32)DCGF_VER_BUILD); + putString(_gameRef->getName()); + + // thumbnail data size + bool thumbnailOK = false; + + if (_gameRef->_cachedThumbnail) { + if (_gameRef->_cachedThumbnail->_thumbnail) { + Common::MemoryWriteStreamDynamic thumbStream(DisposeAfterUse::YES); + if (_gameRef->_cachedThumbnail->_thumbnail->writeBMPToStream(&thumbStream)) { + _saveStream->writeUint32LE(thumbStream.size()); + _saveStream->write(thumbStream.getData(), thumbStream.size()); + } else { + _saveStream->writeUint32LE(0); + } + + thumbnailOK = true; + } + } + if (!thumbnailOK) { + putDWORD(0); + } + + // in any case, destroy the cached thumbnail once used + delete _gameRef->_cachedThumbnail; + _gameRef->_cachedThumbnail = NULL; + + uint32 dataOffset = _offset + + sizeof(uint32) + // data offset + sizeof(uint32) + strlen(desc) + 1 + // description + sizeof(uint32); // timestamp + + putDWORD(dataOffset); + putString(desc); + + g_system->getTimeAndDate(_savedTimestamp); + putTimeDate(_savedTimestamp); + _savedPlayTime = g_system->getMillis(); + _saveStream->writeUint32LE(_savedPlayTime); + } + return STATUS_OK; +} + +bool BasePersistenceManager::readHeader(const Common::String &filename) { + cleanup(); + + _saving = false; + + _loadStream = g_system->getSavefileManager()->openForLoading(filename); + //_buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &_bufferSize); + if (_loadStream) { + uint32 magic; + magic = getDWORD(); + + if (magic != DCGF_MAGIC) { + cleanup(); + return STATUS_FAILED; + } + + magic = getDWORD(); + + if (magic == SAVE_MAGIC || magic == SAVE_MAGIC_2) { + _savedVerMajor = _loadStream->readByte(); + _savedVerMinor = _loadStream->readByte(); + _savedExtMajor = _loadStream->readByte(); + _savedExtMinor = _loadStream->readByte(); + + if (magic == SAVE_MAGIC_2) { + _savedVerBuild = (byte)getDWORD(); + _savedName = getStringObj(); + + // load thumbnail + _thumbnailDataSize = getDWORD(); + if (_thumbnailDataSize > 0) { + _thumbnailData = new byte[_thumbnailDataSize]; + if (_thumbnailData) { + getBytes(_thumbnailData, _thumbnailDataSize); + } else { + _thumbnailDataSize = 0; + } + } + } else { + _savedVerBuild = 35; // last build with ver1 savegames + } + + uint32 dataOffset = getDWORD(); + + _savedDescription = getString(); + _savedTimestamp = getTimeDate(); + _savedPlayTime = _loadStream->readUint32LE(); + + _offset = dataOffset; + + return STATUS_OK; + } + } + + cleanup(); + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::initLoad(const Common::String &filename) { + if (DID_FAIL(readHeader(filename))) { + cleanup(); + return STATUS_FAILED; + } + _saving = false; + + if (_savedName == "" || scumm_stricmp(_savedName.c_str(), _gameRef->getName()) != 0) { + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game name doesn't match current game"); + cleanup(); + return STATUS_FAILED; + } + + // if save is newer version than we are, fail + if (_savedVerMajor > DCGF_VER_MAJOR || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor > DCGF_VER_MINOR) || + (_savedVerMajor == DCGF_VER_MAJOR && _savedVerMinor == DCGF_VER_MINOR && _savedVerBuild > DCGF_VER_BUILD) + ) { + + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game version is newer than current game"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + } + + // if save is older than the minimal version we support + if (_savedVerMajor < SAVEGAME_VER_MAJOR || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor < SAVEGAME_VER_MINOR) || + (_savedVerMajor == SAVEGAME_VER_MAJOR && _savedVerMinor == SAVEGAME_VER_MINOR && _savedVerBuild < SAVEGAME_VER_BUILD) + ) { + debugC(kWintermuteDebugSaveGame, "ERROR: Saved game is too old and cannot be used by this version of game engine"); + debugC(kWintermuteDebugSaveGame, "ERROR: Expected %d.%d.%d got %d.%d.%d", DCGF_VER_MAJOR, DCGF_VER_MINOR, DCGF_VER_BUILD, _savedVerMajor, _savedVerMinor, _savedVerBuild); + cleanup(); + return STATUS_FAILED; + + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::saveFile(const Common::String &filename) { + byte *prefixBuffer = _richBuffer; + uint32 prefixSize = _richBufferSize; + byte *buffer = ((Common::MemoryWriteStreamDynamic *)_saveStream)->getData(); + uint32 bufferSize = ((Common::MemoryWriteStreamDynamic *)_saveStream)->size(); + + Common::SaveFileManager *saveMan = ((WintermuteEngine *)g_engine)->getSaveFileMan(); + Common::OutSaveFile *file = saveMan->openForSaving(filename); + file->write(prefixBuffer, prefixSize); + file->write(buffer, bufferSize); + bool retVal = !file->err(); + file->finalize(); + delete file; + return retVal; +} + + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::putBytes(byte *buffer, uint32 size) { + _saveStream->write(buffer, size); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::getBytes(byte *buffer, uint32 size) { + _loadStream->read(buffer, size); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::putDWORD(uint32 val) { + _saveStream->writeUint32LE(val); +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BasePersistenceManager::getDWORD() { + uint32 ret = _loadStream->readUint32LE(); + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +void BasePersistenceManager::putString(const Common::String &val) { + if (!val.size()) { + putString("(null)"); + } else { + _saveStream->writeUint32LE(val.size()); + _saveStream->writeString(val); + } +} + +Common::String BasePersistenceManager::getStringObj() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + Common::String retString = ret; + delete[] ret; + + if (retString == "(null)") { + retString = ""; + } + + return retString; +} + +////////////////////////////////////////////////////////////////////////// +char *BasePersistenceManager::getString() { + uint32 len = _loadStream->readUint32LE(); + char *ret = new char[len + 1]; + _loadStream->read(ret, len); + ret[len] = '\0'; + + if (!strcmp(ret, "(null)")) { + delete[] ret; + return NULL; + } else { + return ret; + } +} + +bool BasePersistenceManager::putTimeDate(const TimeDate &t) { + _saveStream->writeSint32LE(t.tm_sec); + _saveStream->writeSint32LE(t.tm_min); + _saveStream->writeSint32LE(t.tm_hour); + _saveStream->writeSint32LE(t.tm_mday); + _saveStream->writeSint32LE(t.tm_mon); + _saveStream->writeSint32LE(t.tm_year); + // _saveStream->writeSint32LE(t.tm_wday); //TODO: Add this in when merging next + + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; +} + +TimeDate BasePersistenceManager::getTimeDate() { + TimeDate t; + t.tm_sec = _loadStream->readSint32LE(); + t.tm_min = _loadStream->readSint32LE(); + t.tm_hour = _loadStream->readSint32LE(); + t.tm_mday = _loadStream->readSint32LE(); + t.tm_mon = _loadStream->readSint32LE(); + t.tm_year = _loadStream->readSint32LE(); + // t.tm_wday = _loadStream->readSint32LE(); //TODO: Add this in when merging next + return t; +} + +void BasePersistenceManager::putFloat(float val) { + Common::String str = Common::String::format("F%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +float BasePersistenceManager::getFloat() { + char *str = getString(); + float value = 0.0f; + int ret = sscanf(str, "F%f", &value); + if (ret != 1) { + warning("%s not parsed as float", str); + } + delete[] str; + return value; +} + +void BasePersistenceManager::putDouble(double val) { + Common::String str = Common::String::format("D%f", val); + str.format("D%f", val); + _saveStream->writeUint32LE(str.size()); + _saveStream->writeString(str); +} + +double BasePersistenceManager::getDouble() { + char *str = getString(); + float value = 0.0f; // TODO: Do we ever really need to carry a full double-precision number? + int ret = sscanf(str, "D%f", &value); + if (ret != 1) { + warning("%s not parsed as double", str); + } + delete[] str; + return value; +} + +////////////////////////////////////////////////////////////////////////// +// bool +bool BasePersistenceManager::transfer(const char *name, bool *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// int +bool BasePersistenceManager::transfer(const char *name, int *val) { + if (_saving) { + _saveStream->writeSint32LE(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = _loadStream->readSint32LE(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// DWORD +bool BasePersistenceManager::transfer(const char *name, uint32 *val) { + if (_saving) { + _saveStream->writeUint32LE(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = _loadStream->readUint32LE(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// float +bool BasePersistenceManager::transfer(const char *name, float *val) { + if (_saving) { + putFloat(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = getFloat(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// double +bool BasePersistenceManager::transfer(const char *name, double *val) { + if (_saving) { + putDouble(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = getDouble(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// char* +bool BasePersistenceManager::transfer(const char *name, char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// const char* +bool BasePersistenceManager::transfer(const char *name, const char **val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + *val = str; + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +// Common::String +bool BasePersistenceManager::transfer(const char *name, Common::String *val) { + if (_saving) { + putString(*val); + return STATUS_OK; + } else { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + *val = str; + delete[] str; + } else { + *val = ""; + } + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::transfer(const char *name, AnsiStringArray &val) { + size_t size; + + if (_saving) { + size = val.size(); + _saveStream->writeUint32LE(size); + + for (AnsiStringArray::iterator it = val.begin(); it != val.end(); ++it) { + putString((*it).c_str()); + } + } else { + val.clear(); + size = _loadStream->readUint32LE(); + + for (size_t i = 0; i < size; i++) { + char *str = getString(); + if (_loadStream->err()) { + delete[] str; + return STATUS_FAILED; + } + if (str) { + val.push_back(str); + } + delete[] str; + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +// BYTE +bool BasePersistenceManager::transfer(const char *name, byte *val) { + if (_saving) { + _saveStream->writeByte(*val); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + *val = _loadStream->readByte(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// RECT +bool BasePersistenceManager::transfer(const char *name, Rect32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->left); + _saveStream->writeSint32LE(val->top); + _saveStream->writeSint32LE(val->right); + _saveStream->writeSint32LE(val->bottom); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + val->left = _loadStream->readSint32LE(); + val->top = _loadStream->readSint32LE(); + val->right = _loadStream->readSint32LE(); + val->bottom = _loadStream->readSint32LE(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// POINT +bool BasePersistenceManager::transfer(const char *name, Point32 *val) { + if (_saving) { + _saveStream->writeSint32LE(val->x); + _saveStream->writeSint32LE(val->y); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + val->x = _loadStream->readSint32LE(); + val->y = _loadStream->readSint32LE(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// Vector2 +bool BasePersistenceManager::transfer(const char *name, Vector2 *val) { + if (_saving) { + putFloat(val->x); + putFloat(val->y); + if (_saveStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } else { + val->x = getFloat(); + val->y = getFloat(); + if (_loadStream->err()) { + return STATUS_FAILED; + } + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +// generic pointer +bool BasePersistenceManager::transfer(const char *name, void *val) { + int classID = -1, instanceID = -1; + + if (_saving) { + SystemClassRegistry::getInstance()->getPointerID(*(void **)val, &classID, &instanceID); + if (*(void **)val != NULL && (classID == -1 || instanceID == -1)) { + debugC(kWintermuteDebugSaveGame, "Warning: invalid instance '%s'", name); + } + + _saveStream->writeUint32LE(classID); + _saveStream->writeUint32LE(instanceID); + } else { + classID = _loadStream->readUint32LE(); + instanceID = _loadStream->readUint32LE(); + + *(void **)val = SystemClassRegistry::getInstance()->idToPointer(classID, instanceID); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BasePersistenceManager::checkVersion(byte verMajor, byte verMinor, byte verBuild) { + if (_saving) { + return true; + } + + // it's ok if we are same or newer than the saved game + if (verMajor > _savedVerMajor || + (verMajor == _savedVerMajor && verMinor > _savedVerMinor) || + (verMajor == _savedVerMajor && verMinor == _savedVerMinor && verBuild > _savedVerBuild) + ) { + return false; + } + + return true; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_persistence_manager.h b/engines/wintermute/base/base_persistence_manager.h index fb5a73d0d3..a262c92a0b 100644 --- a/engines/wintermute/base/base_persistence_manager.h +++ b/engines/wintermute/base/base_persistence_manager.h @@ -1,118 +1,118 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H -#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H - - -#include "engines/wintermute/dctypes.h" -#include "engines/wintermute/math/rect32.h" -#include "engines/savestate.h" -#include "common/stream.h" -#include "common/str.h" -#include "common/system.h" -#include "common/rect.h" - -namespace Wintermute { - -class Vector2; -class BaseGame; -class BasePersistenceManager { -public: - char *_savedDescription; - Common::String _savePrefix; - Common::String _savedName; - bool saveFile(const Common::String &filename); - uint32 getDWORD(); - void putDWORD(uint32 val); - char *getString(); - Common::String getStringObj(); - void putString(const Common::String &val); - float getFloat(); - void putFloat(float val); - double getDouble(); - void putDouble(double val); - void cleanup(); - void getSaveStateDesc(int slot, SaveStateDescriptor &desc); - void deleteSaveSlot(int slot); - uint32 getMaxUsedSlot(); - bool getSaveExists(int slot); - bool initLoad(const Common::String &filename); - bool initSave(const char *desc); - bool getBytes(byte *buffer, uint32 size); - bool putBytes(byte *buffer, uint32 size); - uint32 _offset; - - bool getIsSaving() { return _saving; } - - uint32 _richBufferSize; - byte *_richBuffer; - - bool transfer(const char *name, void *val); - bool transfer(const char *name, int *val); - bool transfer(const char *name, uint32 *val); - bool transfer(const char *name, float *val); - bool transfer(const char *name, double *val); - bool transfer(const char *name, bool *val); - bool transfer(const char *name, byte *val); - bool transfer(const char *name, Rect32 *val); - bool transfer(const char *name, Point32 *val); - bool transfer(const char *name, const char **val); - bool transfer(const char *name, char **val); - bool transfer(const char *name, Common::String *val); - bool transfer(const char *name, Vector2 *val); - bool transfer(const char *name, AnsiStringArray &Val); - BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); - virtual ~BasePersistenceManager(); - bool checkVersion(byte verMajor, byte verMinor, byte verBuild); - - uint32 _thumbnailDataSize; - byte *_thumbnailData; - Common::String getFilenameForSlot(int slot) const; -private: - bool _deleteSingleton; - bool readHeader(const Common::String &filename); - TimeDate getTimeDate(); - bool putTimeDate(const TimeDate &t); - Common::WriteStream *_saveStream; - Common::SeekableReadStream *_loadStream; - TimeDate _savedTimestamp; - uint32 _savedPlayTime; - byte _savedVerMajor; - byte _savedVerMinor; - byte _savedVerBuild; - byte _savedExtMajor; - byte _savedExtMinor; - bool _saving; - // Separate from Base, as this class can do SOME operations without a _gameRef. - BaseGame *_gameRef; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PERSISTENCE_MANAGER_H +#define WINTERMUTE_BASE_PERSISTENCE_MANAGER_H + + +#include "engines/wintermute/dctypes.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/savestate.h" +#include "common/stream.h" +#include "common/str.h" +#include "common/system.h" +#include "common/rect.h" + +namespace Wintermute { + +class Vector2; +class BaseGame; +class BasePersistenceManager { +public: + char *_savedDescription; + Common::String _savePrefix; + Common::String _savedName; + bool saveFile(const Common::String &filename); + uint32 getDWORD(); + void putDWORD(uint32 val); + char *getString(); + Common::String getStringObj(); + void putString(const Common::String &val); + float getFloat(); + void putFloat(float val); + double getDouble(); + void putDouble(double val); + void cleanup(); + void getSaveStateDesc(int slot, SaveStateDescriptor &desc); + void deleteSaveSlot(int slot); + uint32 getMaxUsedSlot(); + bool getSaveExists(int slot); + bool initLoad(const Common::String &filename); + bool initSave(const char *desc); + bool getBytes(byte *buffer, uint32 size); + bool putBytes(byte *buffer, uint32 size); + uint32 _offset; + + bool getIsSaving() { return _saving; } + + uint32 _richBufferSize; + byte *_richBuffer; + + bool transfer(const char *name, void *val); + bool transfer(const char *name, int *val); + bool transfer(const char *name, uint32 *val); + bool transfer(const char *name, float *val); + bool transfer(const char *name, double *val); + bool transfer(const char *name, bool *val); + bool transfer(const char *name, byte *val); + bool transfer(const char *name, Rect32 *val); + bool transfer(const char *name, Point32 *val); + bool transfer(const char *name, const char **val); + bool transfer(const char *name, char **val); + bool transfer(const char *name, Common::String *val); + bool transfer(const char *name, Vector2 *val); + bool transfer(const char *name, AnsiStringArray &Val); + BasePersistenceManager(const char *savePrefix = NULL, bool deleteSingleton = false); + virtual ~BasePersistenceManager(); + bool checkVersion(byte verMajor, byte verMinor, byte verBuild); + + uint32 _thumbnailDataSize; + byte *_thumbnailData; + Common::String getFilenameForSlot(int slot) const; +private: + bool _deleteSingleton; + bool readHeader(const Common::String &filename); + TimeDate getTimeDate(); + bool putTimeDate(const TimeDate &t); + Common::WriteStream *_saveStream; + Common::SeekableReadStream *_loadStream; + TimeDate _savedTimestamp; + uint32 _savedPlayTime; + byte _savedVerMajor; + byte _savedVerMinor; + byte _savedVerBuild; + byte _savedExtMajor; + byte _savedExtMinor; + bool _saving; + // Separate from Base, as this class can do SOME operations without a _gameRef. + BaseGame *_gameRef; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_point.cpp b/engines/wintermute/base/base_point.cpp index 73e7e4690a..fbd8960894 100644 --- a/engines/wintermute/base/base_point.cpp +++ b/engines/wintermute/base/base_point.cpp @@ -1,63 +1,63 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_point.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BasePoint, false) - -////////////////////////////////////////////////////////////////////////// -BasePoint::BasePoint() { - x = y = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint::~BasePoint() { - -} - - -////////////////////////////////////////////////////////////////////////// -BasePoint::BasePoint(int initX, int initY) { - x = initX; - y = initY; -} - -////////////////////////////////////////////////////////////////////////// -bool BasePoint::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(x)); - persistMgr->transfer(TMEMBER(y)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_point.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BasePoint, false) + +////////////////////////////////////////////////////////////////////////// +BasePoint::BasePoint() { + x = y = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint::~BasePoint() { + +} + + +////////////////////////////////////////////////////////////////////////// +BasePoint::BasePoint(int initX, int initY) { + x = initX; + y = initY; +} + +////////////////////////////////////////////////////////////////////////// +bool BasePoint::persist(BasePersistenceManager *persistMgr) { + + persistMgr->transfer(TMEMBER(x)); + persistMgr->transfer(TMEMBER(y)); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_point.h b/engines/wintermute/base/base_point.h index 43f8f960f1..c0bbd3102e 100644 --- a/engines/wintermute/base/base_point.h +++ b/engines/wintermute/base/base_point.h @@ -1,50 +1,50 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_POINT_H -#define WINTERMUTE_BASE_POINT_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BasePoint: public BaseClass { -public: - DECLARE_PERSISTENT(BasePoint, BaseClass) - BasePoint(); - BasePoint(int initX, int initY); - int y; - int x; - virtual ~BasePoint(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_POINT_H +#define WINTERMUTE_BASE_POINT_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BasePoint: public BaseClass { +public: + DECLARE_PERSISTENT(BasePoint, BaseClass) + BasePoint(); + BasePoint(int initX, int initY); + int y; + int x; + virtual ~BasePoint(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_quick_msg.cpp b/engines/wintermute/base/base_quick_msg.cpp index dfe25b474b..0a9907ac6b 100644 --- a/engines/wintermute/base/base_quick_msg.cpp +++ b/engines/wintermute/base/base_quick_msg.cpp @@ -1,57 +1,57 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_quick_msg.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { - _text = new char [strlen(text) + 1]; - if (_text) { - strcpy(_text, text); - } - _startTime = _gameRef->_currentTime; -} - - -////////////////////////////////////////////////////////////////////////// -BaseQuickMsg::~BaseQuickMsg() { - if (_text) { - delete[] _text; - } -} - - -////////////////////////////////////////////////////////////////////////// -char *BaseQuickMsg::getText() { - return _text; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_quick_msg.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseQuickMsg::BaseQuickMsg(BaseGame *inGame, const char *text) : BaseClass(inGame) { + _text = new char [strlen(text) + 1]; + if (_text) { + strcpy(_text, text); + } + _startTime = _gameRef->_currentTime; +} + + +////////////////////////////////////////////////////////////////////////// +BaseQuickMsg::~BaseQuickMsg() { + if (_text) { + delete[] _text; + } +} + + +////////////////////////////////////////////////////////////////////////// +char *BaseQuickMsg::getText() { + return _text; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index d00b302baf..4fed5ffc2e 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -1,48 +1,48 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_QUICKMSG_H -#define WINTERMUTE_BASE_QUICKMSG_H - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseQuickMsg : public BaseClass { -public: - char *getText(); - uint32 _startTime; - char *_text; - BaseQuickMsg(BaseGame *inGame, const char *Text); - virtual ~BaseQuickMsg(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_QUICKMSG_H +#define WINTERMUTE_BASE_QUICKMSG_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseQuickMsg : public BaseClass { +public: + char *getText(); + uint32 _startTime; + char *_text; + BaseQuickMsg(BaseGame *inGame, const char *Text); + virtual ~BaseQuickMsg(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index 4d7f3487f0..e332ffe9ff 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -1,535 +1,535 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_region.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" -#include - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseRegion, false) - -////////////////////////////////////////////////////////////////////////// -BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { - _active = true; - _editorSelectedPoint = -1; - _lastMimicScale = -1; - _lastMimicX = _lastMimicY = INT_MIN; - - BasePlatform::setRectEmpty(&_rect); -} - - -////////////////////////////////////////////////////////////////////////// -BaseRegion::~BaseRegion() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRegion::cleanup() { - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - - BasePlatform::setRectEmpty(&_rect); - _editorSelectedPoint = -1; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::createRegion() { - return DID_SUCCEED(getBoundingRect(&_rect)); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::pointInRegion(int x, int y) { - if (_points.size() < 3) { - return false; - } - - Point32 pt; - pt.x = x; - pt.y = y; - - Rect32 rect; - rect.left = x - 1; - rect.right = x + 2; - rect.top = y - 1; - rect.bottom = y + 2; - - if (BasePlatform::ptInRect(&_rect, pt)) { - return ptInPolygon(x, y); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::loadFile(const char *filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - bool ret; - - setFilename(filename); - - if (DID_FAIL(ret = loadBuffer(buffer, true))) { - _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); - } - - - delete[] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(REGION) -TOKEN_DEF(TEMPLATE) -TOKEN_DEF(NAME) -TOKEN_DEF(ACTIVE) -TOKEN_DEF(POINT) -TOKEN_DEF(CAPTION) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_SELECTED_POINT) -TOKEN_DEF(PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::loadBuffer(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(REGION) - TOKEN_TABLE(TEMPLATE) - TOKEN_TABLE(NAME) - TOKEN_TABLE(ACTIVE) - TOKEN_TABLE(POINT) - TOKEN_TABLE(CAPTION) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_SELECTED_POINT) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { - _gameRef->LOG(0, "'REGION' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - for (uint32 i = 0; i < _points.size(); i++) { - delete _points[i]; - } - _points.clear(); - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_TEMPLATE: - if (DID_FAIL(loadFile((char *)params))) { - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_CAPTION: - setCaption((char *)params); - break; - - case TOKEN_ACTIVE: - parser.scanStr((char *)params, "%b", &_active); - break; - - case TOKEN_POINT: { - int x, y; - parser.scanStr((char *)params, "%d,%d", &x, &y); - _points.add(new BasePoint(x, y)); - } - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_EDITOR_SELECTED_POINT: - parser.scanStr((char *)params, "%d", &_editorSelectedPoint); - break; - - case TOKEN_PROPERTY: - parseProperty(params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in REGION definition"); - return STATUS_FAILED; - } - - createRegion(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // AddPoint - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AddPoint") == 0) { - stack->correctParams(2); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - _points.add(new BasePoint(x, y)); - createRegion(); - - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertPoint") == 0) { - stack->correctParams(3); - int index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (index >= 0 && index < (int32)_points.size()) { - _points.insert_at(index, new BasePoint(x, y)); - createRegion(); - - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPoint") == 0) { - stack->correctParams(3); - int index = stack->pop()->getInt(); - int x = stack->pop()->getInt(); - int y = stack->pop()->getInt(); - - if (index >= 0 && index < (int32)_points.size()) { - _points[index]->x = x; - _points[index]->y = y; - createRegion(); - - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemovePoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemovePoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < (int32)_points.size()) { - delete _points[index]; - _points[index] = NULL; - - _points.remove_at(index); - createRegion(); - - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPoint - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPoint") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(); - - if (index >= 0 && index < (int32)_points.size()) { - ScValue *val = stack->getPushValue(); - if (val) { - val->setProperty("X", _points[index]->x); - val->setProperty("Y", _points[index]->y); - } - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseRegion::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("region"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(getName()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _scValue->setBool(_active); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumPoints - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { - _scValue->setInt(_points.size()); - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Active - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { - _active = value->getBool(); - return STATUS_OK; - } else { - return BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseRegion::scToString() { - return "[region]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { - if (!nameOverride) { - buffer->putTextIndent(indent, "REGION {\n"); - } else { - buffer->putTextIndent(indent, "%s {\n", nameOverride); - } - - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); - buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); - - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (uint32 i = 0; i < _points.size(); i++) { - buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); - } - - if (_scProp) { - _scProp->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_active)); - persistMgr->transfer(TMEMBER(_editorSelectedPoint)); - persistMgr->transfer(TMEMBER(_lastMimicScale)); - persistMgr->transfer(TMEMBER(_lastMimicX)); - persistMgr->transfer(TMEMBER(_lastMimicY)); - _points.persist(persistMgr); - - return STATUS_OK; -} - - -typedef struct { - double x, y; -} dPoint; - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::ptInPolygon(int x, int y) { - if (_points.size() < 3) { - return false; - } - - int counter = 0; - double xinters; - dPoint p, p1, p2; - - p.x = (double)x; - p.y = (double)y; - - p1.x = (double)_points[0]->x; - p1.y = (double)_points[0]->y; - - for (uint32 i = 1; i <= _points.size(); i++) { - p2.x = (double)_points[i % _points.size()]->x; - p2.y = (double)_points[i % _points.size()]->y; - - if (p.y > MIN(p1.y, p2.y)) { - if (p.y <= MAX(p1.y, p2.y)) { - if (p.x <= MAX(p1.x, p2.x)) { - if (p1.y != p2.y) { - xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; - if (p1.x == p2.x || p.x <= xinters) { - counter++; - } - } - } - } - } - p1 = p2; - } - - if (counter % 2 == 0) { - return false; - } else { - return true; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::getBoundingRect(Rect32 *rect) { - if (_points.size() == 0) { - BasePlatform::setRectEmpty(rect); - } else { - int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; - - for (uint32 i = 0; i < _points.size(); i++) { - minX = MIN(minX, _points[i]->x); - minY = MIN(minY, _points[i]->y); - - maxX = MAX(maxX, _points[i]->x); - maxY = MAX(maxY, _points[i]->y); - } - BasePlatform::setRect(rect, minX, minY, maxX, maxY); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { - if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { - return STATUS_OK; - } - - cleanup(); - - for (uint32 i = 0; i < region->_points.size(); i++) { - int xVal, yVal; - - xVal = (int)((float)region->_points[i]->x * scale / 100.0f); - yVal = (int)((float)region->_points[i]->y * scale / 100.0f); - - _points.add(new BasePoint(xVal + x, yVal + y)); - } - - _lastMimicScale = scale; - _lastMimicX = x; - _lastMimicY = y; - - return createRegion() ? STATUS_OK : STATUS_FAILED; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseRegion, false) + +////////////////////////////////////////////////////////////////////////// +BaseRegion::BaseRegion(BaseGame *inGame) : BaseObject(inGame) { + _active = true; + _editorSelectedPoint = -1; + _lastMimicScale = -1; + _lastMimicX = _lastMimicY = INT_MIN; + + BasePlatform::setRectEmpty(&_rect); +} + + +////////////////////////////////////////////////////////////////////////// +BaseRegion::~BaseRegion() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRegion::cleanup() { + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + + BasePlatform::setRectEmpty(&_rect); + _editorSelectedPoint = -1; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::createRegion() { + return DID_SUCCEED(getBoundingRect(&_rect)); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::pointInRegion(int x, int y) { + if (_points.size() < 3) { + return false; + } + + Point32 pt; + pt.x = x; + pt.y = y; + + Rect32 rect; + rect.left = x - 1; + rect.right = x + 2; + rect.top = y - 1; + rect.bottom = y + 2; + + if (BasePlatform::ptInRect(&_rect, pt)) { + return ptInPolygon(x, y); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::loadFile(const char *filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseRegion::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + bool ret; + + setFilename(filename); + + if (DID_FAIL(ret = loadBuffer(buffer, true))) { + _gameRef->LOG(0, "Error parsing REGION file '%s'", filename); + } + + + delete[] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(REGION) +TOKEN_DEF(TEMPLATE) +TOKEN_DEF(NAME) +TOKEN_DEF(ACTIVE) +TOKEN_DEF(POINT) +TOKEN_DEF(CAPTION) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_SELECTED_POINT) +TOKEN_DEF(PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::loadBuffer(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(REGION) + TOKEN_TABLE(TEMPLATE) + TOKEN_TABLE(NAME) + TOKEN_TABLE(ACTIVE) + TOKEN_TABLE(POINT) + TOKEN_TABLE(CAPTION) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_SELECTED_POINT) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_REGION) { + _gameRef->LOG(0, "'REGION' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + for (uint32 i = 0; i < _points.size(); i++) { + delete _points[i]; + } + _points.clear(); + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_TEMPLATE: + if (DID_FAIL(loadFile((char *)params))) { + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_CAPTION: + setCaption((char *)params); + break; + + case TOKEN_ACTIVE: + parser.scanStr((char *)params, "%b", &_active); + break; + + case TOKEN_POINT: { + int x, y; + parser.scanStr((char *)params, "%d,%d", &x, &y); + _points.add(new BasePoint(x, y)); + } + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_EDITOR_SELECTED_POINT: + parser.scanStr((char *)params, "%d", &_editorSelectedPoint); + break; + + case TOKEN_PROPERTY: + parseProperty(params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in REGION definition"); + return STATUS_FAILED; + } + + createRegion(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // AddPoint + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AddPoint") == 0) { + stack->correctParams(2); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + _points.add(new BasePoint(x, y)); + createRegion(); + + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertPoint") == 0) { + stack->correctParams(3); + int index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (index >= 0 && index < (int32)_points.size()) { + _points.insert_at(index, new BasePoint(x, y)); + createRegion(); + + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPoint") == 0) { + stack->correctParams(3); + int index = stack->pop()->getInt(); + int x = stack->pop()->getInt(); + int y = stack->pop()->getInt(); + + if (index >= 0 && index < (int32)_points.size()) { + _points[index]->x = x; + _points[index]->y = y; + createRegion(); + + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemovePoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemovePoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < (int32)_points.size()) { + delete _points[index]; + _points[index] = NULL; + + _points.remove_at(index); + createRegion(); + + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPoint + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPoint") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(); + + if (index >= 0 && index < (int32)_points.size()) { + ScValue *val = stack->getPushValue(); + if (val) { + val->setProperty("X", _points[index]->x); + val->setProperty("Y", _points[index]->y); + } + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseRegion::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("region"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(getName()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _scValue->setBool(_active); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumPoints + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumPoints") == 0) { + _scValue->setInt(_points.size()); + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Active + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Active") == 0) { + _active = value->getBool(); + return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseRegion::scToString() { + return "[region]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride) { + if (!nameOverride) { + buffer->putTextIndent(indent, "REGION {\n"); + } else { + buffer->putTextIndent(indent, "%s {\n", nameOverride); + } + + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "CAPTION=\"%s\"\n", getCaption()); + buffer->putTextIndent(indent + 2, "ACTIVE=%s\n", _active ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED_POINT=%d\n", _editorSelectedPoint); + + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (uint32 i = 0; i < _points.size(); i++) { + buffer->putTextIndent(indent + 2, "POINT {%d,%d}\n", _points[i]->x, _points[i]->y); + } + + if (_scProp) { + _scProp->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::persist(BasePersistenceManager *persistMgr) { + + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_active)); + persistMgr->transfer(TMEMBER(_editorSelectedPoint)); + persistMgr->transfer(TMEMBER(_lastMimicScale)); + persistMgr->transfer(TMEMBER(_lastMimicX)); + persistMgr->transfer(TMEMBER(_lastMimicY)); + _points.persist(persistMgr); + + return STATUS_OK; +} + + +typedef struct { + double x, y; +} dPoint; + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::ptInPolygon(int x, int y) { + if (_points.size() < 3) { + return false; + } + + int counter = 0; + double xinters; + dPoint p, p1, p2; + + p.x = (double)x; + p.y = (double)y; + + p1.x = (double)_points[0]->x; + p1.y = (double)_points[0]->y; + + for (uint32 i = 1; i <= _points.size(); i++) { + p2.x = (double)_points[i % _points.size()]->x; + p2.y = (double)_points[i % _points.size()]->y; + + if (p.y > MIN(p1.y, p2.y)) { + if (p.y <= MAX(p1.y, p2.y)) { + if (p.x <= MAX(p1.x, p2.x)) { + if (p1.y != p2.y) { + xinters = (p.y - p1.y) * (p2.x - p1.x) / (p2.y - p1.y) + p1.x; + if (p1.x == p2.x || p.x <= xinters) { + counter++; + } + } + } + } + } + p1 = p2; + } + + if (counter % 2 == 0) { + return false; + } else { + return true; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::getBoundingRect(Rect32 *rect) { + if (_points.size() == 0) { + BasePlatform::setRectEmpty(rect); + } else { + int minX = INT_MAX, minY = INT_MAX, maxX = INT_MIN, maxY = INT_MIN; + + for (uint32 i = 0; i < _points.size(); i++) { + minX = MIN(minX, _points[i]->x); + minY = MIN(minY, _points[i]->y); + + maxX = MAX(maxX, _points[i]->x); + maxY = MAX(maxY, _points[i]->y); + } + BasePlatform::setRect(rect, minX, minY, maxX, maxY); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRegion::mimic(BaseRegion *region, float scale, int x, int y) { + if (scale == _lastMimicScale && x == _lastMimicX && y == _lastMimicY) { + return STATUS_OK; + } + + cleanup(); + + for (uint32 i = 0; i < region->_points.size(); i++) { + int xVal, yVal; + + xVal = (int)((float)region->_points[i]->x * scale / 100.0f); + yVal = (int)((float)region->_points[i]->y * scale / 100.0f); + + _points.add(new BasePoint(xVal + x, yVal + y)); + } + + _lastMimicScale = scale; + _lastMimicX = x; + _lastMimicY = y; + + return createRegion() ? STATUS_OK : STATUS_FAILED; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index e7ae9bda13..8dd02fe928 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -1,69 +1,69 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_REGION_H -#define WINTERMUTE_BASE_REGION_H - -#include "engines/wintermute/base/base_point.h" -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class BaseRegion : public BaseObject { -public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; - void cleanup(); - bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); - bool getBoundingRect(Rect32 *rect); - bool ptInPolygon(int x, int y); - DECLARE_PERSISTENT(BaseRegion, BaseObject) - bool _active; - int _editorSelectedPoint; - BaseRegion(BaseGame *inGame); - virtual ~BaseRegion(); - bool pointInRegion(int x, int y); - bool createRegion(); - bool loadFile(const char *filename); - bool loadBuffer(byte *buffer, bool complete = true); - Rect32 _rect; - BaseArray _points; - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, NULL); } - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_REGION_H +#define WINTERMUTE_BASE_REGION_H + +#include "engines/wintermute/base/base_point.h" +#include "engines/wintermute/base/base_object.h" + +namespace Wintermute { + +class BaseRegion : public BaseObject { +public: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; + void cleanup(); + bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); + bool getBoundingRect(Rect32 *rect); + bool ptInPolygon(int x, int y); + DECLARE_PERSISTENT(BaseRegion, BaseObject) + bool _active; + int _editorSelectedPoint; + BaseRegion(BaseGame *inGame); + virtual ~BaseRegion(); + bool pointInRegion(int x, int y); + bool createRegion(); + bool loadFile(const char *filename); + bool loadBuffer(byte *buffer, bool complete = true); + Rect32 _rect; + BaseArray _points; + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, NULL); } + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 8cd15ccf1d..186e1234a8 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -1,80 +1,80 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_save_thumb_helper.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { - delete _thumbnail; - _thumbnail = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { - delete _thumbnail; - _thumbnail = NULL; - - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - if (doFlip) { - // when using opengl on windows it seems to be necessary to do this twice - // works normally for direct3d - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - - _gameRef->displayContent(false); - _gameRef->_renderer->flip(); - } - - BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); - if (!screenshot) { - return STATUS_FAILED; - } - - // normal thumbnail - if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { - _thumbnail = new BaseImage(); - _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); - } - - - delete screenshot; - screenshot = NULL; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_save_thumb_helper.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbHelper::BaseSaveThumbHelper(BaseGame *inGame) : BaseClass(inGame) { + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbHelper::~BaseSaveThumbHelper(void) { + delete _thumbnail; + _thumbnail = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbHelper::storeThumbnail(bool doFlip) { + delete _thumbnail; + _thumbnail = NULL; + + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + if (doFlip) { + // when using opengl on windows it seems to be necessary to do this twice + // works normally for direct3d + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + + _gameRef->displayContent(false); + _gameRef->_renderer->flip(); + } + + BaseImage *screenshot = _gameRef->_renderer->takeScreenshot(); + if (!screenshot) { + return STATUS_FAILED; + } + + // normal thumbnail + if (_gameRef->_thumbnailWidth > 0 && _gameRef->_thumbnailHeight > 0) { + _thumbnail = new BaseImage(); + _thumbnail->copyFrom(screenshot, _gameRef->_thumbnailWidth, _gameRef->_thumbnailHeight); + } + + + delete screenshot; + screenshot = NULL; + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_save_thumb_helper.h b/engines/wintermute/base/base_save_thumb_helper.h index 0af3103f71..8863508ac9 100644 --- a/engines/wintermute/base/base_save_thumb_helper.h +++ b/engines/wintermute/base/base_save_thumb_helper.h @@ -1,51 +1,51 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ -#ifndef WINTERMUTE_BASE_SAVE_THUMB_HELPER_H -#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseImage; - -class BaseSaveThumbHelper : public BaseClass { -public: - BaseSaveThumbHelper(BaseGame *inGame); - virtual ~BaseSaveThumbHelper(void); - bool storeThumbnail(bool doFlip = false); - - BaseImage *_thumbnail; -private: - BaseImage *_richThumbnail; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ +#ifndef WINTERMUTE_BASE_SAVE_THUMB_HELPER_H +#define WINTERMUTE_BASE_SAVE_THUMB_HELPER_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseImage; + +class BaseSaveThumbHelper : public BaseClass { +public: + BaseSaveThumbHelper(BaseGame *inGame); + virtual ~BaseSaveThumbHelper(void); + bool storeThumbnail(bool doFlip = false); + + BaseImage *_thumbnail; +private: + BaseImage *_richThumbnail; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index e4132351e0..d3e6078d43 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -1,502 +1,502 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/ad/ad_game.h" -#include "engines/wintermute/base/base_script_holder.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseScriptHolder, false) - -////////////////////////////////////////////////////////////////////// -BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { - setName(""); - - _freezable = true; - _filename = NULL; -} - - -////////////////////////////////////////////////////////////////////// -BaseScriptHolder::~BaseScriptHolder() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::cleanup() { - delete[] _filename; - _filename = NULL; - - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->finish(true); - _scripts[i]->_owner = NULL; - } - _scripts.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::setFilename(const char *filename) { - if (_filename != NULL) { - delete[] _filename; - _filename = NULL; - } - if (filename == NULL) { - return; - } - _filename = new char [strlen(filename) + 1]; - if (_filename != NULL) { - strcpy(_filename, filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { - int numHandlers = 0; - - bool ret = STATUS_FAILED; - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread) { - ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); - if (handler) { - //_scripts.add(handler); - numHandlers++; - ret = STATUS_OK; - } - } - } - if (numHandlers > 0 && unbreakable) { - _gameRef->_scEngine->tickUnbreakable(); - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // DEBUG_CrashMe - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "DEBUG_CrashMe") == 0) { - stack->correctParams(0); - byte *p = 0; - *p = 10; - stack->pushNULL(); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ApplyEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ApplyEvent") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - bool ret; - ret = applyEvent(val->getString()); - - if (DID_SUCCEED(ret)) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleEvent") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleEvent(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // CanHandleMethod - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CanHandleMethod") == 0) { - stack->correctParams(1); - stack->pushBool(canHandleMethod(stack->pop()->getString())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AttachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AttachScript") == 0) { - stack->correctParams(1); - stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DetachScript - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DetachScript") == 0) { - stack->correctParams(2); - const char *filename = stack->pop()->getString(); - bool killThreads = stack->pop()->getBool(false); - bool ret = false; - for (uint32 i = 0; i < _scripts.size(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - _scripts[i]->finish(killThreads); - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IsScriptRunning - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsScriptRunning") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - bool ret = false; - for (uint32 i = 0; i < _scripts.size(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { - ret = true; - break; - } - } - stack->pushBool(ret); - - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptHolder::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("script_holder"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { - _scValue->setString(getName()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name") == 0) { - setName(value->getString()); - return STATUS_OK; - } else { - return BaseScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptHolder::scToString() { - return "[script_holder]"; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { - return BaseClass::saveAsText(buffer, indent); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - if (persistMgr->getIsSaving()) { - const char *name = getName(); - persistMgr->transfer(TMEMBER(name)); - } else { - char *name; - persistMgr->transfer(TMEMBER(name)); - setName(name); - delete[] name; - } - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::addScript(const char *filename) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { - if (_scripts[i]->_state != SCRIPT_FINISHED) { - _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); - return STATUS_OK; - } - } - } - - ScScript *scr = _gameRef->_scEngine->runScript(filename, this); - if (!scr) { - if (_gameRef->_editorForceScripts) { - // editor hack - scr = new ScScript(_gameRef, _gameRef->_scEngine); - scr->_filename = new char[strlen(filename) + 1]; - strcpy(scr->_filename, filename); - scr->_state = SCRIPT_ERROR; - scr->_owner = this; - _scripts.add(scr); - _gameRef->_scEngine->_scripts.add(scr); - - return STATUS_OK; - } - return STATUS_FAILED; - } else { - scr->_freezable = _freezable; - _scripts.add(scr); - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::removeScript(ScScript *script) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] == script) { - _scripts.remove_at(i); - break; - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleEvent(const char *EventName) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { - return true; - } - } - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::canHandleMethod(const char *MethodName) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { - return true; - } - } - return false; -} - - -TOKEN_DEF_START -TOKEN_DEF(PROPERTY) -TOKEN_DEF(NAME) -TOKEN_DEF(VALUE) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(PROPERTY) - TOKEN_TABLE(NAME) - TOKEN_TABLE(VALUE) - TOKEN_TABLE_END - - byte *params; - int cmd; - BaseParser parser; - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { - _gameRef->LOG(0, "'PROPERTY' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - char *propName = NULL; - char *propValue = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_NAME: - delete[] propName; - propName = new char[strlen((char *)params) + 1]; - if (propName) { - strcpy(propName, (char *)params); - } else { - cmd = PARSERR_GENERIC; - } - break; - - case TOKEN_VALUE: - delete[] propValue; - propValue = new char[strlen((char *)params) + 1]; - if (propValue) { - strcpy(propValue, (char *)params); - } else { - cmd = PARSERR_GENERIC; - } - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Syntax error in PROPERTY definition"); - return STATUS_FAILED; - } - if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - _gameRef->LOG(0, "Error loading PROPERTY definition"); - return STATUS_FAILED; - } - - - ScValue *val = new ScValue(_gameRef); - val->setString(propValue); - scSetProperty(propName, val); - - delete val; - delete[] propName; - delete[] propValue; - propName = NULL; - propValue = NULL; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::makeFreezable(bool freezable) { - _freezable = freezable; - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->_freezable = freezable; - } - -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { - for (int i = _scripts.size() - 1; i >= 0; i--) { - if (_scripts[i]->canHandleMethod(methodName)) { - - ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); - if (thread) { - bool ret = thread->createMethodThread(_scripts[i], methodName); - if (DID_SUCCEED(ret)) { - _scripts[i]->_engine->_scripts.add(thread); - return thread; - } else { - delete thread; - } - } - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); - if (getName() && strcmp(getName(), "") != 0) { - strcat(buf, " Name: "); - strcat(buf, getName()); - } - if (_filename) { - strcat(buf, " File: "); - strcat(buf, _filename); - } -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeObject -////////////////////////////////////////////////////////////////////////// -bool BaseScriptHolder::sendEvent(const char *eventName) { - return DID_SUCCEED(applyEvent(eventName)); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/ad/ad_game.h" +#include "engines/wintermute/base/base_script_holder.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseScriptHolder, false) + +////////////////////////////////////////////////////////////////////// +BaseScriptHolder::BaseScriptHolder(BaseGame *inGame) : BaseScriptable(inGame) { + setName(""); + + _freezable = true; + _filename = NULL; +} + + +////////////////////////////////////////////////////////////////////// +BaseScriptHolder::~BaseScriptHolder() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::cleanup() { + delete[] _filename; + _filename = NULL; + + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->finish(true); + _scripts[i]->_owner = NULL; + } + _scripts.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::setFilename(const char *filename) { + if (_filename != NULL) { + delete[] _filename; + _filename = NULL; + } + if (filename == NULL) { + return; + } + _filename = new char [strlen(filename) + 1]; + if (_filename != NULL) { + strcpy(_filename, filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::applyEvent(const char *eventName, bool unbreakable) { + int numHandlers = 0; + + bool ret = STATUS_FAILED; + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread) { + ScScript *handler = _scripts[i]->invokeEventHandler(eventName, unbreakable); + if (handler) { + //_scripts.add(handler); + numHandlers++; + ret = STATUS_OK; + } + } + } + if (numHandlers > 0 && unbreakable) { + _gameRef->_scEngine->tickUnbreakable(); + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::listen(BaseScriptHolder *param1, uint32 param2) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // DEBUG_CrashMe + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "DEBUG_CrashMe") == 0) { + stack->correctParams(0); + byte *p = 0; + *p = 10; + stack->pushNULL(); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ApplyEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ApplyEvent") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + bool ret; + ret = applyEvent(val->getString()); + + if (DID_SUCCEED(ret)) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleEvent") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleEvent(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // CanHandleMethod + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CanHandleMethod") == 0) { + stack->correctParams(1); + stack->pushBool(canHandleMethod(stack->pop()->getString())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AttachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AttachScript") == 0) { + stack->correctParams(1); + stack->pushBool(DID_SUCCEED(addScript(stack->pop()->getString()))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DetachScript + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DetachScript") == 0) { + stack->correctParams(2); + const char *filename = stack->pop()->getString(); + bool killThreads = stack->pop()->getBool(false); + bool ret = false; + for (uint32 i = 0; i < _scripts.size(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + _scripts[i]->finish(killThreads); + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IsScriptRunning + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IsScriptRunning") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + bool ret = false; + for (uint32 i = 0; i < _scripts.size(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0 && _scripts[i]->_state != SCRIPT_FINISHED && _scripts[i]->_state != SCRIPT_ERROR) { + ret = true; + break; + } + } + stack->pushBool(ret); + + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseScriptHolder::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("script_holder"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Name") == 0) { + _scValue->setString(getName()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name") == 0) { + setName(value->getString()); + return STATUS_OK; + } else { + return BaseScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseScriptHolder::scToString() { + return "[script_holder]"; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::saveAsText(BaseDynamicBuffer *buffer, int indent) { + return BaseClass::saveAsText(buffer, indent); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + if (persistMgr->getIsSaving()) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + delete[] name; + } + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::addScript(const char *filename) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (scumm_stricmp(_scripts[i]->_filename, filename) == 0) { + if (_scripts[i]->_state != SCRIPT_FINISHED) { + _gameRef->LOG(0, "BaseScriptHolder::AddScript - trying to add script '%s' mutiple times (obj: '%s')", filename, getName()); + return STATUS_OK; + } + } + } + + ScScript *scr = _gameRef->_scEngine->runScript(filename, this); + if (!scr) { + if (_gameRef->_editorForceScripts) { + // editor hack + scr = new ScScript(_gameRef, _gameRef->_scEngine); + scr->_filename = new char[strlen(filename) + 1]; + strcpy(scr->_filename, filename); + scr->_state = SCRIPT_ERROR; + scr->_owner = this; + _scripts.add(scr); + _gameRef->_scEngine->_scripts.add(scr); + + return STATUS_OK; + } + return STATUS_FAILED; + } else { + scr->_freezable = _freezable; + _scripts.add(scr); + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::removeScript(ScScript *script) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] == script) { + _scripts.remove_at(i); + break; + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::canHandleEvent(const char *EventName) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleEvent(EventName)) { + return true; + } + } + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::canHandleMethod(const char *MethodName) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->canHandleMethod(MethodName)) { + return true; + } + } + return false; +} + + +TOKEN_DEF_START +TOKEN_DEF(PROPERTY) +TOKEN_DEF(NAME) +TOKEN_DEF(VALUE) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::parseProperty(byte *buffer, bool complete) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(PROPERTY) + TOKEN_TABLE(NAME) + TOKEN_TABLE(VALUE) + TOKEN_TABLE_END + + byte *params; + int cmd; + BaseParser parser; + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_PROPERTY) { + _gameRef->LOG(0, "'PROPERTY' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + char *propName = NULL; + char *propValue = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_NAME: + delete[] propName; + propName = new char[strlen((char *)params) + 1]; + if (propName) { + strcpy(propName, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } + break; + + case TOKEN_VALUE: + delete[] propValue; + propValue = new char[strlen((char *)params) + 1]; + if (propValue) { + strcpy(propValue, (char *)params); + } else { + cmd = PARSERR_GENERIC; + } + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Syntax error in PROPERTY definition"); + return STATUS_FAILED; + } + if (cmd == PARSERR_GENERIC || propName == NULL || propValue == NULL) { + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + _gameRef->LOG(0, "Error loading PROPERTY definition"); + return STATUS_FAILED; + } + + + ScValue *val = new ScValue(_gameRef); + val->setString(propValue); + scSetProperty(propName, val); + + delete val; + delete[] propName; + delete[] propValue; + propName = NULL; + propValue = NULL; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::makeFreezable(bool freezable) { + _freezable = freezable; + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->_freezable = freezable; + } + +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *BaseScriptHolder::invokeMethodThread(const char *methodName) { + for (int i = _scripts.size() - 1; i >= 0; i--) { + if (_scripts[i]->canHandleMethod(methodName)) { + + ScScript *thread = new ScScript(_gameRef, _scripts[i]->_engine); + if (thread) { + bool ret = thread->createMethodThread(_scripts[i], methodName); + if (DID_SUCCEED(ret)) { + _scripts[i]->_engine->_scripts.add(thread); + return thread; + } else { + delete thread; + } + } + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptHolder::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); + if (getName() && strcmp(getName(), "") != 0) { + strcat(buf, " Name: "); + strcat(buf, getName()); + } + if (_filename) { + strcat(buf, " File: "); + strcat(buf, _filename); + } +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeObject +////////////////////////////////////////////////////////////////////////// +bool BaseScriptHolder::sendEvent(const char *eventName) { + return DID_SUCCEED(applyEvent(eventName)); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index cab0d4f693..0c3d7a1a70 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -1,76 +1,76 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SCRIPTHOLDER_H -#define WINTERMUTE_BASE_SCRIPTHOLDER_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class BaseScriptHolder : public BaseScriptable { -public: - DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) - - BaseScriptHolder(BaseGame *inGame); - virtual ~BaseScriptHolder(); - virtual ScScript *invokeMethodThread(const char *methodName); - virtual void makeFreezable(bool freezable); - bool canHandleEvent(const char *eventName); - virtual bool canHandleMethod(const char *eventMethod); - bool cleanup(); - bool removeScript(ScScript *script); - bool addScript(const char *filename); - virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); - virtual bool listen(BaseScriptHolder *param1, uint32 param2); - bool applyEvent(const char *eventName, bool unbreakable = false); - void setFilename(const char *filename); - const char *getFilename() { return _filename; } - bool parseProperty(byte *buffer, bool complete = true); - bool _freezable; - bool _ready; - - BaseArray _scripts; - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void scDebuggerDesc(char *buf, int bufSize); - // IWmeObject -private: - char *_filename; -public: - virtual bool sendEvent(const char *eventName); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SCRIPTHOLDER_H +#define WINTERMUTE_BASE_SCRIPTHOLDER_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class BaseScriptHolder : public BaseScriptable { +public: + DECLARE_PERSISTENT(BaseScriptHolder, BaseScriptable) + + BaseScriptHolder(BaseGame *inGame); + virtual ~BaseScriptHolder(); + virtual ScScript *invokeMethodThread(const char *methodName); + virtual void makeFreezable(bool freezable); + bool canHandleEvent(const char *eventName); + virtual bool canHandleMethod(const char *eventMethod); + bool cleanup(); + bool removeScript(ScScript *script); + bool addScript(const char *filename); + virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent); + virtual bool listen(BaseScriptHolder *param1, uint32 param2); + bool applyEvent(const char *eventName, bool unbreakable = false); + void setFilename(const char *filename); + const char *getFilename() { return _filename; } + bool parseProperty(byte *buffer, bool complete = true); + bool _freezable; + bool _ready; + + BaseArray _scripts; + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void scDebuggerDesc(char *buf, int bufSize); + // IWmeObject +private: + char *_filename; +public: + virtual bool sendEvent(const char *eventName); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 6e5b30f7b6..143934402b 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -1,191 +1,191 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_scriptable.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseScriptable, false) - -////////////////////////////////////////////////////////////////////////// -BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) : BaseNamedObject(inGame) { - _refCount = 0; - - if (noValue) { - _scValue = NULL; - } else { - _scValue = new ScValue(_gameRef); - } - - _persistable = persistable; - - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseScriptable::~BaseScriptable() { - //if (_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); - delete _scValue; - delete _scProp; - _scValue = NULL; - _scProp = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - /* - stack->correctParams(0); - stack->pushNULL(); - script->runtimeError("Call to undefined method '%s'.", name); - - return STATUS_OK; - */ - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptable::scGetProperty(const char *name) { - if (!_scProp) { - _scProp = new ScValue(_gameRef); - } - if (_scProp) { - return _scProp->getProp(name); - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { - if (!_scProp) { - _scProp = new ScValue(_gameRef); - } - if (_scProp) { - return _scProp->setProp(name, value); - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseScriptable::scToString() { - return "[native object]"; -} - -////////////////////////////////////////////////////////////////////////// -void *BaseScriptable::scToMemBuffer() { - return (void *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseScriptable::scToInt() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -double BaseScriptable::scToFloat() { - return 0.0f; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::scToBool() { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetString(const char *val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetInt(int val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetFloat(double val) { -} - - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scSetBool(bool val) { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_refCount)); - persistMgr->transfer(TMEMBER(_scProp)); - persistMgr->transfer(TMEMBER(_scValue)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseScriptable::scCompare(BaseScriptable *val) { - if (this < val) { - return -1; - } else if (this > val) { - return 1; - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { - strcpy(buf, scToString()); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseScriptable::canHandleMethod(const char *eventMethod) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseScriptable, false) + +////////////////////////////////////////////////////////////////////////// +BaseScriptable::BaseScriptable(BaseGame *inGame, bool noValue, bool persistable) : BaseNamedObject(inGame) { + _refCount = 0; + + if (noValue) { + _scValue = NULL; + } else { + _scValue = new ScValue(_gameRef); + } + + _persistable = persistable; + + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseScriptable::~BaseScriptable() { + //if (_refCount>0) _gameRef->LOG(0, "Warning: Destroying object, _refCount=%d", _refCount); + delete _scValue; + delete _scProp; + _scValue = NULL; + _scProp = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + /* + stack->correctParams(0); + stack->pushNULL(); + script->runtimeError("Call to undefined method '%s'.", name); + + return STATUS_OK; + */ + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseScriptable::scGetProperty(const char *name) { + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->getProp(name); + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::scSetProperty(const char *name, ScValue *value) { + if (!_scProp) { + _scProp = new ScValue(_gameRef); + } + if (_scProp) { + return _scProp->setProp(name, value); + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseScriptable::scToString() { + return "[native object]"; +} + +////////////////////////////////////////////////////////////////////////// +void *BaseScriptable::scToMemBuffer() { + return (void *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseScriptable::scToInt() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +double BaseScriptable::scToFloat() { + return 0.0f; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::scToBool() { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetString(const char *val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetInt(int val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetFloat(double val) { +} + + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scSetBool(bool val) { +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_refCount)); + persistMgr->transfer(TMEMBER(_scProp)); + persistMgr->transfer(TMEMBER(_scValue)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseScriptable::scCompare(BaseScriptable *val) { + if (this < val) { + return -1; + } else if (this > val) { + return 1; + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseScriptable::scDebuggerDesc(char *buf, int bufSize) { + strcpy(buf, scToString()); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseScriptable::canHandleMethod(const char *eventMethod) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *BaseScriptable::invokeMethodThread(const char *methodName) { + return NULL; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index 11cb0bcf9f..b006e6e07c 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -1,83 +1,83 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SCRIPTABLE_H -#define WINTERMUTE_BASE_SCRIPTABLE_H - - -#include "engines/wintermute/base/base_named_object.h" -#include "engines/wintermute/persistent.h" - -namespace Wintermute { - -class ScValue; -class ScStack; -class ScScript; - -class BaseScriptable : public BaseNamedObject { -public: - virtual ScScript *invokeMethodThread(const char *methodName); - DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) - - BaseScriptable(BaseGame *inGame, bool noValue = false, bool persistable = true); - virtual ~BaseScriptable(); - - // high level scripting interface - virtual bool canHandleMethod(const char *eventMethod); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual ScValue *scGetProperty(const char *name); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - virtual void *scToMemBuffer(); - virtual int scToInt(); - virtual double scToFloat(); - virtual bool scToBool(); - virtual void scSetString(const char *val); - virtual void scSetInt(int val); - virtual void scSetFloat(double val); - virtual void scSetBool(bool val); - virtual int scCompare(BaseScriptable *val); - virtual void scDebuggerDesc(char *buf, int bufSize); - int _refCount; - ScValue *_scValue; - ScValue *_scProp; -}; - -// Implemented in their respective .cpp-files -BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack); -BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack); -BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack); -BaseScriptable *makeSXMath(BaseGame *inGame); -BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack); -BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); -BaseScriptable *makeSXStore(BaseGame *inGame); -BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SCRIPTABLE_H +#define WINTERMUTE_BASE_SCRIPTABLE_H + + +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/persistent.h" + +namespace Wintermute { + +class ScValue; +class ScStack; +class ScScript; + +class BaseScriptable : public BaseNamedObject { +public: + virtual ScScript *invokeMethodThread(const char *methodName); + DECLARE_PERSISTENT(BaseScriptable, BaseNamedObject) + + BaseScriptable(BaseGame *inGame, bool noValue = false, bool persistable = true); + virtual ~BaseScriptable(); + + // high level scripting interface + virtual bool canHandleMethod(const char *eventMethod); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + virtual void *scToMemBuffer(); + virtual int scToInt(); + virtual double scToFloat(); + virtual bool scToBool(); + virtual void scSetString(const char *val); + virtual void scSetInt(int val); + virtual void scSetFloat(double val); + virtual void scSetBool(bool val); + virtual int scCompare(BaseScriptable *val); + virtual void scDebuggerDesc(char *buf, int bufSize); + int _refCount; + ScValue *_scValue; + ScValue *_scProp; +}; + +// Implemented in their respective .cpp-files +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXMath(BaseGame *inGame); +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack); +BaseScriptable *makeSXStore(BaseGame *inGame); +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack); + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index ae0e844cb5..e2dd8bbd39 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -1,814 +1,814 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_frame.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseSprite, false) - -////////////////////////////////////////////////////////////////////// -BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { - _editorAllFrames = false; - _owner = Owner; - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////// -BaseSprite::~BaseSprite() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSprite::setDefaults() { - _currentFrame = -1; - _looping = false; - _lastFrameTime = 0; - setFilename(NULL); - _finished = false; - _changed = false; - _paused = false; - _continuous = false; - _moveX = _moveY = 0; - - _editorMuted = false; - _editorBgFile = NULL; - _editorBgOffsetX = _editorBgOffsetY = 0; - _editorBgAlpha = 0xFF; - _streamed = false; - _streamedKeepLoaded = false; - - setName(""); - - _precise = true; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSprite::cleanup() { - BaseScriptHolder::cleanup(); - - for (uint32 i = 0; i < _frames.size(); i++) { - delete _frames[i]; - } - _frames.clear(); - - delete[] _editorBgFile; - _editorBgFile = NULL; - - setDefaults(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { - getCurrentFrame(zoomX, zoomY); - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - return STATUS_OK; - } - - // move owner if allowed to - if (_changed && _owner && _owner->_movable) { - _owner->_posX += _moveX; - _owner->_posY += _moveY; - _owner->afterMove(); - - x = _owner->_posX; - y = _owner->_posY; - } - - // draw frame - return display(x, y, registerOwner, zoomX, zoomY, alpha); -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); - if (!file) { - _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); - if (_gameRef->_debugDebugMode) { - return loadFile("invalid_debug.bmp", lifeTime, cacheType); - } else { - return loadFile("invalid.bmp", lifeTime, cacheType); - } - } else { - BaseFileManager::getEngineInstance()->closeFile(file); - file = NULL; - } - - bool ret = STATUS_FAILED; - - AnsiString filePrefix = filename; - AnsiString ext = PathUtil::getExtension(filename); - ext.toLowercase(); - filePrefix.toLowercase(); - if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) { - BaseFrame *frame = new BaseFrame(_gameRef); - BaseSubFrame *subframe = new BaseSubFrame(_gameRef); - subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); - if (subframe->_surface == NULL) { - _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); - ret = STATUS_FAILED; - delete frame; - delete subframe; - } else { - subframe->setDefaultRect(); - frame->_subframes.add(subframe); - _frames.add(frame); - _currentFrame = 0; - ret = STATUS_OK; - } - } else { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer) { - if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { - _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); - } else { - ret = STATUS_OK; - } - delete[] buffer; - } - } - - setFilename(filename.c_str()); - - return ret; -} - - - -TOKEN_DEF_START -TOKEN_DEF(CONTINUOUS) -TOKEN_DEF(SPRITE) -TOKEN_DEF(LOOPING) -TOKEN_DEF(FRAME) -TOKEN_DEF(NAME) -TOKEN_DEF(PRECISE) -TOKEN_DEF(EDITOR_MUTED) -TOKEN_DEF(STREAMED_KEEP_LOADED) -TOKEN_DEF(STREAMED) -TOKEN_DEF(SCRIPT) -TOKEN_DEF(EDITOR_BG_FILE) -TOKEN_DEF(EDITOR_BG_OFFSET_X) -TOKEN_DEF(EDITOR_BG_OFFSET_Y) -TOKEN_DEF(EDITOR_BG_ALPHA) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(CONTINUOUS) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(LOOPING) - TOKEN_TABLE(FRAME) - TOKEN_TABLE(NAME) - TOKEN_TABLE(PRECISE) - TOKEN_TABLE(EDITOR_MUTED) - TOKEN_TABLE(STREAMED_KEEP_LOADED) - TOKEN_TABLE(STREAMED) - TOKEN_TABLE(SCRIPT) - TOKEN_TABLE(EDITOR_BG_FILE) - TOKEN_TABLE(EDITOR_BG_OFFSET_X) - TOKEN_TABLE(EDITOR_BG_OFFSET_Y) - TOKEN_TABLE(EDITOR_BG_ALPHA) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - byte *params; - int cmd; - BaseParser parser; - - cleanup(); - - - if (complete) { - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { - _gameRef->LOG(0, "'SPRITE' keyword expected."); - return STATUS_FAILED; - } - buffer = params; - } - - int frameCount = 1; - BaseFrame *frame; - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_CONTINUOUS: - parser.scanStr((char *)params, "%b", &_continuous); - break; - - case TOKEN_EDITOR_MUTED: - parser.scanStr((char *)params, "%b", &_editorMuted); - break; - - case TOKEN_SCRIPT: - addScript((char *)params); - break; - - case TOKEN_LOOPING: - parser.scanStr((char *)params, "%b", &_looping); - break; - - case TOKEN_PRECISE: - parser.scanStr((char *)params, "%b", &_precise); - break; - - case TOKEN_STREAMED: - parser.scanStr((char *)params, "%b", &_streamed); - if (_streamed && lifeTime == -1) { - lifeTime = 500; - cacheType = CACHE_ALL; - } - break; - - case TOKEN_STREAMED_KEEP_LOADED: - parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); - break; - - case TOKEN_NAME: - setName((char *)params); - break; - - case TOKEN_EDITOR_BG_FILE: - if (_gameRef->_editorMode) { - delete[] _editorBgFile; - _editorBgFile = new char[strlen((char *)params) + 1]; - if (_editorBgFile) { - strcpy(_editorBgFile, (char *)params); - } - } - break; - - case TOKEN_EDITOR_BG_OFFSET_X: - parser.scanStr((char *)params, "%d", &_editorBgOffsetX); - break; - - case TOKEN_EDITOR_BG_OFFSET_Y: - parser.scanStr((char *)params, "%d", &_editorBgOffsetY); - break; - - case TOKEN_EDITOR_BG_ALPHA: - parser.scanStr((char *)params, "%d", &_editorBgAlpha); - _editorBgAlpha = MIN(_editorBgAlpha, 255); - _editorBgAlpha = MAX(_editorBgAlpha, 0); - break; - - case TOKEN_FRAME: { - int frameLifeTime = lifeTime; - if (cacheType == CACHE_HALF && frameCount % 2 != 1) { - frameLifeTime = -1; - } - - frame = new BaseFrame(_gameRef); - - if (DID_FAIL(frame->loadBuffer(params, frameLifeTime, _streamedKeepLoaded))) { - delete frame; - _gameRef->LOG(0, "Error parsing frame %d", frameCount); - return STATUS_FAILED; - } - - _frames.add(frame); - frameCount++; - if (_currentFrame == -1) { - _currentFrame = 0; - } - } - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty(params, false); - break; - } - } - - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SPRITE definition"); - return STATUS_FAILED; - } - _canBreak = !_continuous; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void BaseSprite::reset() { - if (_frames.size() > 0) { - _currentFrame = 0; - } else { - _currentFrame = -1; - } - - killAllSounds(); - - _lastFrameTime = 0; - _finished = false; - _moveX = _moveY = 0; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { - //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; - - if (_currentFrame == -1) { - return false; - } - - uint32 timer; - if (_owner && _owner->_freezable) { - timer = _gameRef->_timer; - } else { - timer = _gameRef->_liveTimer; - } - - int lastFrame = _currentFrame; - - // get current frame - if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { - if (_currentFrame < (int32)_frames.size() - 1) { - _currentFrame++; - if (_continuous) { - _canBreak = (_currentFrame == (int32)_frames.size() - 1); - } - } else { - if (_looping) { - _currentFrame = 0; - _canBreak = true; - } else { - _finished = true; - _canBreak = true; - } - } - - _lastFrameTime = timer; - } - - _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); - - if (_lastFrameTime == 0) { - _lastFrameTime = timer; - _changed = true; - if (_continuous) { - _canBreak = (_currentFrame == (int32)_frames.size() - 1); - } - } - - if (_changed) { - _moveX = _frames[_currentFrame]->_moveX; - _moveY = _frames[_currentFrame]->_moveY; - - if (zoomX != 100 || zoomY != 100) { - _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); - _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); - } - } - - return _changed; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - return STATUS_OK; - } - - // on change... - if (_changed) { - if (_frames[_currentFrame]->_killSound) { - killAllSounds(); - } - applyEvent("FrameChanged"); - _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); - } - - // draw frame - return _frames[_currentFrame]->draw(x - _gameRef->_offsetX, y - _gameRef->_offsetY, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -BaseSurface *BaseSprite::getSurface() { - // only used for animated textures for 3D models - if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { - return NULL; - } - BaseFrame *frame = _frames[_currentFrame]; - if (frame && frame->_subframes.size() > 0) { - BaseSubFrame *subframe = frame->_subframes[0]; - if (subframe) { - return subframe->_surface; - } else { - return NULL; - } - } else { - return NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) { - return false; - } - - BasePlatform::setRectEmpty(rect); - for (uint32 i = 0; i < _frames.size(); i++) { - Rect32 frame; - Rect32 temp; - BasePlatform::copyRect(&temp, rect); - _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); - BasePlatform::unionRect(rect, &temp, &frame); - } - return true; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { - buffer->putTextIndent(indent, "SPRITE {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); - buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); - buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); - if (_streamed) { - buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); - - if (_streamedKeepLoaded) { - buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); - } - } - - if (_editorMuted) { - buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); - } - - if (_editorBgFile) { - buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); - buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); - buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); - } - - BaseScriptHolder::saveAsText(buffer, indent + 2); - - // scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); - } - - for (uint32 i = 0; i < _frames.size(); i++) { - _frames[i]->saveAsText(buffer, indent + 2); - } - - buffer->putTextIndent(indent, "}\n\n"); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::persist(BasePersistenceManager *persistMgr) { - BaseScriptHolder::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_canBreak)); - persistMgr->transfer(TMEMBER(_changed)); - persistMgr->transfer(TMEMBER(_paused)); - persistMgr->transfer(TMEMBER(_continuous)); - persistMgr->transfer(TMEMBER(_currentFrame)); - persistMgr->transfer(TMEMBER(_editorAllFrames)); - persistMgr->transfer(TMEMBER(_editorBgAlpha)); - persistMgr->transfer(TMEMBER(_editorBgFile)); - persistMgr->transfer(TMEMBER(_editorBgOffsetX)); - persistMgr->transfer(TMEMBER(_editorBgOffsetY)); - persistMgr->transfer(TMEMBER(_editorMuted)); - persistMgr->transfer(TMEMBER(_finished)); - - _frames.persist(persistMgr); - - persistMgr->transfer(TMEMBER(_lastFrameTime)); - persistMgr->transfer(TMEMBER(_looping)); - persistMgr->transfer(TMEMBER(_moveX)); - persistMgr->transfer(TMEMBER(_moveY)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_precise)); - persistMgr->transfer(TMEMBER(_streamed)); - persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetFrame") == 0) { - stack->correctParams(1); - int index = stack->pop()->getInt(-1); - if (index < 0 || index >= (int32)_frames.size()) { - script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); - stack->pushNULL(); - } else { - stack->pushNative(_frames[index], true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DeleteFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeleteFrame") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - if (val->isInt()) { - int index = val->getInt(-1); - if (index < 0 || index >= (int32)_frames.size()) { - script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); - } - } else { - BaseFrame *frame = (BaseFrame *)val->getNative(); - for (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i] == frame) { - if (i == (uint32)_currentFrame) { - _lastFrameTime = 0; - } - delete _frames[i]; - _frames.remove_at(i); - break; - } - } - } - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Reset - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Reset") == 0) { - stack->correctParams(0); - reset(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddFrame") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseFrame *frame = new BaseFrame(_gameRef); - if (filename != NULL) { - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) { - sub->setDefaultRect(); - frame->_subframes.add(sub); - } else { - delete sub; - } - } - _frames.add(frame); - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // InsertFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "InsertFrame") == 0) { - stack->correctParams(2); - int index = stack->pop()->getInt(); - if (index < 0) { - index = 0; - } - - ScValue *val = stack->pop(); - const char *filename = NULL; - if (!val->isNULL()) { - filename = val->getString(); - } - - BaseFrame *frame = new BaseFrame(_gameRef); - if (filename != NULL) { - BaseSubFrame *sub = new BaseSubFrame(_gameRef); - if (DID_SUCCEED(sub->setSurface(filename))) { - frame->_subframes.add(sub); - } else { - delete sub; - } - } - - if (index >= (int32)_frames.size()) { - _frames.add(frame); - } else { - _frames.insert_at(index, frame); - } - - stack->pushNative(frame, true); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _paused = true; - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Play - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Play") == 0) { - stack->correctParams(0); - _paused = false; - stack->pushNULL(); - return STATUS_OK; - } else { - return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseSprite::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("sprite"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // NumFrames (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { - _scValue->setInt(_frames.size()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { - _scValue->setInt(_currentFrame); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _scValue->setBool(_precise); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _scValue->setBool(_looping); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Owner (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { - if (_owner == NULL) { - _scValue->setNULL(); - } else { - _scValue->setNative(_owner, true); - } - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Finished (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { - _scValue->setBool(_finished); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Paused (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { - _scValue->setBool(_paused); - return _scValue; - } else { - return BaseScriptHolder::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // CurrentFrame - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "CurrentFrame") == 0) { - _currentFrame = value->getInt(0); - if (_currentFrame >= (int32)_frames.size() || _currentFrame < 0) { - _currentFrame = -1; - } - _lastFrameTime = 0; - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // PixelPerfect - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { - _precise = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Looping - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { - _looping = value->getBool(); - return STATUS_OK; - } else { - return BaseScriptHolder::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseSprite::scToString() { - return "[sprite]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSprite::killAllSounds() { - for (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i]->_sound) { - _frames[i]->_sound->stop(); - } - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseSprite, false) + +////////////////////////////////////////////////////////////////////// +BaseSprite::BaseSprite(BaseGame *inGame, BaseObject *Owner) : BaseScriptHolder(inGame) { + _editorAllFrames = false; + _owner = Owner; + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////// +BaseSprite::~BaseSprite() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSprite::setDefaults() { + _currentFrame = -1; + _looping = false; + _lastFrameTime = 0; + setFilename(NULL); + _finished = false; + _changed = false; + _paused = false; + _continuous = false; + _moveX = _moveY = 0; + + _editorMuted = false; + _editorBgFile = NULL; + _editorBgOffsetX = _editorBgOffsetY = 0; + _editorBgAlpha = 0xFF; + _streamed = false; + _streamedKeepLoaded = false; + + setName(""); + + _precise = true; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSprite::cleanup() { + BaseScriptHolder::cleanup(); + + for (uint32 i = 0; i < _frames.size(); i++) { + delete _frames[i]; + } + _frames.clear(); + + delete[] _editorBgFile; + _editorBgFile = NULL; + + setDefaults(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, uint32 alpha) { + getCurrentFrame(zoomX, zoomY); + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + return STATUS_OK; + } + + // move owner if allowed to + if (_changed && _owner && _owner->_movable) { + _owner->_posX += _moveX; + _owner->_posY += _moveY; + _owner->afterMove(); + + x = _owner->_posX; + y = _owner->_posY; + } + + // draw frame + return display(x, y, registerOwner, zoomX, zoomY, alpha); +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(filename); + if (!file) { + _gameRef->LOG(0, "BaseSprite::LoadFile failed for file '%s'", filename.c_str()); + if (_gameRef->_debugDebugMode) { + return loadFile("invalid_debug.bmp", lifeTime, cacheType); + } else { + return loadFile("invalid.bmp", lifeTime, cacheType); + } + } else { + BaseFileManager::getEngineInstance()->closeFile(file); + file = NULL; + } + + bool ret = STATUS_FAILED; + + AnsiString filePrefix = filename; + AnsiString ext = PathUtil::getExtension(filename); + ext.toLowercase(); + filePrefix.toLowercase(); + if (filePrefix.hasPrefix("savegame:") || (ext == "bmp") || (ext == "tga") || (ext == "png") || (ext == "jpg")) { + BaseFrame *frame = new BaseFrame(_gameRef); + BaseSubFrame *subframe = new BaseSubFrame(_gameRef); + subframe->setSurface(filename, true, 0, 0, 0, lifeTime, true); + if (subframe->_surface == NULL) { + _gameRef->LOG(0, "Error loading simple sprite '%s'", filename.c_str()); + ret = STATUS_FAILED; + delete frame; + delete subframe; + } else { + subframe->setDefaultRect(); + frame->_subframes.add(subframe); + _frames.add(frame); + _currentFrame = 0; + ret = STATUS_OK; + } + } else { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer) { + if (DID_FAIL(ret = loadBuffer(buffer, true, lifeTime, cacheType))) { + _gameRef->LOG(0, "Error parsing SPRITE file '%s'", filename.c_str()); + } else { + ret = STATUS_OK; + } + delete[] buffer; + } + } + + setFilename(filename.c_str()); + + return ret; +} + + + +TOKEN_DEF_START +TOKEN_DEF(CONTINUOUS) +TOKEN_DEF(SPRITE) +TOKEN_DEF(LOOPING) +TOKEN_DEF(FRAME) +TOKEN_DEF(NAME) +TOKEN_DEF(PRECISE) +TOKEN_DEF(EDITOR_MUTED) +TOKEN_DEF(STREAMED_KEEP_LOADED) +TOKEN_DEF(STREAMED) +TOKEN_DEF(SCRIPT) +TOKEN_DEF(EDITOR_BG_FILE) +TOKEN_DEF(EDITOR_BG_OFFSET_X) +TOKEN_DEF(EDITOR_BG_OFFSET_Y) +TOKEN_DEF(EDITOR_BG_ALPHA) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool BaseSprite::loadBuffer(byte *buffer, bool complete, int lifeTime, TSpriteCacheType cacheType) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(CONTINUOUS) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(LOOPING) + TOKEN_TABLE(FRAME) + TOKEN_TABLE(NAME) + TOKEN_TABLE(PRECISE) + TOKEN_TABLE(EDITOR_MUTED) + TOKEN_TABLE(STREAMED_KEEP_LOADED) + TOKEN_TABLE(STREAMED) + TOKEN_TABLE(SCRIPT) + TOKEN_TABLE(EDITOR_BG_FILE) + TOKEN_TABLE(EDITOR_BG_OFFSET_X) + TOKEN_TABLE(EDITOR_BG_OFFSET_Y) + TOKEN_TABLE(EDITOR_BG_ALPHA) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + byte *params; + int cmd; + BaseParser parser; + + cleanup(); + + + if (complete) { + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_SPRITE) { + _gameRef->LOG(0, "'SPRITE' keyword expected."); + return STATUS_FAILED; + } + buffer = params; + } + + int frameCount = 1; + BaseFrame *frame; + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_CONTINUOUS: + parser.scanStr((char *)params, "%b", &_continuous); + break; + + case TOKEN_EDITOR_MUTED: + parser.scanStr((char *)params, "%b", &_editorMuted); + break; + + case TOKEN_SCRIPT: + addScript((char *)params); + break; + + case TOKEN_LOOPING: + parser.scanStr((char *)params, "%b", &_looping); + break; + + case TOKEN_PRECISE: + parser.scanStr((char *)params, "%b", &_precise); + break; + + case TOKEN_STREAMED: + parser.scanStr((char *)params, "%b", &_streamed); + if (_streamed && lifeTime == -1) { + lifeTime = 500; + cacheType = CACHE_ALL; + } + break; + + case TOKEN_STREAMED_KEEP_LOADED: + parser.scanStr((char *)params, "%b", &_streamedKeepLoaded); + break; + + case TOKEN_NAME: + setName((char *)params); + break; + + case TOKEN_EDITOR_BG_FILE: + if (_gameRef->_editorMode) { + delete[] _editorBgFile; + _editorBgFile = new char[strlen((char *)params) + 1]; + if (_editorBgFile) { + strcpy(_editorBgFile, (char *)params); + } + } + break; + + case TOKEN_EDITOR_BG_OFFSET_X: + parser.scanStr((char *)params, "%d", &_editorBgOffsetX); + break; + + case TOKEN_EDITOR_BG_OFFSET_Y: + parser.scanStr((char *)params, "%d", &_editorBgOffsetY); + break; + + case TOKEN_EDITOR_BG_ALPHA: + parser.scanStr((char *)params, "%d", &_editorBgAlpha); + _editorBgAlpha = MIN(_editorBgAlpha, 255); + _editorBgAlpha = MAX(_editorBgAlpha, 0); + break; + + case TOKEN_FRAME: { + int frameLifeTime = lifeTime; + if (cacheType == CACHE_HALF && frameCount % 2 != 1) { + frameLifeTime = -1; + } + + frame = new BaseFrame(_gameRef); + + if (DID_FAIL(frame->loadBuffer(params, frameLifeTime, _streamedKeepLoaded))) { + delete frame; + _gameRef->LOG(0, "Error parsing frame %d", frameCount); + return STATUS_FAILED; + } + + _frames.add(frame); + frameCount++; + if (_currentFrame == -1) { + _currentFrame = 0; + } + } + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty(params, false); + break; + } + } + + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SPRITE definition"); + return STATUS_FAILED; + } + _canBreak = !_continuous; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void BaseSprite::reset() { + if (_frames.size() > 0) { + _currentFrame = 0; + } else { + _currentFrame = -1; + } + + killAllSounds(); + + _lastFrameTime = 0; + _finished = false; + _moveX = _moveY = 0; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSprite::getCurrentFrame(float zoomX, float zoomY) { + //if (_owner && _owner->_freezable && _gameRef->_state == GAME_FROZEN) return true; + + if (_currentFrame == -1) { + return false; + } + + uint32 timer; + if (_owner && _owner->_freezable) { + timer = _gameRef->_timer; + } else { + timer = _gameRef->_liveTimer; + } + + int lastFrame = _currentFrame; + + // get current frame + if (!_paused && !_finished && timer >= _lastFrameTime + _frames[_currentFrame]->_delay && _lastFrameTime != 0) { + if (_currentFrame < (int32)_frames.size() - 1) { + _currentFrame++; + if (_continuous) { + _canBreak = (_currentFrame == (int32)_frames.size() - 1); + } + } else { + if (_looping) { + _currentFrame = 0; + _canBreak = true; + } else { + _finished = true; + _canBreak = true; + } + } + + _lastFrameTime = timer; + } + + _changed = (lastFrame != _currentFrame || (_looping && (int32)_frames.size() == 1)); + + if (_lastFrameTime == 0) { + _lastFrameTime = timer; + _changed = true; + if (_continuous) { + _canBreak = (_currentFrame == (int32)_frames.size() - 1); + } + } + + if (_changed) { + _moveX = _frames[_currentFrame]->_moveX; + _moveY = _frames[_currentFrame]->_moveY; + + if (zoomX != 100 || zoomY != 100) { + _moveX = (int)((float)_moveX * (float)(zoomX / 100.0f)); + _moveY = (int)((float)_moveY * (float)(zoomY / 100.0f)); + } + } + + return _changed; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSprite::display(int x, int y, BaseObject *registerVal, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + return STATUS_OK; + } + + // on change... + if (_changed) { + if (_frames[_currentFrame]->_killSound) { + killAllSounds(); + } + applyEvent("FrameChanged"); + _frames[_currentFrame]->oneTimeDisplay(_owner, _gameRef->_editorMode && _editorMuted); + } + + // draw frame + return _frames[_currentFrame]->draw(x - _gameRef->_offsetX, y - _gameRef->_offsetY, registerVal, zoomX, zoomY, _precise, alpha, _editorAllFrames, rotate, blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +BaseSurface *BaseSprite::getSurface() { + // only used for animated textures for 3D models + if (_currentFrame < 0 || _currentFrame >= (int32)_frames.size()) { + return NULL; + } + BaseFrame *frame = _frames[_currentFrame]; + if (frame && frame->_subframes.size() > 0) { + BaseSubFrame *subframe = frame->_subframes[0]; + if (subframe) { + return subframe->_surface; + } else { + return NULL; + } + } else { + return NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) { + return false; + } + + BasePlatform::setRectEmpty(rect); + for (uint32 i = 0; i < _frames.size(); i++) { + Rect32 frame; + Rect32 temp; + BasePlatform::copyRect(&temp, rect); + _frames[i]->getBoundingRect(&frame, x, y, scaleX, scaleY); + BasePlatform::unionRect(rect, &temp, &frame); + } + return true; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::saveAsText(BaseDynamicBuffer *buffer, int indent) { + buffer->putTextIndent(indent, "SPRITE {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", getName()); + buffer->putTextIndent(indent + 2, "LOOPING=%s\n", _looping ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "CONTINUOUS=%s\n", _continuous ? "TRUE" : "FALSE"); + buffer->putTextIndent(indent + 2, "PRECISE=%s\n", _precise ? "TRUE" : "FALSE"); + if (_streamed) { + buffer->putTextIndent(indent + 2, "STREAMED=%s\n", _streamed ? "TRUE" : "FALSE"); + + if (_streamedKeepLoaded) { + buffer->putTextIndent(indent + 2, "STREAMED_KEEP_LOADED=%s\n", _streamedKeepLoaded ? "TRUE" : "FALSE"); + } + } + + if (_editorMuted) { + buffer->putTextIndent(indent + 2, "EDITOR_MUTED=%s\n", _editorMuted ? "TRUE" : "FALSE"); + } + + if (_editorBgFile) { + buffer->putTextIndent(indent + 2, "EDITOR_BG_FILE=\"%s\"\n", _editorBgFile); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_X=%d\n", _editorBgOffsetX); + buffer->putTextIndent(indent + 2, "EDITOR_BG_OFFSET_Y=%d\n", _editorBgOffsetY); + buffer->putTextIndent(indent + 2, "EDITOR_BG_ALPHA=%d\n", _editorBgAlpha); + } + + BaseScriptHolder::saveAsText(buffer, indent + 2); + + // scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + buffer->putTextIndent(indent + 2, "SCRIPT=\"%s\"\n", _scripts[i]->_filename); + } + + for (uint32 i = 0; i < _frames.size(); i++) { + _frames[i]->saveAsText(buffer, indent + 2); + } + + buffer->putTextIndent(indent, "}\n\n"); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::persist(BasePersistenceManager *persistMgr) { + BaseScriptHolder::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_canBreak)); + persistMgr->transfer(TMEMBER(_changed)); + persistMgr->transfer(TMEMBER(_paused)); + persistMgr->transfer(TMEMBER(_continuous)); + persistMgr->transfer(TMEMBER(_currentFrame)); + persistMgr->transfer(TMEMBER(_editorAllFrames)); + persistMgr->transfer(TMEMBER(_editorBgAlpha)); + persistMgr->transfer(TMEMBER(_editorBgFile)); + persistMgr->transfer(TMEMBER(_editorBgOffsetX)); + persistMgr->transfer(TMEMBER(_editorBgOffsetY)); + persistMgr->transfer(TMEMBER(_editorMuted)); + persistMgr->transfer(TMEMBER(_finished)); + + _frames.persist(persistMgr); + + persistMgr->transfer(TMEMBER(_lastFrameTime)); + persistMgr->transfer(TMEMBER(_looping)); + persistMgr->transfer(TMEMBER(_moveX)); + persistMgr->transfer(TMEMBER(_moveY)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_precise)); + persistMgr->transfer(TMEMBER(_streamed)); + persistMgr->transfer(TMEMBER(_streamedKeepLoaded)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetFrame") == 0) { + stack->correctParams(1); + int index = stack->pop()->getInt(-1); + if (index < 0 || index >= (int32)_frames.size()) { + script->runtimeError("Sprite.GetFrame: Frame index %d is out of range.", index); + stack->pushNULL(); + } else { + stack->pushNative(_frames[index], true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DeleteFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DeleteFrame") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + if (val->isInt()) { + int index = val->getInt(-1); + if (index < 0 || index >= (int32)_frames.size()) { + script->runtimeError("Sprite.DeleteFrame: Frame index %d is out of range.", index); + } + } else { + BaseFrame *frame = (BaseFrame *)val->getNative(); + for (uint32 i = 0; i < _frames.size(); i++) { + if (_frames[i] == frame) { + if (i == (uint32)_currentFrame) { + _lastFrameTime = 0; + } + delete _frames[i]; + _frames.remove_at(i); + break; + } + } + } + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Reset + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Reset") == 0) { + stack->correctParams(0); + reset(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddFrame") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseFrame *frame = new BaseFrame(_gameRef); + if (filename != NULL) { + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + sub->setDefaultRect(); + frame->_subframes.add(sub); + } else { + delete sub; + } + } + _frames.add(frame); + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // InsertFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "InsertFrame") == 0) { + stack->correctParams(2); + int index = stack->pop()->getInt(); + if (index < 0) { + index = 0; + } + + ScValue *val = stack->pop(); + const char *filename = NULL; + if (!val->isNULL()) { + filename = val->getString(); + } + + BaseFrame *frame = new BaseFrame(_gameRef); + if (filename != NULL) { + BaseSubFrame *sub = new BaseSubFrame(_gameRef); + if (DID_SUCCEED(sub->setSurface(filename))) { + frame->_subframes.add(sub); + } else { + delete sub; + } + } + + if (index >= (int32)_frames.size()) { + _frames.add(frame); + } else { + _frames.insert_at(index, frame); + } + + stack->pushNative(frame, true); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _paused = true; + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Play + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Play") == 0) { + stack->correctParams(0); + _paused = false; + stack->pushNULL(); + return STATUS_OK; + } else { + return BaseScriptHolder::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseSprite::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("sprite"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // NumFrames (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumFrames") == 0) { + _scValue->setInt(_frames.size()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "CurrentFrame") == 0) { + _scValue->setInt(_currentFrame); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _scValue->setBool(_precise); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _scValue->setBool(_looping); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Owner (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Owner") == 0) { + if (_owner == NULL) { + _scValue->setNULL(); + } else { + _scValue->setNative(_owner, true); + } + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Finished (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Finished") == 0) { + _scValue->setBool(_finished); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Paused (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Paused") == 0) { + _scValue->setBool(_paused); + return _scValue; + } else { + return BaseScriptHolder::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // CurrentFrame + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "CurrentFrame") == 0) { + _currentFrame = value->getInt(0); + if (_currentFrame >= (int32)_frames.size() || _currentFrame < 0) { + _currentFrame = -1; + } + _lastFrameTime = 0; + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // PixelPerfect + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PixelPerfect") == 0) { + _precise = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Looping + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Looping") == 0) { + _looping = value->getBool(); + return STATUS_OK; + } else { + return BaseScriptHolder::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseSprite::scToString() { + return "[sprite]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSprite::killAllSounds() { + for (uint32 i = 0; i < _frames.size(); i++) { + if (_frames[i]->_sound) { + _frames[i]->_sound->stop(); + } + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index db9931c6f3..c861ca9930 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -1,90 +1,90 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SPRITE_H -#define WINTERMUTE_BASE_SPRITE_H - - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/base_script_holder.h" - -namespace Wintermute { -class BaseFrame; -class BaseSurface; -class BaseObject; -class BaseSprite: public BaseScriptHolder { -public: - bool killAllSounds(); - BaseSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; - void cleanup(); - void setDefaults(); - bool _precise; - DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) - - bool _editorAllFrames; - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - int _moveY; - int _moveX; - bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; - void reset(); - BaseObject *_owner; - bool _changed; - bool _paused; - bool _finished; - bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; - bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); - bool _looping; - int _currentFrame; - bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); - BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); - virtual ~BaseSprite(); - BaseArray _frames; - bool saveAsText(BaseDynamicBuffer *buffer, int indent); - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SPRITE_H +#define WINTERMUTE_BASE_SPRITE_H + + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base_script_holder.h" + +namespace Wintermute { +class BaseFrame; +class BaseSurface; +class BaseObject; +class BaseSprite: public BaseScriptHolder { +public: + bool killAllSounds(); + BaseSurface *getSurface(); + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _streamed; + bool _streamedKeepLoaded; + void cleanup(); + void setDefaults(); + bool _precise; + DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) + + bool _editorAllFrames; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + int _moveY; + int _moveX; + bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getCurrentFrame(float zoomX = 100, float zoomY = 100); + bool _canBreak; + bool _editorMuted; + bool _continuous; + void reset(); + BaseObject *_owner; + bool _changed; + bool _paused; + bool _finished; + bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); + uint32 _lastFrameTime; + bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); + bool _looping; + int _currentFrame; + bool addFrame(const char *filename, uint32 delay = 0, int hotspotX = 0, int hotspotY = 0, Rect32 *rect = NULL); + BaseSprite(BaseGame *inGame, BaseObject *owner = NULL); + virtual ~BaseSprite(); + BaseArray _frames; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_string_table.cpp b/engines/wintermute/base/base_string_table.cpp index 3b5e5e3774..2f890beea1 100644 --- a/engines/wintermute/base/base_string_table.cpp +++ b/engines/wintermute/base/base_string_table.cpp @@ -1,255 +1,255 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_string_table.h" -#include "common/str.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -BaseStringTable::~BaseStringTable() { - // delete strings - _strings.clear(); - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { - if (key == NULL || val == NULL) { - return STATUS_FAILED; - } - - if (scumm_stricmp(key, "@right-to-left") == 0) { - _gameRef->_textRTL = true; - return STATUS_OK; - } - - Common::String finalKey = key; - finalKey.toLowercase(); - - StringsIter it = _strings.find(finalKey); - if (it != _strings.end() && reportDuplicities) { - _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); - } - - _strings[finalKey] = val; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -char *BaseStringTable::getKey(const char *str) const { - if (str == NULL || str[0] != '/') { - return NULL; - } - - const char *value = strchr(str + 1, '/'); - if (value == NULL) { - return NULL; - } - - char *key = new char[value - str]; - Common::strlcpy(key, str + 1, (size_t)(value - str)); - - BasePlatform::strlwr(key); - - char *newStr; - - StringsIter it = _strings.find(key); - if (it != _strings.end()) { - newStr = new char[it->_value.size() + 1]; - strcpy(newStr, it->_value.c_str()); - if (strlen(newStr) > 0 && newStr[0] == '/' && strchr(newStr + 1, '/')) { - delete[] key; - char *ret = getKey(newStr); - delete[] newStr; - return ret; - } else { - delete[] newStr; - return key; - } - } else { - return key; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseStringTable::expand(char **str) const { - if (str == NULL || *str == NULL || *str[0] != '/') { - return; - } - - char *value = strchr(*str + 1, '/'); - if (value == NULL) { - return; - } - - char *key = new char[value - *str]; - Common::strlcpy(key, *str + 1, (size_t)(value - *str)); - - BasePlatform::strlwr(key); - - value++; - - char *newStr; - - StringsIter it = _strings.find(key); - if (it != _strings.end()) { - newStr = new char[it->_value.size() + 1]; - strcpy(newStr, it->_value.c_str()); - } else { - newStr = new char[strlen(value) + 1]; - strcpy(newStr, value); - } - - delete[] key; - delete[] *str; - *str = newStr; - - if (strlen(*str) > 0 && *str[0] == '/') { - expand(str); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseStringTable::expandStatic(const char *string) const { - if (string == NULL || string[0] == '\0' || string[0] != '/') { - return string; - } - - const char *value = strchr(string + 1, '/'); - if (value == NULL) { - return string; - } - - char *key = new char[value - string]; - Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); - BasePlatform::strlwr(key); - - value++; - - const char *newStr; - - StringsIter it = _strings.find(key); - if (it != _strings.end()) { - newStr = it->_value.c_str(); - } else { - newStr = value; - } - - delete[] key; - - if (strlen(newStr) > 0 && newStr[0] == '/') { - return expandStatic(newStr); - } else { - return newStr; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseStringTable::loadFile(const char *filename, bool clearOld) { - _gameRef->LOG(0, "Loading string table..."); - - if (clearOld) { - _strings.clear(); - } - - uint32 size; - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); - return STATUS_FAILED; - } - - uint32 pos = 0; - - if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { - pos += 3; - if (_gameRef->_textEncoding != TEXT_UTF8) { - _gameRef->_textEncoding = TEXT_UTF8; - //_gameRef->_textEncoding = TEXT_ANSI; - _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); - } - } else { - _gameRef->_textEncoding = TEXT_ANSI; - } - - uint32 lineLength = 0; - while (pos < size) { - lineLength = 0; - while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') { - lineLength++; - } - - uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); - char *line = new char[realLength + 1]; - Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); - char *value = strchr(line, '\t'); - if (value == NULL) { - value = strchr(line, ' '); - } - - if (line[0] != ';') { - if (value != NULL) { - value[0] = '\0'; - value++; - for (uint32 i = 0; i < strlen(value); i++) { - if (value[i] == '|') { - value[i] = '\n'; - } - } - addString(line, value, clearOld); - } else if (line[0] != '\0') { - addString(line, "", clearOld); - } - } - - delete[] line; - pos += lineLength + 1; - } - - delete[] buffer; - - _gameRef->LOG(0, " %d strings loaded", _strings.size()); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_string_table.h" +#include "common/str.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseStringTable::BaseStringTable(BaseGame *inGame) : BaseClass(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +BaseStringTable::~BaseStringTable() { + // delete strings + _strings.clear(); + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseStringTable::addString(const char *key, const char *val, bool reportDuplicities) { + if (key == NULL || val == NULL) { + return STATUS_FAILED; + } + + if (scumm_stricmp(key, "@right-to-left") == 0) { + _gameRef->_textRTL = true; + return STATUS_OK; + } + + Common::String finalKey = key; + finalKey.toLowercase(); + + StringsIter it = _strings.find(finalKey); + if (it != _strings.end() && reportDuplicities) { + _gameRef->LOG(0, " Warning: Duplicate definition of string '%s'.", finalKey.c_str()); + } + + _strings[finalKey] = val; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +char *BaseStringTable::getKey(const char *str) const { + if (str == NULL || str[0] != '/') { + return NULL; + } + + const char *value = strchr(str + 1, '/'); + if (value == NULL) { + return NULL; + } + + char *key = new char[value - str]; + Common::strlcpy(key, str + 1, (size_t)(value - str)); + + BasePlatform::strlwr(key); + + char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); + if (strlen(newStr) > 0 && newStr[0] == '/' && strchr(newStr + 1, '/')) { + delete[] key; + char *ret = getKey(newStr); + delete[] newStr; + return ret; + } else { + delete[] newStr; + return key; + } + } else { + return key; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseStringTable::expand(char **str) const { + if (str == NULL || *str == NULL || *str[0] != '/') { + return; + } + + char *value = strchr(*str + 1, '/'); + if (value == NULL) { + return; + } + + char *key = new char[value - *str]; + Common::strlcpy(key, *str + 1, (size_t)(value - *str)); + + BasePlatform::strlwr(key); + + value++; + + char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = new char[it->_value.size() + 1]; + strcpy(newStr, it->_value.c_str()); + } else { + newStr = new char[strlen(value) + 1]; + strcpy(newStr, value); + } + + delete[] key; + delete[] *str; + *str = newStr; + + if (strlen(*str) > 0 && *str[0] == '/') { + expand(str); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseStringTable::expandStatic(const char *string) const { + if (string == NULL || string[0] == '\0' || string[0] != '/') { + return string; + } + + const char *value = strchr(string + 1, '/'); + if (value == NULL) { + return string; + } + + char *key = new char[value - string]; + Common::strlcpy(key, string + 1, (size_t)(value - string - 1)); + BasePlatform::strlwr(key); + + value++; + + const char *newStr; + + StringsIter it = _strings.find(key); + if (it != _strings.end()) { + newStr = it->_value.c_str(); + } else { + newStr = value; + } + + delete[] key; + + if (strlen(newStr) > 0 && newStr[0] == '/') { + return expandStatic(newStr); + } else { + return newStr; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseStringTable::loadFile(const char *filename, bool clearOld) { + _gameRef->LOG(0, "Loading string table..."); + + if (clearOld) { + _strings.clear(); + } + + uint32 size; + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename, &size); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseStringTable::LoadFile failed for file '%s'", filename); + return STATUS_FAILED; + } + + uint32 pos = 0; + + if (size > 3 && buffer[0] == 0xEF && buffer[1] == 0xBB && buffer[2] == 0xBF) { + pos += 3; + if (_gameRef->_textEncoding != TEXT_UTF8) { + _gameRef->_textEncoding = TEXT_UTF8; + //_gameRef->_textEncoding = TEXT_ANSI; + _gameRef->LOG(0, " UTF8 file detected, switching to UTF8 text encoding"); + } + } else { + _gameRef->_textEncoding = TEXT_ANSI; + } + + uint32 lineLength = 0; + while (pos < size) { + lineLength = 0; + while (pos + lineLength < size && buffer[pos + lineLength] != '\n' && buffer[pos + lineLength] != '\0') { + lineLength++; + } + + uint32 realLength = lineLength - (pos + lineLength >= size ? 0 : 1); + char *line = new char[realLength + 1]; + Common::strlcpy(line, (char *)&buffer[pos], realLength + 1); + char *value = strchr(line, '\t'); + if (value == NULL) { + value = strchr(line, ' '); + } + + if (line[0] != ';') { + if (value != NULL) { + value[0] = '\0'; + value++; + for (uint32 i = 0; i < strlen(value); i++) { + if (value[i] == '|') { + value[i] = '\n'; + } + } + addString(line, value, clearOld); + } else if (line[0] != '\0') { + addString(line, "", clearOld); + } + } + + delete[] line; + pos += lineLength + 1; + } + + delete[] buffer; + + _gameRef->LOG(0, " %d strings loaded", _strings.size()); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_string_table.h b/engines/wintermute/base/base_string_table.h index 09d8aecce4..128807bd1a 100644 --- a/engines/wintermute/base/base_string_table.h +++ b/engines/wintermute/base/base_string_table.h @@ -1,55 +1,55 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_STRING_TABLE_H -#define WINTERMUTE_BASE_STRING_TABLE_H - - -#include "common/hashmap.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseStringTable : public BaseClass { -public: - bool loadFile(const char *filename, bool deleteAll = true); - void expand(char **str) const; - const char *expandStatic(const char *string) const; - bool addString(const char *key, const char *val, bool reportDuplicities = true); - BaseStringTable(BaseGame *inGame); - virtual ~BaseStringTable(); - char *getKey(const char *str) const; -private: - Common::HashMap _strings; - typedef Common::HashMap::const_iterator StringsIter; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_STRING_TABLE_H +#define WINTERMUTE_BASE_STRING_TABLE_H + + +#include "common/hashmap.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseStringTable : public BaseClass { +public: + bool loadFile(const char *filename, bool deleteAll = true); + void expand(char **str) const; + const char *expandStatic(const char *string) const; + bool addString(const char *key, const char *val, bool reportDuplicities = true); + BaseStringTable(BaseGame *inGame); + virtual ~BaseStringTable(); + char *getKey(const char *str) const; +private: + Common::HashMap _strings; + typedef Common::HashMap::const_iterator StringsIter; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 3ddfd1bb14..6a9246efd4 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -1,655 +1,655 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/base/base_active_rect.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseSubFrame, false) - -////////////////////////////////////////////////////////////////////////// -BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { - _surface = NULL; - _hotspotX = _hotspotY = 0; - _alpha = 0xFFFFFFFF; - _transparent = 0xFFFF00FF; - - _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); - - _editorSelected = false; - - _surfaceFilename = NULL; - _cKDefault = true; - _cKRed = _cKBlue = _cKGreen = 0; - _lifeTime = -1; - _keepLoaded = false; - - _2DOnly = _3DOnly = false; - _decoration = false; - - _mirrorX = _mirrorY = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSubFrame::~BaseSubFrame() { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - } - delete[] _surfaceFilename; - _surfaceFilename = NULL; -} - - -TOKEN_DEF_START -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(RECT) -TOKEN_DEF(HOTSPOT) -TOKEN_DEF(2D_ONLY) -TOKEN_DEF(3D_ONLY) -TOKEN_DEF(DECORATION) -TOKEN_DEF(ALPHA_COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(MIRROR_X) -TOKEN_DEF(MIRROR_Y) -TOKEN_DEF(EDITOR_SELECTED) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(RECT) - TOKEN_TABLE(HOTSPOT) - TOKEN_TABLE(2D_ONLY) - TOKEN_TABLE(3D_ONLY) - TOKEN_TABLE(DECORATION) - TOKEN_TABLE(ALPHA_COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(MIRROR_X) - TOKEN_TABLE(MIRROR_Y) - TOKEN_TABLE(EDITOR_SELECTED) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE_END - - char *params; - int cmd; - BaseParser parser; - Rect32 rect; - int r = 255, g = 255, b = 255; - int ar = 255, ag = 255, ab = 255, alpha = 255; - bool custoTrans = false; - BasePlatform::setRectEmpty(&rect); - char *surfaceFile = NULL; - - delete _surface; - _surface = NULL; - - while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_RECT: - parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); - break; - - case TOKEN_HOTSPOT: - parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); - break; - - case TOKEN_2D_ONLY: - parser.scanStr(params, "%b", &_2DOnly); - break; - - case TOKEN_3D_ONLY: - parser.scanStr(params, "%b", &_3DOnly); - break; - - case TOKEN_MIRROR_X: - parser.scanStr(params, "%b", &_mirrorX); - break; - - case TOKEN_MIRROR_Y: - parser.scanStr(params, "%b", &_mirrorY); - break; - - case TOKEN_DECORATION: - parser.scanStr(params, "%b", &_decoration); - break; - - case TOKEN_ALPHA_COLOR: - parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); - break; - - case TOKEN_ALPHA: - parser.scanStr(params, "%d", &alpha); - break; - - case TOKEN_EDITOR_SELECTED: - parser.scanStr(params, "%b", &_editorSelected); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); - return STATUS_FAILED; - } - - if (surfaceFile != NULL) { - if (custoTrans) { - setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); - } else { - setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); - } - } - - _alpha = BYTETORGBA(ar, ag, ab, alpha); - if (custoTrans) { - _transparent = BYTETORGBA(r, g, b, 0xFF); - } - - /* - if (_surface == NULL) - { - _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); - return STATUS_FAILED; - } - */ - if (BasePlatform::isRectEmpty(&rect)) { - setDefaultRect(); - } else { - setRect(rect); - } - - return STATUS_OK; -} - -Rect32 BaseSubFrame::getRect() { - if (_wantsDefaultRect && _surface) { - BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - _wantsDefaultRect = false; - } - return _rect; -} - -void BaseSubFrame::setRect(Rect32 rect) { - _wantsDefaultRect = false; - _rect = rect; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { - if (!_surface) { - return STATUS_OK; - } - - if (registerOwner != NULL && !_decoration) { - if (zoomX == 100 && zoomY == 100) { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise)); - } else { - _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise)); - } - } - if (_gameRef->_suspendedRendering) { - return STATUS_OK; - } - - bool res; - - //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) - if (_alpha != 0xFFFFFFFF) { - alpha = _alpha; - } - - if (rotate != 0.0f) { - res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); - } else { - if (zoomX == 100 && zoomY == 100) { - res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY); - } else { - res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); - } - } - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { - if (!rect) { - return false; - } - - float ratioX = scaleX / 100.0f; - float ratioY = scaleY / 100.0f; - - BasePlatform::setRect(rect, - (int)(x - _hotspotX * ratioX), - (int)(y - _hotspotY * ratioY), - (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), - (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { - if (complete) { - buffer->putTextIndent(indent, "SUBFRAME {\n"); - } - - if (_surface && _surface->getFileNameStr() != "") { - buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); - } - - if (_transparent != 0xFFFF00FF) { - buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); - } - - Rect32 rect; - BasePlatform::setRectEmpty(&rect); - if (_surface) { - BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); - } - if (!(rect == getRect())) { - buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", getRect().left, getRect().top, getRect().right, getRect().bottom); - } - - if (_hotspotX != 0 || _hotspotY != 0) { - buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); - } - - if (_alpha != 0xFFFFFFFF) { - buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); - buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); - } - - if (_mirrorX) { - buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); - } - - if (_mirrorY) { - buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); - } - - if (_2DOnly) { - buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); - } - - if (_3DOnly) { - buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); - } - - if (_decoration) { - buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); - } - - if (_editorSelected) { - buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); - } - - BaseClass::saveAsText(buffer, indent + 2); - - - if (complete) { - buffer->putTextIndent(indent, "}\n\n"); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSubFrame::setDefaultRect() { - if (_surface) { - _wantsDefaultRect = true; - } else { - _wantsDefaultRect = false; - BasePlatform::setRectEmpty(&_rect); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_2DOnly)); - persistMgr->transfer(TMEMBER(_3DOnly)); - persistMgr->transfer(TMEMBER(_alpha)); - persistMgr->transfer(TMEMBER(_decoration)); - persistMgr->transfer(TMEMBER(_editorSelected)); - persistMgr->transfer(TMEMBER(_hotspotX)); - persistMgr->transfer(TMEMBER(_hotspotY)); - persistMgr->transfer(TMEMBER(_rect)); - persistMgr->transfer(TMEMBER(_wantsDefaultRect)); - - persistMgr->transfer(TMEMBER(_surfaceFilename)); - persistMgr->transfer(TMEMBER(_cKDefault)); - persistMgr->transfer(TMEMBER(_cKRed)); - persistMgr->transfer(TMEMBER(_cKGreen)); - persistMgr->transfer(TMEMBER(_cKBlue)); - persistMgr->transfer(TMEMBER(_lifeTime)); - - persistMgr->transfer(TMEMBER(_keepLoaded)); - persistMgr->transfer(TMEMBER(_mirrorX)); - persistMgr->transfer(TMEMBER(_mirrorY)); - persistMgr->transfer(TMEMBER(_transparent)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - - ////////////////////////////////////////////////////////////////////////// - // GetImage - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetImage") == 0) { - stack->correctParams(0); - - if (!_surfaceFilename) { - stack->pushNULL(); - } else { - stack->pushString(_surfaceFilename); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetImage - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetImage") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - if (val->isNULL()) { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - } - delete[] _surfaceFilename; - _surfaceFilename = NULL; - stack->pushBool(true); - } else { - const char *filename = val->getString(); - if (DID_SUCCEED(setSurface(filename))) { - setDefaultRect(); - stack->pushBool(true); - } else { - stack->pushBool(false); - } - } - - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *BaseSubFrame::scGetProperty(const char *name) { - if (!_scValue) { - _scValue = new ScValue(_gameRef); - } - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("subframe"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { - - _scValue->setInt((int)_alpha); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TransparentColor (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { - _scValue->setInt((int)_transparent); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _scValue->setBool(_2DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _scValue->setBool(_3DOnly); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _scValue->setBool(_mirrorX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _scValue->setBool(_mirrorY); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _scValue->setBool(_decoration); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _scValue->setInt(_hotspotX); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _scValue->setInt(_hotspotY); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // AlphaColor - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "AlphaColor") == 0) { - _alpha = (uint32)value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is2DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { - _2DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Is3DOnly - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { - _3DOnly = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { - _mirrorX = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MirrorY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { - _mirrorY = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Decoration - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { - _decoration = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotX - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { - _hotspotX = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // HotspotY - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { - _hotspotY = value->getInt(); - return STATUS_OK; - } else { - return BaseScriptable::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *BaseSubFrame::scToString() { - return "[subframe]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::setSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - if (_surface) { - _gameRef->_surfaceStorage->removeSurface(_surface); - _surface = NULL; - } - - delete[] _surfaceFilename; - _surfaceFilename = NULL; - - _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - if (_surface) { - _surfaceFilename = new char[filename.size() + 1]; - strcpy(_surfaceFilename, filename.c_str()); - - _cKDefault = defaultCK; - _cKRed = ckRed; - _cKGreen = ckGreen; - _cKBlue = ckBlue; - _lifeTime = lifeTime; - _keepLoaded = keepLoaded; - - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSubFrame::setSurfaceSimple() { - if (!_surfaceFilename) { - _surface = NULL; - return STATUS_OK; - } - _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); - if (_surface) { - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseSubFrame, false) + +////////////////////////////////////////////////////////////////////////// +BaseSubFrame::BaseSubFrame(BaseGame *inGame) : BaseScriptable(inGame, true) { + _surface = NULL; + _hotspotX = _hotspotY = 0; + _alpha = 0xFFFFFFFF; + _transparent = 0xFFFF00FF; + + _wantsDefaultRect = false; + BasePlatform::setRectEmpty(&_rect); + + _editorSelected = false; + + _surfaceFilename = NULL; + _cKDefault = true; + _cKRed = _cKBlue = _cKGreen = 0; + _lifeTime = -1; + _keepLoaded = false; + + _2DOnly = _3DOnly = false; + _decoration = false; + + _mirrorX = _mirrorY = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSubFrame::~BaseSubFrame() { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } + delete[] _surfaceFilename; + _surfaceFilename = NULL; +} + + +TOKEN_DEF_START +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(RECT) +TOKEN_DEF(HOTSPOT) +TOKEN_DEF(2D_ONLY) +TOKEN_DEF(3D_ONLY) +TOKEN_DEF(DECORATION) +TOKEN_DEF(ALPHA_COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(MIRROR_X) +TOKEN_DEF(MIRROR_Y) +TOKEN_DEF(EDITOR_SELECTED) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::loadBuffer(byte *buffer, int lifeTime, bool keepLoaded) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(RECT) + TOKEN_TABLE(HOTSPOT) + TOKEN_TABLE(2D_ONLY) + TOKEN_TABLE(3D_ONLY) + TOKEN_TABLE(DECORATION) + TOKEN_TABLE(ALPHA_COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(MIRROR_X) + TOKEN_TABLE(MIRROR_Y) + TOKEN_TABLE(EDITOR_SELECTED) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE_END + + char *params; + int cmd; + BaseParser parser; + Rect32 rect; + int r = 255, g = 255, b = 255; + int ar = 255, ag = 255, ab = 255, alpha = 255; + bool custoTrans = false; + BasePlatform::setRectEmpty(&rect); + char *surfaceFile = NULL; + + delete _surface; + _surface = NULL; + + while ((cmd = parser.getCommand((char **)&buffer, commands, ¶ms)) > 0) { + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_RECT: + parser.scanStr(params, "%d,%d,%d,%d", &rect.left, &rect.top, &rect.right, &rect.bottom); + break; + + case TOKEN_HOTSPOT: + parser.scanStr(params, "%d,%d", &_hotspotX, &_hotspotY); + break; + + case TOKEN_2D_ONLY: + parser.scanStr(params, "%b", &_2DOnly); + break; + + case TOKEN_3D_ONLY: + parser.scanStr(params, "%b", &_3DOnly); + break; + + case TOKEN_MIRROR_X: + parser.scanStr(params, "%b", &_mirrorX); + break; + + case TOKEN_MIRROR_Y: + parser.scanStr(params, "%b", &_mirrorY); + break; + + case TOKEN_DECORATION: + parser.scanStr(params, "%b", &_decoration); + break; + + case TOKEN_ALPHA_COLOR: + parser.scanStr(params, "%d,%d,%d", &ar, &ag, &ab); + break; + + case TOKEN_ALPHA: + parser.scanStr(params, "%d", &alpha); + break; + + case TOKEN_EDITOR_SELECTED: + parser.scanStr(params, "%b", &_editorSelected); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in SUBFRAME definition"); + return STATUS_FAILED; + } + + if (surfaceFile != NULL) { + if (custoTrans) { + setSurface(surfaceFile, false, r, g, b, lifeTime, keepLoaded); + } else { + setSurface(surfaceFile, true, 0, 0, 0, lifeTime, keepLoaded); + } + } + + _alpha = BYTETORGBA(ar, ag, ab, alpha); + if (custoTrans) { + _transparent = BYTETORGBA(r, g, b, 0xFF); + } + + /* + if (_surface == NULL) + { + _gameRef->LOG(0, "Error parsing sub-frame. Image not set."); + return STATUS_FAILED; + } + */ + if (BasePlatform::isRectEmpty(&rect)) { + setDefaultRect(); + } else { + setRect(rect); + } + + return STATUS_OK; +} + +Rect32 BaseSubFrame::getRect() { + if (_wantsDefaultRect && _surface) { + BasePlatform::setRect(&_rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + _wantsDefaultRect = false; + } + return _rect; +} + +void BaseSubFrame::setRect(Rect32 rect) { + _wantsDefaultRect = false; + _rect = rect; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { + if (!_surface) { + return STATUS_OK; + } + + if (registerOwner != NULL && !_decoration) { + if (zoomX == 100 && zoomY == 100) { + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, x - _hotspotX + getRect().left, y - _hotspotY + getRect().top, getRect().right - getRect().left, getRect().bottom - getRect().top, zoomX, zoomY, precise)); + } else { + _gameRef->_renderer->addRectToList(new BaseActiveRect(_gameRef, registerOwner, this, (int)(x - (_hotspotX + getRect().left) * (zoomX / 100)), (int)(y - (_hotspotY + getRect().top) * (zoomY / 100)), (int)((getRect().right - getRect().left) * (zoomX / 100)), (int)((getRect().bottom - getRect().top) * (zoomY / 100)), zoomX, zoomY, precise)); + } + } + if (_gameRef->_suspendedRendering) { + return STATUS_OK; + } + + bool res; + + //if (Alpha==0xFFFFFFFF) Alpha = _alpha; // TODO: better (combine owner's and self alpha) + if (_alpha != 0xFFFFFFFF) { + alpha = _alpha; + } + + if (rotate != 0.0f) { + res = _surface->displayTransform((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), _hotspotX, _hotspotY, getRect(), zoomX, zoomY, alpha, rotate, blendMode, _mirrorX, _mirrorY); + } else { + if (zoomX == 100 && zoomY == 100) { + res = _surface->displayTrans(x - _hotspotX, y - _hotspotY, getRect(), alpha, blendMode, _mirrorX, _mirrorY); + } else { + res = _surface->displayTransZoom((int)(x - _hotspotX * (zoomX / 100)), (int)(y - _hotspotY * (zoomY / 100)), getRect(), zoomX, zoomY, alpha, blendMode, _mirrorX, _mirrorY); + } + } + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::getBoundingRect(Rect32 *rect, int x, int y, float scaleX, float scaleY) { + if (!rect) { + return false; + } + + float ratioX = scaleX / 100.0f; + float ratioY = scaleY / 100.0f; + + BasePlatform::setRect(rect, + (int)(x - _hotspotX * ratioX), + (int)(y - _hotspotY * ratioY), + (int)(x - _hotspotX * ratioX + (getRect().right - getRect().left) * ratioX), + (int)(y - _hotspotY * ratioY + (getRect().bottom - getRect().top) * ratioY)); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete) { + if (complete) { + buffer->putTextIndent(indent, "SUBFRAME {\n"); + } + + if (_surface && _surface->getFileNameStr() != "") { + buffer->putTextIndent(indent + 2, "IMAGE = \"%s\"\n", _surface->getFileName()); + } + + if (_transparent != 0xFFFF00FF) { + buffer->putTextIndent(indent + 2, "TRANSPARENT { %d,%d,%d }\n", RGBCOLGetR(_transparent), RGBCOLGetG(_transparent), RGBCOLGetB(_transparent)); + } + + Rect32 rect; + BasePlatform::setRectEmpty(&rect); + if (_surface) { + BasePlatform::setRect(&rect, 0, 0, _surface->getWidth(), _surface->getHeight()); + } + if (!(rect == getRect())) { + buffer->putTextIndent(indent + 2, "RECT { %d,%d,%d,%d }\n", getRect().left, getRect().top, getRect().right, getRect().bottom); + } + + if (_hotspotX != 0 || _hotspotY != 0) { + buffer->putTextIndent(indent + 2, "HOTSPOT {%d, %d}\n", _hotspotX, _hotspotY); + } + + if (_alpha != 0xFFFFFFFF) { + buffer->putTextIndent(indent + 2, "ALPHA_COLOR { %d,%d,%d }\n", RGBCOLGetR(_alpha), RGBCOLGetG(_alpha), RGBCOLGetB(_alpha)); + buffer->putTextIndent(indent + 2, "ALPHA = %d\n", RGBCOLGetA(_alpha)); + } + + if (_mirrorX) { + buffer->putTextIndent(indent + 2, "MIRROR_X=%s\n", _mirrorX ? "TRUE" : "FALSE"); + } + + if (_mirrorY) { + buffer->putTextIndent(indent + 2, "MIRROR_Y=%s\n", _mirrorY ? "TRUE" : "FALSE"); + } + + if (_2DOnly) { + buffer->putTextIndent(indent + 2, "2D_ONLY=%s\n", _2DOnly ? "TRUE" : "FALSE"); + } + + if (_3DOnly) { + buffer->putTextIndent(indent + 2, "3D_ONLY=%s\n", _3DOnly ? "TRUE" : "FALSE"); + } + + if (_decoration) { + buffer->putTextIndent(indent + 2, "DECORATION=%s\n", _decoration ? "TRUE" : "FALSE"); + } + + if (_editorSelected) { + buffer->putTextIndent(indent + 2, "EDITOR_SELECTED=%s\n", _editorSelected ? "TRUE" : "FALSE"); + } + + BaseClass::saveAsText(buffer, indent + 2); + + + if (complete) { + buffer->putTextIndent(indent, "}\n\n"); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSubFrame::setDefaultRect() { + if (_surface) { + _wantsDefaultRect = true; + } else { + _wantsDefaultRect = false; + BasePlatform::setRectEmpty(&_rect); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_2DOnly)); + persistMgr->transfer(TMEMBER(_3DOnly)); + persistMgr->transfer(TMEMBER(_alpha)); + persistMgr->transfer(TMEMBER(_decoration)); + persistMgr->transfer(TMEMBER(_editorSelected)); + persistMgr->transfer(TMEMBER(_hotspotX)); + persistMgr->transfer(TMEMBER(_hotspotY)); + persistMgr->transfer(TMEMBER(_rect)); + persistMgr->transfer(TMEMBER(_wantsDefaultRect)); + + persistMgr->transfer(TMEMBER(_surfaceFilename)); + persistMgr->transfer(TMEMBER(_cKDefault)); + persistMgr->transfer(TMEMBER(_cKRed)); + persistMgr->transfer(TMEMBER(_cKGreen)); + persistMgr->transfer(TMEMBER(_cKBlue)); + persistMgr->transfer(TMEMBER(_lifeTime)); + + persistMgr->transfer(TMEMBER(_keepLoaded)); + persistMgr->transfer(TMEMBER(_mirrorX)); + persistMgr->transfer(TMEMBER(_mirrorY)); + persistMgr->transfer(TMEMBER(_transparent)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + + ////////////////////////////////////////////////////////////////////////// + // GetImage + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetImage") == 0) { + stack->correctParams(0); + + if (!_surfaceFilename) { + stack->pushNULL(); + } else { + stack->pushString(_surfaceFilename); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetImage + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetImage") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + if (val->isNULL()) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + } + delete[] _surfaceFilename; + _surfaceFilename = NULL; + stack->pushBool(true); + } else { + const char *filename = val->getString(); + if (DID_SUCCEED(setSurface(filename))) { + setDefaultRect(); + stack->pushBool(true); + } else { + stack->pushBool(false); + } + } + + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *BaseSubFrame::scGetProperty(const char *name) { + if (!_scValue) { + _scValue = new ScValue(_gameRef); + } + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("subframe"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaColor") == 0) { + + _scValue->setInt((int)_alpha); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TransparentColor (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TransparentColor") == 0) { + _scValue->setInt((int)_transparent); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _scValue->setBool(_2DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _scValue->setBool(_3DOnly); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _scValue->setBool(_mirrorX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _scValue->setBool(_mirrorY); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _scValue->setBool(_decoration); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _scValue->setInt(_hotspotX); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _scValue->setInt(_hotspotY); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // AlphaColor + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "AlphaColor") == 0) { + _alpha = (uint32)value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is2DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is2DOnly") == 0) { + _2DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Is3DOnly + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Is3DOnly") == 0) { + _3DOnly = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorX") == 0) { + _mirrorX = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MirrorY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MirrorY") == 0) { + _mirrorY = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Decoration + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Decoration") == 0) { + _decoration = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotX + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotX") == 0) { + _hotspotX = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // HotspotY + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "HotspotY") == 0) { + _hotspotY = value->getInt(); + return STATUS_OK; + } else { + return BaseScriptable::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *BaseSubFrame::scToString() { + return "[subframe]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::setSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + if (_surface) { + _gameRef->_surfaceStorage->removeSurface(_surface); + _surface = NULL; + } + + delete[] _surfaceFilename; + _surfaceFilename = NULL; + + _surface = _gameRef->_surfaceStorage->addSurface(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + if (_surface) { + _surfaceFilename = new char[filename.size() + 1]; + strcpy(_surfaceFilename, filename.c_str()); + + _cKDefault = defaultCK; + _cKRed = ckRed; + _cKGreen = ckGreen; + _cKBlue = ckBlue; + _lifeTime = lifeTime; + _keepLoaded = keepLoaded; + + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSubFrame::setSurfaceSimple() { + if (!_surfaceFilename) { + _surface = NULL; + return STATUS_OK; + } + _surface = _gameRef->_surfaceStorage->addSurface(_surfaceFilename, _cKDefault, _cKRed, _cKGreen, _cKBlue, _lifeTime, _keepLoaded); + if (_surface) { + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index e89a189e2d..b174c6e5f0 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -1,92 +1,92 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SUBFRAME_H -#define WINTERMUTE_BASE_SUBFRAME_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { -class BaseObject; -class BaseSurface; -class BaseSubFrame : public BaseScriptable { -public: - bool _mirrorX; - bool _mirrorY; - bool _decoration; - bool setSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool setSurfaceSimple(); - DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) - void setDefaultRect(); - uint32 _transparent; - bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } - bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); - bool _editorSelected; - BaseSubFrame(BaseGame *inGame); - virtual ~BaseSubFrame(); - bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); - bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); - bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); - - int _hotspotX; - int _hotspotY; - uint32 _alpha; - // These two setters and getters are rather usefull, as they allow _rect to be lazily defined - // Thus we don't need to load the actual graphics before the rect is actually needed. - Rect32 getRect(); - void setRect(Rect32 rect); -private: - bool _wantsDefaultRect; - Rect32 _rect; -public: - bool _cKDefault; - byte _cKRed; - byte _cKGreen; - byte _cKBlue; - int _lifeTime; - bool _keepLoaded; - char *_surfaceFilename; - - bool _2DOnly; - bool _3DOnly; - - BaseSurface *_surface; - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SUBFRAME_H +#define WINTERMUTE_BASE_SUBFRAME_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { +class BaseObject; +class BaseSurface; +class BaseSubFrame : public BaseScriptable { +public: + bool _mirrorX; + bool _mirrorY; + bool _decoration; + bool setSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool setSurfaceSimple(); + DECLARE_PERSISTENT(BaseSubFrame, BaseScriptable) + void setDefaultRect(); + uint32 _transparent; + bool saveAsText(BaseDynamicBuffer *buffer, int indent) { return saveAsText(buffer, indent, true); } + bool saveAsText(BaseDynamicBuffer *buffer, int indent, bool complete); + bool _editorSelected; + BaseSubFrame(BaseGame *inGame); + virtual ~BaseSubFrame(); + bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); + bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + + int _hotspotX; + int _hotspotY; + uint32 _alpha; + // These two setters and getters are rather usefull, as they allow _rect to be lazily defined + // Thus we don't need to load the actual graphics before the rect is actually needed. + Rect32 getRect(); + void setRect(Rect32 rect); +private: + bool _wantsDefaultRect; + Rect32 _rect; +public: + bool _cKDefault; + byte _cKRed; + byte _cKGreen; + byte _cKBlue; + int _lifeTime; + bool _keepLoaded; + char *_surfaceFilename; + + bool _2DOnly; + bool _3DOnly; + + BaseSurface *_surface; + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index c87da898db..1dcebb0595 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -1,207 +1,207 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace Wintermute { - -//IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); - -////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { - _lastCleanupTime = 0; -} - - -////////////////////////////////////////////////////////////////////// -BaseSurfaceStorage::~BaseSurfaceStorage() { - cleanup(true); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::cleanup(bool warn) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (warn) { - _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); - } - delete _surfaces[i]; - } - _surfaces.clear(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::initLoop() { - if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { - _lastCleanupTime = _gameRef->_liveTimer; - sortSurfaces(); - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i]->_lifeTime <= 0) { - break; - } - - if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { - //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); - _surfaces[i]->invalidate(); - } - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (_surfaces[i] == surface) { - _surfaces[i]->_referenceCount--; - if (_surfaces[i]->_referenceCount <= 0) { - delete _surfaces[i]; - _surfaces.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - for (uint32 i = 0; i < _surfaces.size(); i++) { - if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) { - _surfaces[i]->_referenceCount++; - return _surfaces[i]; - } - } - - if (!BaseFileManager::getEngineInstance()->hasFile(filename)) { - if (filename.size()) { - _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); - } - if (_gameRef->_debugDebugMode) { - return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } else { - return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); - } - } - - BaseSurface *surface; - surface = _gameRef->_renderer->createSurface(); - - if (!surface) { - return NULL; - } - - if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { - delete surface; - return NULL; - } else { - surface->_referenceCount = 1; - _surfaces.push_back(surface); - return surface; - } -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::restoreAll() { - bool ret; - for (uint32 i = 0; i < _surfaces.size(); i++) { - ret = _surfaces[i]->restore(); - if (ret != STATUS_OK) { - _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); - return ret; - } - } - return STATUS_OK; -} - - -/* -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) -{ - - if (!persistMgr->getIsSaving()) cleanup(false); - - persistMgr->transfer(TMEMBER(_gameRef)); - - //_surfaces.persist(persistMgr); - - return STATUS_OK; -} -*/ - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceStorage::sortSurfaces() { - Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { - const BaseSurface *s1 = *((const BaseSurface *const *)arg1); - const BaseSurface *s2 = *((const BaseSurface *const *)arg2); - - // sort by life time - if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { - return 1; - } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) { - return -1; - } - - - // sort by validity - if (s1->_valid && !s2->_valid) { - return -1; - } else if (!s1->_valid && s2->_valid) { - return 1; - } - - // sort by time - else if (s1->_lastUsedTime > s2->_lastUsedTime) { - return 1; - } else if (s1->_lastUsedTime < s2->_lastUsedTime) { - return -1; - } else { - return 0; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace Wintermute { + +//IMPLEMENT_PERSISTENT(BaseSurfaceStorage, true); + +////////////////////////////////////////////////////////////////////// +BaseSurfaceStorage::BaseSurfaceStorage(BaseGame *inGame) : BaseClass(inGame) { + _lastCleanupTime = 0; +} + + +////////////////////////////////////////////////////////////////////// +BaseSurfaceStorage::~BaseSurfaceStorage() { + cleanup(true); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::cleanup(bool warn) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (warn) { + _gameRef->LOG(0, "BaseSurfaceStorage warning: purging surface '%s', usage:%d", _surfaces[i]->getFileName(), _surfaces[i]->_referenceCount); + } + delete _surfaces[i]; + } + _surfaces.clear(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::initLoop() { + if (_gameRef->_smartCache && _gameRef->_liveTimer - _lastCleanupTime >= _gameRef->_surfaceGCCycleTime) { + _lastCleanupTime = _gameRef->_liveTimer; + sortSurfaces(); + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i]->_lifeTime <= 0) { + break; + } + + if (_surfaces[i]->_lifeTime > 0 && _surfaces[i]->_valid && (int)(_gameRef->_liveTimer - _surfaces[i]->_lastUsedTime) >= _surfaces[i]->_lifeTime) { + //_gameRef->QuickMessageForm("Invalidating: %s", _surfaces[i]->_filename); + _surfaces[i]->invalidate(); + } + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::removeSurface(BaseSurface *surface) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (_surfaces[i] == surface) { + _surfaces[i]->_referenceCount--; + if (_surfaces[i]->_referenceCount <= 0) { + delete _surfaces[i]; + _surfaces.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +BaseSurface *BaseSurfaceStorage::addSurface(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + for (uint32 i = 0; i < _surfaces.size(); i++) { + if (scumm_stricmp(_surfaces[i]->getFileName(), filename.c_str()) == 0) { + _surfaces[i]->_referenceCount++; + return _surfaces[i]; + } + } + + if (!BaseFileManager::getEngineInstance()->hasFile(filename)) { + if (filename.size()) { + _gameRef->LOG(0, "Missing image: '%s'", filename.c_str()); + } + if (_gameRef->_debugDebugMode) { + return addSurface("invalid_debug.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } else { + return addSurface("invalid.bmp", defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded); + } + } + + BaseSurface *surface; + surface = _gameRef->_renderer->createSurface(); + + if (!surface) { + return NULL; + } + + if (DID_FAIL(surface->create(filename, defaultCK, ckRed, ckGreen, ckBlue, lifeTime, keepLoaded))) { + delete surface; + return NULL; + } else { + surface->_referenceCount = 1; + _surfaces.push_back(surface); + return surface; + } +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::restoreAll() { + bool ret; + for (uint32 i = 0; i < _surfaces.size(); i++) { + ret = _surfaces[i]->restore(); + if (ret != STATUS_OK) { + _gameRef->LOG(0, "BaseSurfaceStorage::RestoreAll failed"); + return ret; + } + } + return STATUS_OK; +} + + +/* +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::persist(BasePersistenceManager *persistMgr) +{ + + if (!persistMgr->getIsSaving()) cleanup(false); + + persistMgr->transfer(TMEMBER(_gameRef)); + + //_surfaces.persist(persistMgr); + + return STATUS_OK; +} +*/ + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceStorage::sortSurfaces() { + Common::sort(_surfaces.begin(), _surfaces.end(), surfaceSortCB); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseSurfaceStorage::surfaceSortCB(const void *arg1, const void *arg2) { + const BaseSurface *s1 = *((const BaseSurface *const *)arg1); + const BaseSurface *s2 = *((const BaseSurface *const *)arg2); + + // sort by life time + if (s1->_lifeTime <= 0 && s2->_lifeTime > 0) { + return 1; + } else if (s1->_lifeTime > 0 && s2->_lifeTime <= 0) { + return -1; + } + + + // sort by validity + if (s1->_valid && !s2->_valid) { + return -1; + } else if (!s1->_valid && s2->_valid) { + return 1; + } + + // sort by time + else if (s1->_lastUsedTime > s2->_lastUsedTime) { + return 1; + } else if (s1->_lastUsedTime < s2->_lastUsedTime) { + return -1; + } else { + return 0; + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_surface_storage.h b/engines/wintermute/base/base_surface_storage.h index 28c36bebca..aef8ad23f9 100644 --- a/engines/wintermute/base/base_surface_storage.h +++ b/engines/wintermute/base/base_surface_storage.h @@ -1,57 +1,57 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SURFACE_STORAGE_H -#define WINTERMUTE_BASE_SURFACE_STORAGE_H - -#include "engines/wintermute/base/base.h" -#include "common/array.h" - -namespace Wintermute { -class BaseSurface; -class BaseSurfaceStorage : public BaseClass { -public: - uint32 _lastCleanupTime; - bool initLoop(); - bool sortSurfaces(); - static int surfaceSortCB(const void *arg1, const void *arg2); - bool cleanup(bool warn = false); - //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); - - bool restoreAll(); - BaseSurface *addSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); - bool removeSurface(BaseSurface *surface); - BaseSurfaceStorage(BaseGame *inGame); - virtual ~BaseSurfaceStorage(); - - Common::Array _surfaces; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACE_STORAGE_H +#define WINTERMUTE_BASE_SURFACE_STORAGE_H + +#include "engines/wintermute/base/base.h" +#include "common/array.h" + +namespace Wintermute { +class BaseSurface; +class BaseSurfaceStorage : public BaseClass { +public: + uint32 _lastCleanupTime; + bool initLoop(); + bool sortSurfaces(); + static int surfaceSortCB(const void *arg1, const void *arg2); + bool cleanup(bool warn = false); + //DECLARE_PERSISTENT(BaseSurfaceStorage, BaseClass); + + bool restoreAll(); + BaseSurface *addSurface(const Common::String &filename, bool defaultCK = true, byte ckRed = 0, byte ckGreen = 0, byte ckBlue = 0, int lifeTime = -1, bool keepLoaded = false); + bool removeSurface(BaseSurface *surface); + BaseSurfaceStorage(BaseGame *inGame); + virtual ~BaseSurfaceStorage(); + + Common::Array _surfaces; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index d71bce1084..5c28f36d30 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -1,136 +1,136 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_transition_manager.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { - _state = TRANS_MGR_READY; - _type = TRANSITION_NONE; - _origInteractive = false; - _preserveInteractive = false; - _lastTime = 0; - _started = false; -} - - - -////////////////////////////////////////////////////////////////////////// -BaseTransitionMgr::~BaseTransitionMgr() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseTransitionMgr::isReady() { - return (_state == TRANS_MGR_READY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { - if (_state != TRANS_MGR_READY) { - return STATUS_OK; - } - - if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { - _state = TRANS_MGR_READY; - return STATUS_OK; - } - - if (nonInteractive) { - _preserveInteractive = true; - _origInteractive = _gameRef->_interactive; - _gameRef->_interactive = false; - } /*else _preserveInteractive */; - - - _type = type; - _state = TRANS_MGR_RUNNING; - _started = false; - - return STATUS_OK; -} - -#define FADE_DURATION 200 - -////////////////////////////////////////////////////////////////////////// -bool BaseTransitionMgr::update() { - if (isReady()) { - return STATUS_OK; - } - - if (!_started) { - _started = true; - _lastTime = g_system->getMillis(); - } - - switch (_type) { - case TRANSITION_NONE: - _state = TRANS_MGR_READY; - break; - - case TRANSITION_FADE_OUT: { - uint32 time = g_system->getMillis() - _lastTime; - int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) { - _state = TRANS_MGR_READY; - } - } - break; - - case TRANSITION_FADE_IN: { - uint32 time = g_system->getMillis() - _lastTime; - int alpha = (int)((float)time / (float)FADE_DURATION * 255); - alpha = MIN(255, MAX(alpha, 0)); - _gameRef->_renderer->fade((uint16)alpha); - - if (time > FADE_DURATION) { - _state = TRANS_MGR_READY; - } - } - break; - default: - error("BaseTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); - } - - if (isReady()) { - if (_preserveInteractive) { - _gameRef->_interactive = _origInteractive; - } - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_transition_manager.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseTransitionMgr::BaseTransitionMgr(BaseGame *inGame) : BaseClass(inGame) { + _state = TRANS_MGR_READY; + _type = TRANSITION_NONE; + _origInteractive = false; + _preserveInteractive = false; + _lastTime = 0; + _started = false; +} + + + +////////////////////////////////////////////////////////////////////////// +BaseTransitionMgr::~BaseTransitionMgr() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseTransitionMgr::isReady() { + return (_state == TRANS_MGR_READY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseTransitionMgr::start(TTransitionType type, bool nonInteractive) { + if (_state != TRANS_MGR_READY) { + return STATUS_OK; + } + + if (type == TRANSITION_NONE || type >= NUM_TRANSITION_TYPES) { + _state = TRANS_MGR_READY; + return STATUS_OK; + } + + if (nonInteractive) { + _preserveInteractive = true; + _origInteractive = _gameRef->_interactive; + _gameRef->_interactive = false; + } /*else _preserveInteractive */; + + + _type = type; + _state = TRANS_MGR_RUNNING; + _started = false; + + return STATUS_OK; +} + +#define FADE_DURATION 200 + +////////////////////////////////////////////////////////////////////////// +bool BaseTransitionMgr::update() { + if (isReady()) { + return STATUS_OK; + } + + if (!_started) { + _started = true; + _lastTime = g_system->getMillis(); + } + + switch (_type) { + case TRANSITION_NONE: + _state = TRANS_MGR_READY; + break; + + case TRANSITION_FADE_OUT: { + uint32 time = g_system->getMillis() - _lastTime; + int alpha = (int)(255 - (float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) { + _state = TRANS_MGR_READY; + } + } + break; + + case TRANSITION_FADE_IN: { + uint32 time = g_system->getMillis() - _lastTime; + int alpha = (int)((float)time / (float)FADE_DURATION * 255); + alpha = MIN(255, MAX(alpha, 0)); + _gameRef->_renderer->fade((uint16)alpha); + + if (time > FADE_DURATION) { + _state = TRANS_MGR_READY; + } + } + break; + default: + error("BaseTransitionMgr::Update - unhandled enum NUM_TRANSITION_TYPES"); + } + + if (isReady()) { + if (_preserveInteractive) { + _gameRef->_interactive = _origInteractive; + } + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_transition_manager.h b/engines/wintermute/base/base_transition_manager.h index 1a989fbcfd..d16a44c88e 100644 --- a/engines/wintermute/base/base_transition_manager.h +++ b/engines/wintermute/base/base_transition_manager.h @@ -1,54 +1,54 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_TRANSITION_MANAGER_H -#define WINTERMUTE_BASE_TRANSITION_MANAGER_H - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -class BaseTransitionMgr : public BaseClass { -public: - bool _started; - uint32 _lastTime; - bool _origInteractive; - bool _preserveInteractive; - bool update(); - bool start(TTransitionType type, bool nonInteractive = false); - bool isReady(); - TTransMgrState _state; - BaseTransitionMgr(BaseGame *inGame); - virtual ~BaseTransitionMgr(); - TTransitionType _type; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_TRANSITION_MANAGER_H +#define WINTERMUTE_BASE_TRANSITION_MANAGER_H + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +class BaseTransitionMgr : public BaseClass { +public: + bool _started; + uint32 _lastTime; + bool _origInteractive; + bool _preserveInteractive; + bool update(); + bool start(TTransitionType type, bool nonInteractive = false); + bool isReady(); + TTransMgrState _state; + BaseTransitionMgr(BaseGame *inGame); + virtual ~BaseTransitionMgr(); + TTransitionType _type; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index af36a4fdd7..3b003e1c49 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -1,98 +1,98 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/base_viewport.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseViewport, false) - -////////////////////////////////////////////////////////////////////////// -BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { - BasePlatform::setRectEmpty(&_rect); - _mainObject = NULL; - _offsetX = _offsetY = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseViewport::~BaseViewport() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseViewport::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_mainObject)); - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_rect)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { - if (!noCheck) { - left = MAX(left, 0); - top = MAX(top, 0); - right = MIN(right, _gameRef->_renderer->_width); - bottom = MIN(bottom, _gameRef->_renderer->_height); - } - - BasePlatform::setRect(&_rect, left, top, right, bottom); - _offsetX = left; - _offsetY = top; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -Rect32 *BaseViewport::getRect() { - return &_rect; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseViewport::getWidth() { - return _rect.right - _rect.left; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseViewport::getHeight() { - return _rect.bottom - _rect.top; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_viewport.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseViewport, false) + +////////////////////////////////////////////////////////////////////////// +BaseViewport::BaseViewport(BaseGame *inGame) : BaseClass(inGame) { + BasePlatform::setRectEmpty(&_rect); + _mainObject = NULL; + _offsetX = _offsetY = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseViewport::~BaseViewport() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseViewport::persist(BasePersistenceManager *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_mainObject)); + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_rect)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseViewport::setRect(int left, int top, int right, int bottom, bool noCheck) { + if (!noCheck) { + left = MAX(left, 0); + top = MAX(top, 0); + right = MIN(right, _gameRef->_renderer->_width); + bottom = MIN(bottom, _gameRef->_renderer->_height); + } + + BasePlatform::setRect(&_rect, left, top, right, bottom); + _offsetX = left; + _offsetY = top; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +Rect32 *BaseViewport::getRect() { + return &_rect; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseViewport::getWidth() { + return _rect.right - _rect.left; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseViewport::getHeight() { + return _rect.bottom - _rect.top; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/base_viewport.h b/engines/wintermute/base/base_viewport.h index c94beeb2b1..98ad1c1e14 100644 --- a/engines/wintermute/base/base_viewport.h +++ b/engines/wintermute/base/base_viewport.h @@ -1,55 +1,55 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_VIEWPORT_H -#define WINTERMUTE_BASE_VIEWPORT_H - - -#include "engines/wintermute/base/base.h" - -namespace Wintermute { -class BaseObject; -class BaseViewport : public BaseClass { -public: - int getHeight(); - int getWidth(); - Rect32 *getRect(); - bool setRect(int left, int top, int right, int bottom, bool noCheck = false); - DECLARE_PERSISTENT(BaseViewport, BaseClass) - int _offsetY; - int _offsetX; - BaseObject *_mainObject; - BaseViewport(BaseGame *inGame = NULL); - virtual ~BaseViewport(); -private: - Rect32 _rect; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_VIEWPORT_H +#define WINTERMUTE_BASE_VIEWPORT_H + + +#include "engines/wintermute/base/base.h" + +namespace Wintermute { +class BaseObject; +class BaseViewport : public BaseClass { +public: + int getHeight(); + int getWidth(); + Rect32 *getRect(); + bool setRect(int left, int top, int right, int bottom, bool noCheck = false); + DECLARE_PERSISTENT(BaseViewport, BaseClass) + int _offsetY; + int _offsetX; + BaseObject *_mainObject; + BaseViewport(BaseGame *inGame = NULL); + virtual ~BaseViewport(); +private: + Rect32 _rect; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 8fff78a32a..2d3951b026 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -1,196 +1,196 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/dcgf.h" -#include "engines/wintermute/base/file/base_disk_file.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "common/stream.h" -#include "common/memstream.h" -#include "common/file.h" -#include "common/zlib.h" -#include "common/archive.h" -#include "common/tokenizer.h" -#include "common/config-manager.h" - -namespace Wintermute { - -void correctSlashes(char *fileName) { - for (size_t i = 0; i < strlen(fileName); i++) { - if (fileName[i] == '\\') { - fileName[i] = '/'; - } - } -} - -// Parse a relative path in the game-folder, and if it exists, return a FSNode to it. -static Common::FSNode getNodeForRelativePath(const Common::String &filename) { - // The filename can be an explicit path, thus we need to chop it up, expecting the path the game - // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) - - // Absolute path: These should have been handled in openDiskFile. - if (filename.contains(':')) { - // So just return an invalid node. - return Common::FSNode(); - } - - // Relative path: - if (filename.contains('\\')) { - Common::StringTokenizer path(filename, "\\"); - - // Start traversing relative to the game-data-dir - const Common::FSNode gameDataDir(ConfMan.get("path")); - Common::FSNode curNode = gameDataDir; - - // Parse all path-elements - while (!path.empty()) { - // Get the next path-component by slicing on '\\' - Common::String pathPart = path.nextToken(); - // Get the next FSNode in the chain, if it exists as a child from the previous. - curNode = curNode.getChild(pathPart); - if (!curNode.isReadable()) { - // Return an invalid FSNode. - return Common::FSNode(); - } - // Following the comments in common/fs.h, anything not a directory is a file. - if (!curNode.isDirectory()) { - if (!path.empty()) { - error("Relative path %s reached a file before the end of the path", filename.c_str()); - } - return curNode; - } - } - } - // Return an invalid FSNode to mark that we didn't find the requested file. - return Common::FSNode(); -} - -bool diskFileExists(const Common::String &filename) { - // Try directly from SearchMan first - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, filename); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { - if ((*it)->getName() == filename) { - return true; - } - } - // File wasn't found in SearchMan, try to parse the path as a relative path. - Common::FSNode searchNode = getNodeForRelativePath(filename); - if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { - return true; - } - return false; -} - -Common::SeekableReadStream *openDiskFile(const Common::String &filename) { - uint32 prefixSize = 0; - Common::SeekableReadStream *file = NULL; - Common::String fixedFilename = filename; - - // Absolute path: TODO: Add specific fallbacks here. - if (filename.contains(':')) { - if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" - fixedFilename = filename.c_str() + 17; - } else { - error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); - } - } - // Try directly from SearchMan first - Common::ArchiveMemberList files; - SearchMan.listMatchingMembers(files, fixedFilename); - - for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { - if ((*it)->getName() == filename) { - file = (*it)->createReadStream(); - break; - } - } - // File wasn't found in SearchMan, try to parse the path as a relative path. - if (!file) { - Common::FSNode searchNode = getNodeForRelativePath(filename); - if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { - file = searchNode.createReadStream(); - } - } - if (file) { - uint32 magic1, magic2; - magic1 = file->readUint32LE(); - magic2 = file->readUint32LE(); - - bool compressed = false; - if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) { - compressed = true; - } - - if (compressed) { - uint32 dataOffset, compSize, uncompSize; - dataOffset = file->readUint32LE(); - compSize = file->readUint32LE(); - uncompSize = file->readUint32LE(); - - byte *compBuffer = new byte[compSize]; - if (!compBuffer) { - error("Error allocating memory for compressed file '%s'", filename.c_str()); - delete file; - return NULL; - } - - byte *data = new byte[uncompSize]; - if (!data) { - error("Error allocating buffer for file '%s'", filename.c_str()); - delete[] compBuffer; - delete file; - return NULL; - } - file->seek(dataOffset + prefixSize, SEEK_SET); - file->read(compBuffer, compSize); - - if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { - error("Error uncompressing file '%s'", filename.c_str()); - delete[] compBuffer; - delete file; - return NULL; - } - - delete[] compBuffer; - - return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); - delete file; - file = NULL; - } else { - file->seek(0, SEEK_SET); - return file; - } - - return file; - - } - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/dcgf.h" +#include "engines/wintermute/base/file/base_disk_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "common/stream.h" +#include "common/memstream.h" +#include "common/file.h" +#include "common/zlib.h" +#include "common/archive.h" +#include "common/tokenizer.h" +#include "common/config-manager.h" + +namespace Wintermute { + +void correctSlashes(char *fileName) { + for (size_t i = 0; i < strlen(fileName); i++) { + if (fileName[i] == '\\') { + fileName[i] = '/'; + } + } +} + +// Parse a relative path in the game-folder, and if it exists, return a FSNode to it. +static Common::FSNode getNodeForRelativePath(const Common::String &filename) { + // The filename can be an explicit path, thus we need to chop it up, expecting the path the game + // specifies to follow the Windows-convention of folder\subfolder\file (absolute paths should not happen) + + // Absolute path: These should have been handled in openDiskFile. + if (filename.contains(':')) { + // So just return an invalid node. + return Common::FSNode(); + } + + // Relative path: + if (filename.contains('\\')) { + Common::StringTokenizer path(filename, "\\"); + + // Start traversing relative to the game-data-dir + const Common::FSNode gameDataDir(ConfMan.get("path")); + Common::FSNode curNode = gameDataDir; + + // Parse all path-elements + while (!path.empty()) { + // Get the next path-component by slicing on '\\' + Common::String pathPart = path.nextToken(); + // Get the next FSNode in the chain, if it exists as a child from the previous. + curNode = curNode.getChild(pathPart); + if (!curNode.isReadable()) { + // Return an invalid FSNode. + return Common::FSNode(); + } + // Following the comments in common/fs.h, anything not a directory is a file. + if (!curNode.isDirectory()) { + if (!path.empty()) { + error("Relative path %s reached a file before the end of the path", filename.c_str()); + } + return curNode; + } + } + } + // Return an invalid FSNode to mark that we didn't find the requested file. + return Common::FSNode(); +} + +bool diskFileExists(const Common::String &filename) { + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, filename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { + if ((*it)->getName() == filename) { + return true; + } + } + // File wasn't found in SearchMan, try to parse the path as a relative path. + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + return true; + } + return false; +} + +Common::SeekableReadStream *openDiskFile(const Common::String &filename) { + uint32 prefixSize = 0; + Common::SeekableReadStream *file = NULL; + Common::String fixedFilename = filename; + + // Absolute path: TODO: Add specific fallbacks here. + if (filename.contains(':')) { + if (filename.hasPrefix("c:\\windows\\fonts\\")) { // East Side Story refers to "c:\windows\fonts\framd.ttf" + fixedFilename = filename.c_str() + 17; + } else { + error("openDiskFile::Absolute path or invalid filename used in %s", filename.c_str()); + } + } + // Try directly from SearchMan first + Common::ArchiveMemberList files; + SearchMan.listMatchingMembers(files, fixedFilename); + + for (Common::ArchiveMemberList::iterator it = files.begin(); it != files.end(); ++it) { + if ((*it)->getName() == filename) { + file = (*it)->createReadStream(); + break; + } + } + // File wasn't found in SearchMan, try to parse the path as a relative path. + if (!file) { + Common::FSNode searchNode = getNodeForRelativePath(filename); + if (searchNode.exists() && !searchNode.isDirectory() && searchNode.isReadable()) { + file = searchNode.createReadStream(); + } + } + if (file) { + uint32 magic1, magic2; + magic1 = file->readUint32LE(); + magic2 = file->readUint32LE(); + + bool compressed = false; + if (magic1 == DCGF_MAGIC && magic2 == COMPRESSED_FILE_MAGIC) { + compressed = true; + } + + if (compressed) { + uint32 dataOffset, compSize, uncompSize; + dataOffset = file->readUint32LE(); + compSize = file->readUint32LE(); + uncompSize = file->readUint32LE(); + + byte *compBuffer = new byte[compSize]; + if (!compBuffer) { + error("Error allocating memory for compressed file '%s'", filename.c_str()); + delete file; + return NULL; + } + + byte *data = new byte[uncompSize]; + if (!data) { + error("Error allocating buffer for file '%s'", filename.c_str()); + delete[] compBuffer; + delete file; + return NULL; + } + file->seek(dataOffset + prefixSize, SEEK_SET); + file->read(compBuffer, compSize); + + if (Common::uncompress(data, (unsigned long *)&uncompSize, compBuffer, compSize) != true) { + error("Error uncompressing file '%s'", filename.c_str()); + delete[] compBuffer; + delete file; + return NULL; + } + + delete[] compBuffer; + + return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); + delete file; + file = NULL; + } else { + file->seek(0, SEEK_SET); + return file; + } + + return file; + + } + return NULL; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_disk_file.h b/engines/wintermute/base/file/base_disk_file.h index 69644408d0..c9f93b80d9 100644 --- a/engines/wintermute/base/file/base_disk_file.h +++ b/engines/wintermute/base/file/base_disk_file.h @@ -1,41 +1,41 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_DISKFILE_H -#define WINTERMUTE_BASE_DISKFILE_H - -#include "common/stream.h" - -namespace Wintermute { - -Common::SeekableReadStream *openDiskFile(const Common::String &filename); -bool diskFileExists(const Common::String &filename); - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_DISKFILE_H +#define WINTERMUTE_BASE_DISKFILE_H + +#include "common/stream.h" + +namespace Wintermute { + +Common::SeekableReadStream *openDiskFile(const Common::String &filename); +bool diskFileExists(const Common::String &filename); + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_file.cpp b/engines/wintermute/base/file/base_file.cpp index f2a347ee0f..f52a13211e 100644 --- a/engines/wintermute/base/file/base_file.cpp +++ b/engines/wintermute/base/file/base_file.cpp @@ -1,68 +1,68 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_file.h" -#include "common/memstream.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -BaseFile::BaseFile() { - _pos = 0; - _size = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFile::~BaseFile() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFile::isEOF() { - return _pos == _size; -} - -Common::SeekableReadStream *BaseFile::getMemStream() { - uint32 oldPos = getPos(); - seek(0); - byte *data = new byte[getSize()]; - read(data, getSize()); - seek(oldPos); - Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); - return memStream; -} - - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_file.h" +#include "common/memstream.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +BaseFile::BaseFile() { + _pos = 0; + _size = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFile::~BaseFile() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFile::isEOF() { + return _pos == _size; +} + +Common::SeekableReadStream *BaseFile::getMemStream() { + uint32 oldPos = getPos(); + seek(0); + byte *data = new byte[getSize()]; + read(data, getSize()); + seek(oldPos); + Common::MemoryReadStream *memStream = new Common::MemoryReadStream(data, getSize(), DisposeAfterUse::YES); + return memStream; +} + + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file.h b/engines/wintermute/base/file/base_file.h index 7ae36d5ad1..82f6ce3554 100644 --- a/engines/wintermute/base/file/base_file.h +++ b/engines/wintermute/base/file/base_file.h @@ -1,67 +1,67 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FILE_H -#define WINTERMUTE_BASE_FILE_H - - -#include "engines/wintermute/base/base.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Common { -class SeekableReadStream; -} - -namespace Wintermute { - -class BaseFile { -protected: - uint32 _pos; - uint32 _size; -public: - virtual uint32 getSize() { - return _size; - }; - virtual uint32 getPos() { - return _pos; - }; - virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; - virtual bool read(void *buffer, uint32 size) = 0; - virtual bool close() = 0; - virtual bool open(const Common::String &filename) = 0; - virtual bool isEOF(); - BaseFile(); - virtual ~BaseFile(); - // Temporary solution to allow usage in ScummVM-code: - virtual Common::SeekableReadStream *getMemStream(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILE_H +#define WINTERMUTE_BASE_FILE_H + + +#include "engines/wintermute/base/base.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Common { +class SeekableReadStream; +} + +namespace Wintermute { + +class BaseFile { +protected: + uint32 _pos; + uint32 _size; +public: + virtual uint32 getSize() { + return _size; + }; + virtual uint32 getPos() { + return _pos; + }; + virtual bool seek(uint32 pos, int whence = SEEK_SET) = 0; + virtual bool read(void *buffer, uint32 size) = 0; + virtual bool close() = 0; + virtual bool open(const Common::String &filename) = 0; + virtual bool isEOF(); + BaseFile(); + virtual ~BaseFile(); + // Temporary solution to allow usage in ScummVM-code: + virtual Common::SeekableReadStream *getMemStream(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_file_entry.cpp b/engines/wintermute/base/file/base_file_entry.cpp index 82ddf7c90e..b9805d78dd 100644 --- a/engines/wintermute/base/file/base_file_entry.cpp +++ b/engines/wintermute/base/file/base_file_entry.cpp @@ -1,73 +1,73 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_file_entry.h" -#include "engines/wintermute/base/file/base_package.h" -#include "common/stream.h" -#include "common/substream.h" -#include "common/zlib.h" - -namespace Wintermute { - -Common::SeekableReadStream *BaseFileEntry::createReadStream() const { - Common::SeekableReadStream *file = _package->getFilePointer(); - if (!file) { - return NULL; - } - - bool compressed = (_compressedLength != 0); - - if (compressed) { - file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // - } else { - file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); - } - - file->seek(0); - - return file; -} - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry::BaseFileEntry() { - _package = NULL; - _length = _compressedLength = _offset = _flags = 0; - _filename = ""; - - _timeDate1 = _timeDate2 = 0; - - _journalTime = 0; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFileEntry::~BaseFileEntry() { - _package = NULL; // ref only -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/base_package.h" +#include "common/stream.h" +#include "common/substream.h" +#include "common/zlib.h" + +namespace Wintermute { + +Common::SeekableReadStream *BaseFileEntry::createReadStream() const { + Common::SeekableReadStream *file = _package->getFilePointer(); + if (!file) { + return NULL; + } + + bool compressed = (_compressedLength != 0); + + if (compressed) { + file = Common::wrapCompressedReadStream(new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES), _length); // + } else { + file = new Common::SeekableSubReadStream(file, _offset, _offset + _length, DisposeAfterUse::YES); + } + + file->seek(0); + + return file; +} + +////////////////////////////////////////////////////////////////////////// +BaseFileEntry::BaseFileEntry() { + _package = NULL; + _length = _compressedLength = _offset = _flags = 0; + _filename = ""; + + _timeDate1 = _timeDate2 = 0; + + _journalTime = 0; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFileEntry::~BaseFileEntry() { + _package = NULL; // ref only +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_file_entry.h b/engines/wintermute/base/file/base_file_entry.h index 6dd4bc08a4..6e4823d994 100644 --- a/engines/wintermute/base/file/base_file_entry.h +++ b/engines/wintermute/base/file/base_file_entry.h @@ -1,60 +1,60 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FILEENTRY_H -#define WINTERMUTE_BASE_FILEENTRY_H - -#include "common/archive.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Wintermute { - -class BasePackage; - -class BaseFileEntry : public Common::ArchiveMember { -public: - virtual Common::SeekableReadStream *createReadStream() const; - virtual Common::String getName() const { return _filename; } - uint32 _timeDate2; - uint32 _timeDate1; - uint32 _flags; - uint32 _journalTime; - Common::String _filename; - uint32 _compressedLength; - uint32 _length; - uint32 _offset; - BasePackage *_package; - BaseFileEntry(); - virtual ~BaseFileEntry(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FILEENTRY_H +#define WINTERMUTE_BASE_FILEENTRY_H + +#include "common/archive.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Wintermute { + +class BasePackage; + +class BaseFileEntry : public Common::ArchiveMember { +public: + virtual Common::SeekableReadStream *createReadStream() const; + virtual Common::String getName() const { return _filename; } + uint32 _timeDate2; + uint32 _timeDate1; + uint32 _flags; + uint32 _journalTime; + Common::String _filename; + uint32 _compressedLength; + uint32 _length; + uint32 _offset; + BasePackage *_package; + BaseFileEntry(); + virtual ~BaseFileEntry(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index c5a62299e2..9780992652 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -1,276 +1,276 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_package.h" -#include "engines/wintermute/base/file/base_file_entry.h" -#include "engines/wintermute/base/file/dcpackage.h" -#include "engines/wintermute/wintermute.h" -#include "common/file.h" -#include "common/stream.h" -#include "common/debug.h" - -namespace Wintermute { - -BasePackage::BasePackage() { - _name = ""; - _cd = 0; - _priority = 0; - _boundToExe = false; -} - -Common::SeekableReadStream *BasePackage::getFilePointer() { - Common::SeekableReadStream *stream = _fsnode.createReadStream(); - - return stream; -} - -static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { - byte buf[32768]; - - byte signature[8]; - ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; - ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; - - uint32 fileSize = (uint32)f->size(); - uint32 startPos = 1024 * 1024; - uint32 bytesRead = startPos; - - while (bytesRead < fileSize - 16) { - uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); - f->seek((int32)startPos, SEEK_SET); - uint32 actuallyRead = f->read(buf, toRead); - if (actuallyRead != toRead) { - return false; - } - - for (uint32 i = 0; i < toRead - 8; i++) - if (!memcmp(buf + i, signature, 8)) { - *offset = startPos + i; - return true; - } - - bytesRead = bytesRead + toRead - 16; - startPos = startPos + toRead - 16; - - } - return false; - -} - -void TPackageHeader::readFromStream(Common::ReadStream *stream) { - _magic1 = stream->readUint32LE(); - _magic2 = stream->readUint32LE(); - _packageVersion = stream->readUint32LE(); - - _gameVersion = stream->readUint32LE(); - - _priority = stream->readByte(); - _cd = stream->readByte(); - _masterIndex = stream->readByte(); - stream->readByte(); // To align the next byte... - - _creationTime = stream->readUint32LE(); - - stream->read(_desc, 100); - _numDirs = stream->readUint32LE(); -} - -PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { - uint32 absoluteOffset = 0; - _priority = 0; - bool boundToExe = false; - Common::SeekableReadStream *stream = file.createReadStream(); - if (!stream) { - return; - } - if (searchSignature) { - uint32 offset; - if (!findPackageSignature(stream, &offset)) { - delete stream; - return; - } else { - stream->seek(offset, SEEK_SET); - absoluteOffset = offset; - boundToExe = true; - } - } - - TPackageHeader hdr; - hdr.readFromStream(stream); - if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); - delete stream; - return; - } - - if (hdr._packageVersion != PACKAGE_VERSION) { - debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); - } - _priority = hdr._priority; - // new in v2 - if (hdr._packageVersion == PACKAGE_VERSION) { - uint32 dirOffset; - dirOffset = stream->readUint32LE(); - dirOffset += absoluteOffset; - stream->seek(dirOffset, SEEK_SET); - } - assert(hdr._numDirs == 1); - for (uint32 i = 0; i < hdr._numDirs; i++) { - BasePackage *pkg = new BasePackage(); - if (!pkg) { - return; - } - pkg->_fsnode = file; - - pkg->_boundToExe = boundToExe; - - // read package info - byte nameLength = stream->readByte(); - char *pkgName = new char[nameLength]; - stream->read(pkgName, nameLength); - pkg->_name = pkgName; - pkg->_cd = stream->readByte(); - pkg->_priority = hdr._priority; - delete[] pkgName; - pkgName = NULL; - - if (!hdr._masterIndex) { - pkg->_cd = 0; // override CD to fixed disk - } - _packages.push_back(pkg); - - // read file entries - uint32 numFiles = stream->readUint32LE(); - - for (uint32 j = 0; j < numFiles; j++) { - char *name; - uint32 offset, length, compLength, flags;/*, timeDate1, timeDate2;*/ - - nameLength = stream->readByte(); - name = new char[nameLength]; - stream->read(name, nameLength); - - // v2 - xor name - if (hdr._packageVersion == PACKAGE_VERSION) { - for (int k = 0; k < nameLength; k++) { - ((byte *)name)[k] ^= 'D'; - } - } - debugC(kWintermuteDebugFileAccess, "Package contains %s", name); - - Common::String upcName = name; - upcName.toUppercase(); - delete[] name; - name = NULL; - - offset = stream->readUint32LE(); - offset += absoluteOffset; - length = stream->readUint32LE(); - compLength = stream->readUint32LE(); - flags = stream->readUint32LE(); - - if (hdr._packageVersion == PACKAGE_VERSION) { - /* timeDate1 = */ stream->readUint32LE(); - /* timeDate2 = */ stream->readUint32LE(); - } - _filesIter = _files.find(upcName); - if (_filesIter == _files.end()) { - BaseFileEntry *fileEntry = new BaseFileEntry(); - fileEntry->_package = pkg; - fileEntry->_offset = offset; - fileEntry->_length = length; - fileEntry->_compressedLength = compLength; - fileEntry->_flags = flags; - - _files[upcName] = Common::ArchiveMemberPtr(fileEntry); - } else { - // current package has higher priority than the registered - // TODO: This cast might be a bit ugly. - BaseFileEntry *filePtr = (BaseFileEntry *) &*(_filesIter->_value); - if (pkg->_priority > filePtr->_package->_priority) { - filePtr->_package = pkg; - filePtr->_offset = offset; - filePtr->_length = length; - filePtr->_compressedLength = compLength; - filePtr->_flags = flags; - } - } - } - } - debugC(kWintermuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); - - delete stream; -} - -PackageSet::~PackageSet() { - for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); ++it) { - delete *it; - } - _packages.clear(); -} - -bool PackageSet::hasFile(const Common::String &name) const { - Common::String upcName = name; - upcName.toUppercase(); - Common::HashMap::const_iterator it; - it = _files.find(upcName.c_str()); - return (it != _files.end()); -} - -int PackageSet::listMembers(Common::ArchiveMemberList &list) const { - Common::HashMap::const_iterator it = _files.begin(); - Common::HashMap::const_iterator end = _files.end(); - int count = 0; - for (; it != end; ++it) { - const Common::ArchiveMemberPtr ptr(it->_value); - list.push_back(ptr); - count++; - } - return count; -} - -const Common::ArchiveMemberPtr PackageSet::getMember(const Common::String &name) const { - Common::String upcName = name; - upcName.toUppercase(); - Common::HashMap::const_iterator it; - it = _files.find(upcName.c_str()); - return Common::ArchiveMemberPtr(it->_value); -} - -Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::String &name) const { - Common::String upcName = name; - upcName.toUppercase(); - Common::HashMap::const_iterator it; - it = _files.find(upcName.c_str()); - if (it != _files.end()) { - return it->_value->createReadStream(); - } - return NULL; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_package.h" +#include "engines/wintermute/base/file/base_file_entry.h" +#include "engines/wintermute/base/file/dcpackage.h" +#include "engines/wintermute/wintermute.h" +#include "common/file.h" +#include "common/stream.h" +#include "common/debug.h" + +namespace Wintermute { + +BasePackage::BasePackage() { + _name = ""; + _cd = 0; + _priority = 0; + _boundToExe = false; +} + +Common::SeekableReadStream *BasePackage::getFilePointer() { + Common::SeekableReadStream *stream = _fsnode.createReadStream(); + + return stream; +} + +static bool findPackageSignature(Common::SeekableReadStream *f, uint32 *offset) { + byte buf[32768]; + + byte signature[8]; + ((uint32 *)signature)[0] = PACKAGE_MAGIC_1; + ((uint32 *)signature)[1] = PACKAGE_MAGIC_2; + + uint32 fileSize = (uint32)f->size(); + uint32 startPos = 1024 * 1024; + uint32 bytesRead = startPos; + + while (bytesRead < fileSize - 16) { + uint32 toRead = MIN((unsigned int)32768, fileSize - bytesRead); + f->seek((int32)startPos, SEEK_SET); + uint32 actuallyRead = f->read(buf, toRead); + if (actuallyRead != toRead) { + return false; + } + + for (uint32 i = 0; i < toRead - 8; i++) + if (!memcmp(buf + i, signature, 8)) { + *offset = startPos + i; + return true; + } + + bytesRead = bytesRead + toRead - 16; + startPos = startPos + toRead - 16; + + } + return false; + +} + +void TPackageHeader::readFromStream(Common::ReadStream *stream) { + _magic1 = stream->readUint32LE(); + _magic2 = stream->readUint32LE(); + _packageVersion = stream->readUint32LE(); + + _gameVersion = stream->readUint32LE(); + + _priority = stream->readByte(); + _cd = stream->readByte(); + _masterIndex = stream->readByte(); + stream->readByte(); // To align the next byte... + + _creationTime = stream->readUint32LE(); + + stream->read(_desc, 100); + _numDirs = stream->readUint32LE(); +} + +PackageSet::PackageSet(Common::FSNode file, const Common::String &filename, bool searchSignature) { + uint32 absoluteOffset = 0; + _priority = 0; + bool boundToExe = false; + Common::SeekableReadStream *stream = file.createReadStream(); + if (!stream) { + return; + } + if (searchSignature) { + uint32 offset; + if (!findPackageSignature(stream, &offset)) { + delete stream; + return; + } else { + stream->seek(offset, SEEK_SET); + absoluteOffset = offset; + boundToExe = true; + } + } + + TPackageHeader hdr; + hdr.readFromStream(stream); + if (hdr._magic1 != PACKAGE_MAGIC_1 || hdr._magic2 != PACKAGE_MAGIC_2 || hdr._packageVersion > PACKAGE_VERSION) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Invalid header in package file '%s'. Ignoring.", filename.c_str()); + delete stream; + return; + } + + if (hdr._packageVersion != PACKAGE_VERSION) { + debugC(kWintermuteDebugFileAccess | kWintermuteDebugLog, " Warning: package file '%s' is outdated.", filename.c_str()); + } + _priority = hdr._priority; + // new in v2 + if (hdr._packageVersion == PACKAGE_VERSION) { + uint32 dirOffset; + dirOffset = stream->readUint32LE(); + dirOffset += absoluteOffset; + stream->seek(dirOffset, SEEK_SET); + } + assert(hdr._numDirs == 1); + for (uint32 i = 0; i < hdr._numDirs; i++) { + BasePackage *pkg = new BasePackage(); + if (!pkg) { + return; + } + pkg->_fsnode = file; + + pkg->_boundToExe = boundToExe; + + // read package info + byte nameLength = stream->readByte(); + char *pkgName = new char[nameLength]; + stream->read(pkgName, nameLength); + pkg->_name = pkgName; + pkg->_cd = stream->readByte(); + pkg->_priority = hdr._priority; + delete[] pkgName; + pkgName = NULL; + + if (!hdr._masterIndex) { + pkg->_cd = 0; // override CD to fixed disk + } + _packages.push_back(pkg); + + // read file entries + uint32 numFiles = stream->readUint32LE(); + + for (uint32 j = 0; j < numFiles; j++) { + char *name; + uint32 offset, length, compLength, flags;/*, timeDate1, timeDate2;*/ + + nameLength = stream->readByte(); + name = new char[nameLength]; + stream->read(name, nameLength); + + // v2 - xor name + if (hdr._packageVersion == PACKAGE_VERSION) { + for (int k = 0; k < nameLength; k++) { + ((byte *)name)[k] ^= 'D'; + } + } + debugC(kWintermuteDebugFileAccess, "Package contains %s", name); + + Common::String upcName = name; + upcName.toUppercase(); + delete[] name; + name = NULL; + + offset = stream->readUint32LE(); + offset += absoluteOffset; + length = stream->readUint32LE(); + compLength = stream->readUint32LE(); + flags = stream->readUint32LE(); + + if (hdr._packageVersion == PACKAGE_VERSION) { + /* timeDate1 = */ stream->readUint32LE(); + /* timeDate2 = */ stream->readUint32LE(); + } + _filesIter = _files.find(upcName); + if (_filesIter == _files.end()) { + BaseFileEntry *fileEntry = new BaseFileEntry(); + fileEntry->_package = pkg; + fileEntry->_offset = offset; + fileEntry->_length = length; + fileEntry->_compressedLength = compLength; + fileEntry->_flags = flags; + + _files[upcName] = Common::ArchiveMemberPtr(fileEntry); + } else { + // current package has higher priority than the registered + // TODO: This cast might be a bit ugly. + BaseFileEntry *filePtr = (BaseFileEntry *) &*(_filesIter->_value); + if (pkg->_priority > filePtr->_package->_priority) { + filePtr->_package = pkg; + filePtr->_offset = offset; + filePtr->_length = length; + filePtr->_compressedLength = compLength; + filePtr->_flags = flags; + } + } + } + } + debugC(kWintermuteDebugFileAccess, " Registered %d files in %d package(s)", _files.size(), _packages.size()); + + delete stream; +} + +PackageSet::~PackageSet() { + for (Common::Array::iterator it = _packages.begin(); it != _packages.end(); ++it) { + delete *it; + } + _packages.clear(); +} + +bool PackageSet::hasFile(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return (it != _files.end()); +} + +int PackageSet::listMembers(Common::ArchiveMemberList &list) const { + Common::HashMap::const_iterator it = _files.begin(); + Common::HashMap::const_iterator end = _files.end(); + int count = 0; + for (; it != end; ++it) { + const Common::ArchiveMemberPtr ptr(it->_value); + list.push_back(ptr); + count++; + } + return count; +} + +const Common::ArchiveMemberPtr PackageSet::getMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + return Common::ArchiveMemberPtr(it->_value); +} + +Common::SeekableReadStream *PackageSet::createReadStreamForMember(const Common::String &name) const { + Common::String upcName = name; + upcName.toUppercase(); + Common::HashMap::const_iterator it; + it = _files.find(upcName.c_str()); + if (it != _files.end()) { + return it->_value->createReadStream(); + } + return NULL; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_package.h b/engines/wintermute/base/file/base_package.h index 23d7d7690f..2882eb03b7 100644 --- a/engines/wintermute/base/file/base_package.h +++ b/engines/wintermute/base/file/base_package.h @@ -1,90 +1,90 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_PACKAGE_H -#define WINTERMUTE_BASE_PACKAGE_H - -#include "common/archive.h" -#include "common/stream.h" -#include "common/fs.h" - -namespace Wintermute { -class BasePackage { -public: - Common::SeekableReadStream *getFilePointer(); - Common::FSNode _fsnode; - bool _boundToExe; - byte _priority; - Common::String _name; - int _cd; - BasePackage(); -}; - -class PackageSet : public Common::Archive { -public: - virtual ~PackageSet(); - - PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); - /** - * Check if a member with the given name is present in the Archive. - * Patterns are not allowed, as this is meant to be a quick File::exists() - * replacement. - */ - virtual bool hasFile(const Common::String &name) const; - - /** - * Add all members of the Archive to list. - * Must only append to list, and not remove elements from it. - * - * @return the number of names added to list - */ - virtual int listMembers(Common::ArchiveMemberList &list) const; - - /** - * Returns a ArchiveMember representation of the given file. - */ - virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; - - /** - * Create a stream bound to a member with the specified name in the - * archive. If no member with this name exists, 0 is returned. - * @return the newly created input stream - */ - virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; - - int getPriority() const { return _priority; } -private: - byte _priority; - Common::Array _packages; - Common::HashMap _files; - Common::HashMap::iterator _filesIter; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_PACKAGE_H +#define WINTERMUTE_BASE_PACKAGE_H + +#include "common/archive.h" +#include "common/stream.h" +#include "common/fs.h" + +namespace Wintermute { +class BasePackage { +public: + Common::SeekableReadStream *getFilePointer(); + Common::FSNode _fsnode; + bool _boundToExe; + byte _priority; + Common::String _name; + int _cd; + BasePackage(); +}; + +class PackageSet : public Common::Archive { +public: + virtual ~PackageSet(); + + PackageSet(Common::FSNode package, const Common::String &filename = "", bool searchSignature = false); + /** + * Check if a member with the given name is present in the Archive. + * Patterns are not allowed, as this is meant to be a quick File::exists() + * replacement. + */ + virtual bool hasFile(const Common::String &name) const; + + /** + * Add all members of the Archive to list. + * Must only append to list, and not remove elements from it. + * + * @return the number of names added to list + */ + virtual int listMembers(Common::ArchiveMemberList &list) const; + + /** + * Returns a ArchiveMember representation of the given file. + */ + virtual const Common::ArchiveMemberPtr getMember(const Common::String &name) const; + + /** + * Create a stream bound to a member with the specified name in the + * archive. If no member with this name exists, 0 is returned. + * @return the newly created input stream + */ + virtual Common::SeekableReadStream *createReadStreamForMember(const Common::String &name) const; + + int getPriority() const { return _priority; } +private: + byte _priority; + Common::Array _packages; + Common::HashMap _files; + Common::HashMap::iterator _filesIter; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_resources.cpp b/engines/wintermute/base/file/base_resources.cpp index a8bda164dc..0b32cb0c4f 100644 --- a/engines/wintermute/base/file/base_resources.cpp +++ b/engines/wintermute/base/file/base_resources.cpp @@ -1,2830 +1,2830 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_resources.h" -#include "common/str.h" -#include "common/memstream.h" - -namespace Wintermute { - -unsigned char invalid[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -} ; - -unsigned char invaliddebug[] = { - 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, - 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, - 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, - 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, - 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, - 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, - 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, - 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, - 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, - 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, - 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, - 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, - 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, - 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, - 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, - 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, - 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, - 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, - 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, - 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, - 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, - 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, - 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, - 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, - 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, - 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, - 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, - 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, - 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, - 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, - 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, - 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, - 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, - 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, - 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, - 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, - 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, - 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, - 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, - 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, - 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, - 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, - 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, - 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, - 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, - 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, - 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, - 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, - 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, - 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, - 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, - 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, - 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, - 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, - 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, - 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, - 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, - 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, - 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, - 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, - 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, - 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, - 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, - 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, - 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, - 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, - 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 -} ; - -unsigned char systemfont[] = { - 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, - 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, - 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, - 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, - 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, - 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, - 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, - 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, - 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, - 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, - 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 -} ; - -Common::SeekableReadStream *BaseResources::getFile(const Common::String &filename) { - if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { - return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { - return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); - } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { - return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); - } - return NULL; -} - -bool BaseResources::hasFile(const Common::String &filename) { - if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { - return true; - } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { - return true; - } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { - return true; - } - return false; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_resources.h" +#include "common/str.h" +#include "common/memstream.h" + +namespace Wintermute { + +unsigned char invalid[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x20, 0x4e, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 +} ; + +unsigned char invaliddebug[] = { + 0x42, 0x4d, 0x36, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x80, + 0x00, 0x00, 0x00, 0x80, 0x80, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x80, + 0x00, 0x00, 0xc0, 0xc0, 0xc0, 0x00, 0xc0, 0xdc, 0xc0, 0x00, 0xf0, 0xca, 0xa6, 0x00, 0x00, 0x20, + 0x40, 0x00, 0x00, 0x20, 0x60, 0x00, 0x00, 0x20, 0x80, 0x00, 0x00, 0x20, 0xa0, 0x00, 0x00, 0x20, + 0xc0, 0x00, 0x00, 0x20, 0xe0, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, + 0x40, 0x00, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, + 0xc0, 0x00, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x60, 0x20, 0x00, 0x00, 0x60, + 0x40, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x80, 0x00, 0x00, 0x60, 0xa0, 0x00, 0x00, 0x60, + 0xc0, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, + 0x40, 0x00, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, + 0xc0, 0x00, 0x00, 0x80, 0xe0, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa0, 0x20, 0x00, 0x00, 0xa0, + 0x40, 0x00, 0x00, 0xa0, 0x60, 0x00, 0x00, 0xa0, 0x80, 0x00, 0x00, 0xa0, 0xa0, 0x00, 0x00, 0xa0, + 0xc0, 0x00, 0x00, 0xa0, 0xe0, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, + 0x40, 0x00, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, + 0xc0, 0x00, 0x00, 0xc0, 0xe0, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe0, 0x20, 0x00, 0x00, 0xe0, + 0x40, 0x00, 0x00, 0xe0, 0x60, 0x00, 0x00, 0xe0, 0x80, 0x00, 0x00, 0xe0, 0xa0, 0x00, 0x00, 0xe0, + 0xc0, 0x00, 0x00, 0xe0, 0xe0, 0x00, 0x40, 0x00, 0x00, 0x00, 0x40, 0x00, 0x20, 0x00, 0x40, 0x00, + 0x40, 0x00, 0x40, 0x00, 0x60, 0x00, 0x40, 0x00, 0x80, 0x00, 0x40, 0x00, 0xa0, 0x00, 0x40, 0x00, + 0xc0, 0x00, 0x40, 0x00, 0xe0, 0x00, 0x40, 0x20, 0x00, 0x00, 0x40, 0x20, 0x20, 0x00, 0x40, 0x20, + 0x40, 0x00, 0x40, 0x20, 0x60, 0x00, 0x40, 0x20, 0x80, 0x00, 0x40, 0x20, 0xa0, 0x00, 0x40, 0x20, + 0xc0, 0x00, 0x40, 0x20, 0xe0, 0x00, 0x40, 0x40, 0x00, 0x00, 0x40, 0x40, 0x20, 0x00, 0x40, 0x40, + 0x40, 0x00, 0x40, 0x40, 0x60, 0x00, 0x40, 0x40, 0x80, 0x00, 0x40, 0x40, 0xa0, 0x00, 0x40, 0x40, + 0xc0, 0x00, 0x40, 0x40, 0xe0, 0x00, 0x40, 0x60, 0x00, 0x00, 0x40, 0x60, 0x20, 0x00, 0x40, 0x60, + 0x40, 0x00, 0x40, 0x60, 0x60, 0x00, 0x40, 0x60, 0x80, 0x00, 0x40, 0x60, 0xa0, 0x00, 0x40, 0x60, + 0xc0, 0x00, 0x40, 0x60, 0xe0, 0x00, 0x40, 0x80, 0x00, 0x00, 0x40, 0x80, 0x20, 0x00, 0x40, 0x80, + 0x40, 0x00, 0x40, 0x80, 0x60, 0x00, 0x40, 0x80, 0x80, 0x00, 0x40, 0x80, 0xa0, 0x00, 0x40, 0x80, + 0xc0, 0x00, 0x40, 0x80, 0xe0, 0x00, 0x40, 0xa0, 0x00, 0x00, 0x40, 0xa0, 0x20, 0x00, 0x40, 0xa0, + 0x40, 0x00, 0x40, 0xa0, 0x60, 0x00, 0x40, 0xa0, 0x80, 0x00, 0x40, 0xa0, 0xa0, 0x00, 0x40, 0xa0, + 0xc0, 0x00, 0x40, 0xa0, 0xe0, 0x00, 0x40, 0xc0, 0x00, 0x00, 0x40, 0xc0, 0x20, 0x00, 0x40, 0xc0, + 0x40, 0x00, 0x40, 0xc0, 0x60, 0x00, 0x40, 0xc0, 0x80, 0x00, 0x40, 0xc0, 0xa0, 0x00, 0x40, 0xc0, + 0xc0, 0x00, 0x40, 0xc0, 0xe0, 0x00, 0x40, 0xe0, 0x00, 0x00, 0x40, 0xe0, 0x20, 0x00, 0x40, 0xe0, + 0x40, 0x00, 0x40, 0xe0, 0x60, 0x00, 0x40, 0xe0, 0x80, 0x00, 0x40, 0xe0, 0xa0, 0x00, 0x40, 0xe0, + 0xc0, 0x00, 0x40, 0xe0, 0xe0, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x20, 0x00, 0x80, 0x00, + 0x40, 0x00, 0x80, 0x00, 0x60, 0x00, 0x80, 0x00, 0x80, 0x00, 0x80, 0x00, 0xa0, 0x00, 0x80, 0x00, + 0xc0, 0x00, 0x80, 0x00, 0xe0, 0x00, 0x80, 0x20, 0x00, 0x00, 0x80, 0x20, 0x20, 0x00, 0x80, 0x20, + 0x40, 0x00, 0x80, 0x20, 0x60, 0x00, 0x80, 0x20, 0x80, 0x00, 0x80, 0x20, 0xa0, 0x00, 0x80, 0x20, + 0xc0, 0x00, 0x80, 0x20, 0xe0, 0x00, 0x80, 0x40, 0x00, 0x00, 0x80, 0x40, 0x20, 0x00, 0x80, 0x40, + 0x40, 0x00, 0x80, 0x40, 0x60, 0x00, 0x80, 0x40, 0x80, 0x00, 0x80, 0x40, 0xa0, 0x00, 0x80, 0x40, + 0xc0, 0x00, 0x80, 0x40, 0xe0, 0x00, 0x80, 0x60, 0x00, 0x00, 0x80, 0x60, 0x20, 0x00, 0x80, 0x60, + 0x40, 0x00, 0x80, 0x60, 0x60, 0x00, 0x80, 0x60, 0x80, 0x00, 0x80, 0x60, 0xa0, 0x00, 0x80, 0x60, + 0xc0, 0x00, 0x80, 0x60, 0xe0, 0x00, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x20, 0x00, 0x80, 0x80, + 0x40, 0x00, 0x80, 0x80, 0x60, 0x00, 0x80, 0x80, 0x80, 0x00, 0x80, 0x80, 0xa0, 0x00, 0x80, 0x80, + 0xc0, 0x00, 0x80, 0x80, 0xe0, 0x00, 0x80, 0xa0, 0x00, 0x00, 0x80, 0xa0, 0x20, 0x00, 0x80, 0xa0, + 0x40, 0x00, 0x80, 0xa0, 0x60, 0x00, 0x80, 0xa0, 0x80, 0x00, 0x80, 0xa0, 0xa0, 0x00, 0x80, 0xa0, + 0xc0, 0x00, 0x80, 0xa0, 0xe0, 0x00, 0x80, 0xc0, 0x00, 0x00, 0x80, 0xc0, 0x20, 0x00, 0x80, 0xc0, + 0x40, 0x00, 0x80, 0xc0, 0x60, 0x00, 0x80, 0xc0, 0x80, 0x00, 0x80, 0xc0, 0xa0, 0x00, 0x80, 0xc0, + 0xc0, 0x00, 0x80, 0xc0, 0xe0, 0x00, 0x80, 0xe0, 0x00, 0x00, 0x80, 0xe0, 0x20, 0x00, 0x80, 0xe0, + 0x40, 0x00, 0x80, 0xe0, 0x60, 0x00, 0x80, 0xe0, 0x80, 0x00, 0x80, 0xe0, 0xa0, 0x00, 0x80, 0xe0, + 0xc0, 0x00, 0x80, 0xe0, 0xe0, 0x00, 0xc0, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x20, 0x00, 0xc0, 0x00, + 0x40, 0x00, 0xc0, 0x00, 0x60, 0x00, 0xc0, 0x00, 0x80, 0x00, 0xc0, 0x00, 0xa0, 0x00, 0xc0, 0x00, + 0xc0, 0x00, 0xc0, 0x00, 0xe0, 0x00, 0xc0, 0x20, 0x00, 0x00, 0xc0, 0x20, 0x20, 0x00, 0xc0, 0x20, + 0x40, 0x00, 0xc0, 0x20, 0x60, 0x00, 0xc0, 0x20, 0x80, 0x00, 0xc0, 0x20, 0xa0, 0x00, 0xc0, 0x20, + 0xc0, 0x00, 0xc0, 0x20, 0xe0, 0x00, 0xc0, 0x40, 0x00, 0x00, 0xc0, 0x40, 0x20, 0x00, 0xc0, 0x40, + 0x40, 0x00, 0xc0, 0x40, 0x60, 0x00, 0xc0, 0x40, 0x80, 0x00, 0xc0, 0x40, 0xa0, 0x00, 0xc0, 0x40, + 0xc0, 0x00, 0xc0, 0x40, 0xe0, 0x00, 0xc0, 0x60, 0x00, 0x00, 0xc0, 0x60, 0x20, 0x00, 0xc0, 0x60, + 0x40, 0x00, 0xc0, 0x60, 0x60, 0x00, 0xc0, 0x60, 0x80, 0x00, 0xc0, 0x60, 0xa0, 0x00, 0xc0, 0x60, + 0xc0, 0x00, 0xc0, 0x60, 0xe0, 0x00, 0xc0, 0x80, 0x00, 0x00, 0xc0, 0x80, 0x20, 0x00, 0xc0, 0x80, + 0x40, 0x00, 0xc0, 0x80, 0x60, 0x00, 0xc0, 0x80, 0x80, 0x00, 0xc0, 0x80, 0xa0, 0x00, 0xc0, 0x80, + 0xc0, 0x00, 0xc0, 0x80, 0xe0, 0x00, 0xc0, 0xa0, 0x00, 0x00, 0xc0, 0xa0, 0x20, 0x00, 0xc0, 0xa0, + 0x40, 0x00, 0xc0, 0xa0, 0x60, 0x00, 0xc0, 0xa0, 0x80, 0x00, 0xc0, 0xa0, 0xa0, 0x00, 0xc0, 0xa0, + 0xc0, 0x00, 0xc0, 0xa0, 0xe0, 0x00, 0xc0, 0xc0, 0x00, 0x00, 0xc0, 0xc0, 0x20, 0x00, 0xc0, 0xc0, + 0x40, 0x00, 0xc0, 0xc0, 0x60, 0x00, 0xc0, 0xc0, 0x80, 0x00, 0xc0, 0xc0, 0xa0, 0x00, 0xf0, 0xfb, + 0xff, 0x00, 0xa4, 0xa0, 0xa0, 0x00, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0xff, 0x00, 0x00, 0xff, + 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0xff, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0xff, + 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, + 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0xf9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, + 0xf9, 0xf9, 0xf9, 0xf9, 0xf9, 0xf9 +} ; + +unsigned char systemfont[] = { + 0x42, 0x4d, 0x36, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x04, 0x00, 0x00, 0x28, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x70, 0x0b, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x00, 0xff, 0x00, 0x80, 0x80, + 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x01, 0x02, 0x02, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x02, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x00, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x02, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x02, 0x01, 0x00, 0x02, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x00, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x00, + 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x01, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x00, + 0x00, 0x01, 0x02, 0x01, 0x02, 0x01, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x01, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x01, 0x02, 0x00, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x01, + 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x01, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x01, 0x00, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x01, 0x01, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, + 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x02, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, + 0x00, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x00, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x00, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x00, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x02, 0x00, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x00, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x00, 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, + 0x00, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x00, 0x01, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x00, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x02, + 0x02, 0x02, 0x02, 0x02, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 +} ; + +Common::SeekableReadStream *BaseResources::getFile(const Common::String &filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { + return new Common::MemoryReadStream(invalid, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { + return new Common::MemoryReadStream(invaliddebug, sizeof(invalid), DisposeAfterUse::NO); + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { + return new Common::MemoryReadStream(systemfont, sizeof(invalid), DisposeAfterUse::NO); + } + return NULL; +} + +bool BaseResources::hasFile(const Common::String &filename) { + if (scumm_stricmp(filename.c_str(), "invalid.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "invalid_debug.bmp") == 0) { + return true; + } else if (scumm_stricmp(filename.c_str(), "syste_font.bmp") == 0) { + return true; + } + return false; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_resources.h b/engines/wintermute/base/file/base_resources.h index 48a0f534d0..91c30bcfa7 100644 --- a/engines/wintermute/base/file/base_resources.h +++ b/engines/wintermute/base/file/base_resources.h @@ -1,45 +1,45 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_RESOURCES_H -#define WINTERMUTE_BASE_RESOURCES_H - -#include "common/stream.h" -#include "common/str.h" - -namespace Wintermute { - -class BaseResources { -public: - static Common::SeekableReadStream *getFile(const Common::String &filename); - static bool hasFile(const Common::String &filename); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RESOURCES_H +#define WINTERMUTE_BASE_RESOURCES_H + +#include "common/stream.h" +#include "common/str.h" + +namespace Wintermute { + +class BaseResources { +public: + static Common::SeekableReadStream *getFile(const Common::String &filename); + static bool hasFile(const Common::String &filename); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 515d8870d7..5bdab0853e 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -1,154 +1,154 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_persistence_manager.h" -#include "engines/wintermute/base/file/base_save_thumb_file.h" -#include "engines/wintermute/platform_osystem.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::BaseSaveThumbFile() { - _data = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSaveThumbFile::~BaseSaveThumbFile() { - close(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::open(const Common::String &filename) { - close(); - - if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { - return STATUS_FAILED; - } - - char *tempFilename = new char[strlen(filename.c_str()) - 8]; - strcpy(tempFilename, filename.c_str() + 9); - for (uint32 i = 0; i < strlen(tempFilename); i++) { - if (tempFilename[i] < '0' || tempFilename[i] > '9') { - tempFilename[i] = '\0'; - break; - } - } - - // get slot number from name - int slot = atoi(tempFilename); - delete[] tempFilename; - - BasePersistenceManager *pm = new BasePersistenceManager(); - Common::String slotFilename = pm->getFilenameForSlot(slot); - if (!pm) { - return STATUS_FAILED; - } - - if (DID_FAIL(pm->initLoad(slotFilename))) { - delete pm; - return STATUS_FAILED; - } - - bool res; - - if (pm->_thumbnailDataSize != 0) { - _data = new byte[pm->_thumbnailDataSize]; - memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); - _size = pm->_thumbnailDataSize; - res = STATUS_OK; - } else { - res = STATUS_FAILED; - } - delete pm; - - return res; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::close() { - delete[] _data; - _data = NULL; - - _pos = 0; - _size = 0; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::read(void *buffer, uint32 size) { - if (!_data || _pos + size > _size) { - return STATUS_FAILED; - } - - memcpy(buffer, (byte *)_data + _pos, size); - _pos += size; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSaveThumbFile::seek(uint32 pos, int whence) { - if (!_data) { - return STATUS_FAILED; - } - - uint32 newPos = 0; - - switch (whence) { - case SEEK_SET: - newPos = pos; - break; - case SEEK_END: - newPos = _size + pos; - break; - case SEEK_CUR: - newPos = _pos + pos; - break; - } - - if (newPos > _size) { - return STATUS_FAILED; - } else { - _pos = newPos; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_persistence_manager.h" +#include "engines/wintermute/base/file/base_save_thumb_file.h" +#include "engines/wintermute/platform_osystem.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbFile::BaseSaveThumbFile() { + _data = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSaveThumbFile::~BaseSaveThumbFile() { + close(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::open(const Common::String &filename) { + close(); + + if (scumm_strnicmp(filename.c_str(), "savegame:", 9) != 0) { + return STATUS_FAILED; + } + + char *tempFilename = new char[strlen(filename.c_str()) - 8]; + strcpy(tempFilename, filename.c_str() + 9); + for (uint32 i = 0; i < strlen(tempFilename); i++) { + if (tempFilename[i] < '0' || tempFilename[i] > '9') { + tempFilename[i] = '\0'; + break; + } + } + + // get slot number from name + int slot = atoi(tempFilename); + delete[] tempFilename; + + BasePersistenceManager *pm = new BasePersistenceManager(); + Common::String slotFilename = pm->getFilenameForSlot(slot); + if (!pm) { + return STATUS_FAILED; + } + + if (DID_FAIL(pm->initLoad(slotFilename))) { + delete pm; + return STATUS_FAILED; + } + + bool res; + + if (pm->_thumbnailDataSize != 0) { + _data = new byte[pm->_thumbnailDataSize]; + memcpy(_data, pm->_thumbnailData, pm->_thumbnailDataSize); + _size = pm->_thumbnailDataSize; + res = STATUS_OK; + } else { + res = STATUS_FAILED; + } + delete pm; + + return res; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::close() { + delete[] _data; + _data = NULL; + + _pos = 0; + _size = 0; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::read(void *buffer, uint32 size) { + if (!_data || _pos + size > _size) { + return STATUS_FAILED; + } + + memcpy(buffer, (byte *)_data + _pos, size); + _pos += size; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSaveThumbFile::seek(uint32 pos, int whence) { + if (!_data) { + return STATUS_FAILED; + } + + uint32 newPos = 0; + + switch (whence) { + case SEEK_SET: + newPos = pos; + break; + case SEEK_END: + newPos = _size + pos; + break; + case SEEK_CUR: + newPos = _pos + pos; + break; + } + + if (newPos > _size) { + return STATUS_FAILED; + } else { + _pos = newPos; + } + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/file/base_save_thumb_file.h b/engines/wintermute/base/file/base_save_thumb_file.h index 377e06f02c..3b217525fd 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.h +++ b/engines/wintermute/base/file/base_save_thumb_file.h @@ -1,52 +1,52 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SAVETHUMBFILE_H -#define WINTERMUTE_BASE_SAVETHUMBFILE_H - - -#include "engines/wintermute/base/file/base_file.h" - -namespace Wintermute { - -//TODO: Get rid of this -class BaseSaveThumbFile : public BaseFile { -public: - BaseSaveThumbFile(); - virtual ~BaseSaveThumbFile(); - virtual bool seek(uint32 pos, int whence = SEEK_SET); - virtual bool read(void *buffer, uint32 size); - virtual bool close(); - virtual bool open(const Common::String &filename); -private: - byte *_data; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SAVETHUMBFILE_H +#define WINTERMUTE_BASE_SAVETHUMBFILE_H + + +#include "engines/wintermute/base/file/base_file.h" + +namespace Wintermute { + +//TODO: Get rid of this +class BaseSaveThumbFile : public BaseFile { +public: + BaseSaveThumbFile(); + virtual ~BaseSaveThumbFile(); + virtual bool seek(uint32 pos, int whence = SEEK_SET); + virtual bool read(void *buffer, uint32 size); + virtual bool close(); + virtual bool open(const Common::String &filename); +private: + byte *_data; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/file/dcpackage.h b/engines/wintermute/base/file/dcpackage.h index 82f1998527..2234139408 100644 --- a/engines/wintermute/base/file/dcpackage.h +++ b/engines/wintermute/base/file/dcpackage.h @@ -1,80 +1,80 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef _DCPACKAGE_H_ -#define _DCPACKAGE_H_ - - -#define PACKAGE_MAGIC_1 0xDEC0ADDE -#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" -#define PACKAGE_VERSION 0x00000200 -#define PACKAGE_EXTENSION "dcp" - -#include "common/stream.h" - -namespace Wintermute { - -struct TPackageHeader { - uint32 _magic1; - uint32 _magic2; - uint32 _packageVersion; - uint32 _gameVersion; - byte _priority; - byte _cd; - bool _masterIndex; - uint32 _creationTime; - char _desc[100]; - uint32 _numDirs; - // base_package.cpp: - void readFromStream(Common::ReadStream *stream); -}; - -/* -v2: uint32 DirOffset - - -Dir: byte NameLength - char Name [NameLength] - byte CD; - uint32 NumEntries - - -Entry: byte NameLength - char Name [NameLength] - uint32 Offset - uint32 Length - uint32 CompLength - uint32 Flags -v2: uint32 TimeDate1 - uint32 TimeDate2 // not used - -*/ - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef _DCPACKAGE_H_ +#define _DCPACKAGE_H_ + + +#define PACKAGE_MAGIC_1 0xDEC0ADDE +#define PACKAGE_MAGIC_2 0x4B4E554A // "JUNK" +#define PACKAGE_VERSION 0x00000200 +#define PACKAGE_EXTENSION "dcp" + +#include "common/stream.h" + +namespace Wintermute { + +struct TPackageHeader { + uint32 _magic1; + uint32 _magic2; + uint32 _packageVersion; + uint32 _gameVersion; + byte _priority; + byte _cd; + bool _masterIndex; + uint32 _creationTime; + char _desc[100]; + uint32 _numDirs; + // base_package.cpp: + void readFromStream(Common::ReadStream *stream); +}; + +/* +v2: uint32 DirOffset + + +Dir: byte NameLength + char Name [NameLength] + byte CD; + uint32 NumEntries + + +Entry: byte NameLength + char Name [NameLength] + uint32 Offset + uint32 Length + uint32 CompLength + uint32 Flags +v2: uint32 TimeDate1 + uint32 TimeDate2 // not used + +*/ + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/font/base_font.cpp b/engines/wintermute/base/font/base_font.cpp index cb70c4add8..87dd3da5a3 100644 --- a/engines/wintermute/base/font/base_font.cpp +++ b/engines/wintermute/base/font/base_font.cpp @@ -1,140 +1,140 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/font/base_font.h" -#include "engines/wintermute/base/font/base_font_bitmap.h" -#include "engines/wintermute/base/font/base_font_truetype.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_file_manager.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFont, false) - -////////////////////////////////////////////////////////////////////// -BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { - -} - - -////////////////////////////////////////////////////////////////////// -BaseFont::~BaseFont() { -} - - -////////////////////////////////////////////////////////////////////// -void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { -} - - -////////////////////////////////////////////////////////////////////// -int BaseFont::getTextHeight(byte *text, int width) { - return 0; -} - - -////////////////////////////////////////////////////////////////////// -int BaseFont::getTextWidth(byte *text, int maxLength) { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFont::getLetterHeight() { - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFont::persist(BasePersistenceManager *persistMgr) { - - BaseObject::persist(persistMgr); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { - if (isTrueType(gameRef, filename)) { - BaseFontTT *font = new BaseFontTT(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } else { - BaseFontBitmap *font = new BaseFontBitmap(gameRef); - if (font) { - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - } - return font; - } -} - - -TOKEN_DEF_START -TOKEN_DEF(FONT) -TOKEN_DEF(TTFONT) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////////// -bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONT) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE_END - - - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - return false; - } - - byte *workBuffer = buffer; - - char *params; - BaseParser parser; - - bool ret = false; - if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { - ret = true; - } - - delete[] buffer; - return ret; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_file_manager.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFont, false) + +////////////////////////////////////////////////////////////////////// +BaseFont::BaseFont(BaseGame *inGame) : BaseObject(inGame) { + +} + + +////////////////////////////////////////////////////////////////////// +BaseFont::~BaseFont() { +} + + +////////////////////////////////////////////////////////////////////// +void BaseFont::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { +} + + +////////////////////////////////////////////////////////////////////// +int BaseFont::getTextHeight(byte *text, int width) { + return 0; +} + + +////////////////////////////////////////////////////////////////////// +int BaseFont::getTextWidth(byte *text, int maxLength) { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFont::getLetterHeight() { + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFont::persist(BasePersistenceManager *persistMgr) { + + BaseObject::persist(persistMgr); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +BaseFont *BaseFont::createFromFile(BaseGame *gameRef, const Common::String &filename) { + if (isTrueType(gameRef, filename)) { + BaseFontTT *font = new BaseFontTT(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } else { + BaseFontBitmap *font = new BaseFontBitmap(gameRef); + if (font) { + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + } + return font; + } +} + + +TOKEN_DEF_START +TOKEN_DEF(FONT) +TOKEN_DEF(TTFONT) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////////// +bool BaseFont::isTrueType(BaseGame *gameRef, const Common::String &filename) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONT) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE_END + + + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + return false; + } + + byte *workBuffer = buffer; + + char *params; + BaseParser parser; + + bool ret = false; + if (parser.getCommand((char **)&workBuffer, commands, (char **)¶ms) == TOKEN_TTFONT) { + ret = true; + } + + delete[] buffer; + return ret; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font.h b/engines/wintermute/base/font/base_font.h index acd424ac06..0abe62ab98 100644 --- a/engines/wintermute/base/font/base_font.h +++ b/engines/wintermute/base/font/base_font.h @@ -1,61 +1,61 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FONT_H -#define WINTERMUTE_BASE_FONT_H - -#include "engines/wintermute/base/base_object.h" - -#define NUM_CHARACTERS 256 - -namespace Wintermute { - -class BaseFont: public BaseObject { -public: - DECLARE_PERSISTENT(BaseFont, BaseObject) - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - virtual void initLoop() {} - virtual void afterLoad() {} - BaseFont(BaseGame *inGame); - virtual ~BaseFont(); - - static BaseFont *createFromFile(BaseGame *game, const Common::String &filename); - -private: - //bool loadBuffer(byte * Buffer); - //bool loadFile(const char* Filename); - static bool isTrueType(BaseGame *game, const Common::String &filename); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONT_H +#define WINTERMUTE_BASE_FONT_H + +#include "engines/wintermute/base/base_object.h" + +#define NUM_CHARACTERS 256 + +namespace Wintermute { + +class BaseFont: public BaseObject { +public: + DECLARE_PERSISTENT(BaseFont, BaseObject) + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + virtual void initLoop() {} + virtual void afterLoad() {} + BaseFont(BaseGame *inGame); + virtual ~BaseFont(); + + static BaseFont *createFromFile(BaseGame *game, const Common::String &filename); + +private: + //bool loadBuffer(byte * Buffer); + //bool loadFile(const char* Filename); + static bool isTrueType(BaseGame *game, const Common::String &filename); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index 062f4801cf..fced08c7e2 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -1,589 +1,589 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/font/base_font_bitmap.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_frame.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/base/base_frame.h" -#include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFontBitmap, false) - -////////////////////////////////////////////////////////////////////// -BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { - _subframe = NULL; - _sprite = NULL; - _widthsFrame = 0; - memset(_widths, 0, NUM_CHARACTERS); - _tileWidth = _tileHeight = _numColumns = 0; - _fontextFix = false; - _freezable = false; - _wholeCell = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseFontBitmap::~BaseFontBitmap() { - delete _subframe; - delete _sprite; - _subframe = NULL; - _sprite = NULL; -} - - -////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); -} - - -////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getTextHeight(byte *text, int width) { - return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); -} - - -////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((char *)text); - } - - if (maxLength >= 0 && str.size() > (uint32)maxLength) { - str = Common::String(str.c_str(), (uint32)maxLength); - } - //str.substr(0, maxLength); // TODO: Remove - - int textWidth = 0; - for (int i = 0; (uint32)i < str.size(); i++) { - textWidth += getCharWidth((byte)str[i]); - } - - return textWidth; -} - - -////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { - if (maxLength == 0) { - return 0; - } - - if (text == NULL || text[0] == '\0') { - return _tileHeight; - } - - AnsiString str; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); - str = StringUtil::wideToAnsi(wstr); - } else { - str = AnsiString((const char *)text); - } - if (str.empty()) { - return 0; - } - - int lineLength = 0; - int realLength = 0; - int numLines = 0; - - int i; - - int index = -1; - int start = 0; - int end = 0; - int last_end = 0; - - bool done = false; - bool newLine = false; - bool longLine = false; - - if (draw) { - _gameRef->_renderer->startSpriteBatch(); - } - - while (!done) { - if (maxHeight > 0 && (numLines + 1)*_tileHeight > maxHeight) { - if (draw) { - _gameRef->_renderer->endSpriteBatch(); - } - return numLines * _tileHeight; - } - - index++; - - if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { - end = index - 1; - realLength = lineLength; - } - - if (str[index] == '\n') { - end = index - 1; - realLength = lineLength; - newLine = true; - } - - if (lineLength + getCharWidth(str[index]) > width && last_end == end) { - end = index - 1; - realLength = lineLength; - newLine = true; - longLine = true; - } - - if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { - done = true; - if (!newLine) { - end = index; - lineLength += getCharWidth(str[index]); - realLength = lineLength; - } - } else { - lineLength += getCharWidth(str[index]); - } - - if ((lineLength > width) || done || newLine) { - if (end < 0) { - done = true; - } - int startX; - switch (align) { - case TAL_CENTER: - startX = x + (width - realLength) / 2; - break; - case TAL_RIGHT: - startX = x + width - realLength; - break; - case TAL_LEFT: - startX = x; - break; - default: - error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); - break; - } - for (i = start; i < end + 1; i++) { - if (draw) { - drawChar(str[i], startX, y); - } - startX += getCharWidth(str[i]); - } - y += _tileHeight; - last_end = end; - if (longLine) { - end--; - } - start = end + 2; - index = end + 1; - lineLength = 0; - newLine = false; - longLine = false; - numLines++; - } - } - - if (draw) { - _gameRef->_renderer->endSpriteBatch(); - } - - return numLines * _tileHeight; -} - - -////////////////////////////////////////////////////////////////////// -void BaseFontBitmap::drawChar(byte c, int x, int y) { - if (_fontextFix) { - c--; - } - - int row, col; - - row = c / _numColumns; - col = c % _numColumns; - - Rect32 rect; - /* l t r b */ - int tileWidth; - if (_wholeCell) { - tileWidth = _tileWidth; - } else { - tileWidth = _widths[c]; - } - - BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); - bool handled = false; - if (_sprite) { - _sprite->getCurrentFrame(); - if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < (int32)_sprite->_frames.size() && _sprite->_frames[_sprite->_currentFrame]) { - if (_sprite->_frames[_sprite->_currentFrame]->_subframes.size() > 0) { - _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); - } - handled = true; - } - } - if (!handled && _subframe) { - _subframe->_surface->displayTrans(x, y, rect); - } -} - - -////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadFile(const Common::String &filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); - return STATUS_FAILED; - } - - bool ret; - - setFilename(filename.c_str()); - - if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); - } - - delete[] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(FONTEXT_FIX) -TOKEN_DEF(FONT) -TOKEN_DEF(IMAGE) -TOKEN_DEF(TRANSPARENT) -TOKEN_DEF(COLUMNS) -TOKEN_DEF(TILE_WIDTH) -TOKEN_DEF(TILE_HEIGHT) -TOKEN_DEF(DEFAULT_WIDTH) -TOKEN_DEF(WIDTHS) -TOKEN_DEF(AUTO_WIDTH) -TOKEN_DEF(SPACE_WIDTH) -TOKEN_DEF(EXPAND_WIDTH) -TOKEN_DEF(EDITOR_PROPERTY) -TOKEN_DEF(SPRITE) -TOKEN_DEF(WIDTHS_FRAME) -TOKEN_DEF(PAINT_WHOLE_CELL) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(FONTEXT_FIX) - TOKEN_TABLE(FONT) - TOKEN_TABLE(IMAGE) - TOKEN_TABLE(TRANSPARENT) - TOKEN_TABLE(COLUMNS) - TOKEN_TABLE(TILE_WIDTH) - TOKEN_TABLE(TILE_HEIGHT) - TOKEN_TABLE(DEFAULT_WIDTH) - TOKEN_TABLE(WIDTHS) - TOKEN_TABLE(AUTO_WIDTH) - TOKEN_TABLE(SPACE_WIDTH) - TOKEN_TABLE(EXPAND_WIDTH) - TOKEN_TABLE(EDITOR_PROPERTY) - TOKEN_TABLE(SPRITE) - TOKEN_TABLE(WIDTHS_FRAME) - TOKEN_TABLE(PAINT_WHOLE_CELL) - TOKEN_TABLE_END - - char *params; - int cmd; - BaseParser parser; - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { - _gameRef->LOG(0, "'FONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - int widths[300]; - int num = 0, defaultWidth = 8; - int lastWidth = 0; - int i; - int r = 255, g = 255, b = 255; - bool custoTrans = false; - char *surfaceFile = NULL; - char *spriteFile = NULL; - - bool autoWidth = false; - int spaceWidth = 0; - int expandWidth = 0; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - - switch (cmd) { - case TOKEN_IMAGE: - surfaceFile = (char *)params; - break; - - case TOKEN_SPRITE: - spriteFile = (char *)params; - break; - - case TOKEN_TRANSPARENT: - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - custoTrans = true; - break; - - case TOKEN_WIDTHS: - parser.scanStr(params, "%D", widths, &num); - for (i = 0; lastWidth < NUM_CHARACTERS && num > 0; lastWidth++, num--, i++) { - _widths[lastWidth] = (byte)widths[i]; - } - break; - - case TOKEN_DEFAULT_WIDTH: - parser.scanStr(params, "%d", &defaultWidth); - break; - - case TOKEN_WIDTHS_FRAME: - parser.scanStr(params, "%d", &_widthsFrame); - break; - - case TOKEN_COLUMNS: - parser.scanStr(params, "%d", &_numColumns); - break; - - case TOKEN_TILE_WIDTH: - parser.scanStr(params, "%d", &_tileWidth); - break; - - case TOKEN_TILE_HEIGHT: - parser.scanStr(params, "%d", &_tileHeight); - break; - - case TOKEN_AUTO_WIDTH: - parser.scanStr(params, "%b", &autoWidth); - break; - - case TOKEN_FONTEXT_FIX: - parser.scanStr(params, "%b", &_fontextFix); - break; - - case TOKEN_PAINT_WHOLE_CELL: - parser.scanStr(params, "%b", &_wholeCell); - break; - - case TOKEN_SPACE_WIDTH: - parser.scanStr(params, "%d", &spaceWidth); - break; - - case TOKEN_EXPAND_WIDTH: - parser.scanStr(params, "%d", &expandWidth); - break; - - case TOKEN_EDITOR_PROPERTY: - parseEditorProperty((byte *)params, false); - break; - } - - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in FONT definition"); - return STATUS_FAILED; - } - - if (spriteFile != NULL) { - delete _sprite; - _sprite = new BaseSprite(_gameRef, this); - if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { - delete _sprite; - _sprite = NULL; - } - } - - if (surfaceFile != NULL && !_sprite) { - _subframe = new BaseSubFrame(_gameRef); - if (custoTrans) { - _subframe->setSurface(surfaceFile, false, r, g, b); - } else { - _subframe->setSurface(surfaceFile); - } - } - - - if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { - _gameRef->LOG(0, "Incomplete font definition"); - return STATUS_FAILED; - } - - if (autoWidth) { - // calculate characters width - getWidths(); - - // do we need to modify widths? - if (expandWidth != 0) { - for (i = 0; i < NUM_CHARACTERS; i++) { - int newWidth = (int)_widths[i] + expandWidth; - if (newWidth < 0) { - newWidth = 0; - } - - _widths[i] = (byte)newWidth; - } - } - - // handle space character - uint32 spaceChar = ' '; - if (_fontextFix) { - spaceChar--; - } - - if (spaceWidth != 0) { - _widths[spaceChar] = spaceWidth; - } else { - if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { - _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; - } - } - } else { - for (i = lastWidth; i < NUM_CHARACTERS; i++) { - _widths[i] = defaultWidth; - } - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { - - BaseFont::persist(persistMgr); - persistMgr->transfer(TMEMBER(_numColumns)); - - persistMgr->transfer(TMEMBER(_subframe)); - persistMgr->transfer(TMEMBER(_tileHeight)); - persistMgr->transfer(TMEMBER(_tileWidth)); - persistMgr->transfer(TMEMBER(_sprite)); - persistMgr->transfer(TMEMBER(_widthsFrame)); - - if (persistMgr->getIsSaving()) { - persistMgr->putBytes(_widths, sizeof(_widths)); - } else { - persistMgr->getBytes(_widths, sizeof(_widths)); - } - - - persistMgr->transfer(TMEMBER(_fontextFix)); - persistMgr->transfer(TMEMBER(_wholeCell)); - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getCharWidth(byte index) { - if (_fontextFix) { - index--; - } - return _widths[index]; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontBitmap::getWidths() { - BaseSurface *surf = NULL; - - if (_sprite) { - if (_widthsFrame >= 0 && _widthsFrame < (int32)_sprite->_frames.size()) { - if (_sprite->_frames[_widthsFrame] && (int32)_sprite->_frames[_widthsFrame]->_subframes.size() > 0) { - surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; - } - } - } - if (surf == NULL && _subframe) { - surf = _subframe->_surface; - } - if (!surf || DID_FAIL(surf->startPixelOp())) { - return STATUS_FAILED; - } - - - for (int i = 0; i < NUM_CHARACTERS; i++) { - int xxx = (i % _numColumns) * _tileWidth; - int yyy = (i / _numColumns) * _tileHeight; - - - int minCol = -1; - for (int row = 0; row < _tileHeight; row++) { - for (int col = _tileWidth - 1; col >= minCol + 1; col--) { - if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) { - continue; - } - if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { - //min_col = col; - minCol = MAX(col, minCol); - break; - } - } - if (minCol == _tileWidth - 1) { - break; - } - } - - _widths[i] = minCol + 1; - } - surf->endPixelOp(); - /* - _gameRef->LOG(0, "----- %s ------", _filename); - for(int j=0; j<16; j++) - { - _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int BaseFontBitmap::getLetterHeight() { - return _tileHeight; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/font/base_font_bitmap.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_frame.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFontBitmap, false) + +////////////////////////////////////////////////////////////////////// +BaseFontBitmap::BaseFontBitmap(BaseGame *inGame) : BaseFont(inGame) { + _subframe = NULL; + _sprite = NULL; + _widthsFrame = 0; + memset(_widths, 0, NUM_CHARACTERS); + _tileWidth = _tileHeight = _numColumns = 0; + _fontextFix = false; + _freezable = false; + _wholeCell = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseFontBitmap::~BaseFontBitmap() { + delete _subframe; + delete _sprite; + _subframe = NULL; + _sprite = NULL; +} + + +////////////////////////////////////////////////////////////////////// +void BaseFontBitmap::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + textHeightDraw(text, x, y, width, align, true, maxHeight, maxLength); +} + + +////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getTextHeight(byte *text, int width) { + return textHeightDraw(text, 0, 0, width, TAL_LEFT, false); +} + + +////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getTextWidth(byte *text, int maxLength) { + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((char *)text); + } + + if (maxLength >= 0 && str.size() > (uint32)maxLength) { + str = Common::String(str.c_str(), (uint32)maxLength); + } + //str.substr(0, maxLength); // TODO: Remove + + int textWidth = 0; + for (int i = 0; (uint32)i < str.size(); i++) { + textWidth += getCharWidth((byte)str[i]); + } + + return textWidth; +} + + +////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int maxHeight, int maxLength) { + if (maxLength == 0) { + return 0; + } + + if (text == NULL || text[0] == '\0') { + return _tileHeight; + } + + AnsiString str; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(Utf8String((const char *)text)); + str = StringUtil::wideToAnsi(wstr); + } else { + str = AnsiString((const char *)text); + } + if (str.empty()) { + return 0; + } + + int lineLength = 0; + int realLength = 0; + int numLines = 0; + + int i; + + int index = -1; + int start = 0; + int end = 0; + int last_end = 0; + + bool done = false; + bool newLine = false; + bool longLine = false; + + if (draw) { + _gameRef->_renderer->startSpriteBatch(); + } + + while (!done) { + if (maxHeight > 0 && (numLines + 1)*_tileHeight > maxHeight) { + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } + return numLines * _tileHeight; + } + + index++; + + if (str[index] == ' ' && (maxHeight < 0 || maxHeight / _tileHeight > 1)) { + end = index - 1; + realLength = lineLength; + } + + if (str[index] == '\n') { + end = index - 1; + realLength = lineLength; + newLine = true; + } + + if (lineLength + getCharWidth(str[index]) > width && last_end == end) { + end = index - 1; + realLength = lineLength; + newLine = true; + longLine = true; + } + + if ((int)str.size() == (index + 1) || (maxLength >= 0 && index == maxLength - 1)) { + done = true; + if (!newLine) { + end = index; + lineLength += getCharWidth(str[index]); + realLength = lineLength; + } + } else { + lineLength += getCharWidth(str[index]); + } + + if ((lineLength > width) || done || newLine) { + if (end < 0) { + done = true; + } + int startX; + switch (align) { + case TAL_CENTER: + startX = x + (width - realLength) / 2; + break; + case TAL_RIGHT: + startX = x + width - realLength; + break; + case TAL_LEFT: + startX = x; + break; + default: + error("BaseFontBitmap::TextHeightDraw - Unhandled enum"); + break; + } + for (i = start; i < end + 1; i++) { + if (draw) { + drawChar(str[i], startX, y); + } + startX += getCharWidth(str[i]); + } + y += _tileHeight; + last_end = end; + if (longLine) { + end--; + } + start = end + 2; + index = end + 1; + lineLength = 0; + newLine = false; + longLine = false; + numLines++; + } + } + + if (draw) { + _gameRef->_renderer->endSpriteBatch(); + } + + return numLines * _tileHeight; +} + + +////////////////////////////////////////////////////////////////////// +void BaseFontBitmap::drawChar(byte c, int x, int y) { + if (_fontextFix) { + c--; + } + + int row, col; + + row = c / _numColumns; + col = c % _numColumns; + + Rect32 rect; + /* l t r b */ + int tileWidth; + if (_wholeCell) { + tileWidth = _tileWidth; + } else { + tileWidth = _widths[c]; + } + + BasePlatform::setRect(&rect, col * _tileWidth, row * _tileHeight, col * _tileWidth + tileWidth, (row + 1)*_tileHeight); + bool handled = false; + if (_sprite) { + _sprite->getCurrentFrame(); + if (_sprite->_currentFrame >= 0 && _sprite->_currentFrame < (int32)_sprite->_frames.size() && _sprite->_frames[_sprite->_currentFrame]) { + if (_sprite->_frames[_sprite->_currentFrame]->_subframes.size() > 0) { + _sprite->_frames[_sprite->_currentFrame]->_subframes[0]->_surface->displayTrans(x, y, rect); + } + handled = true; + } + } + if (!handled && _subframe) { + _subframe->_surface->displayTrans(x, y, rect); + } +} + + +////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::loadFile(const Common::String &filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseFontBitmap::LoadFile failed for file '%s'", filename.c_str()); + return STATUS_FAILED; + } + + bool ret; + + setFilename(filename.c_str()); + + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing FONT file '%s'", filename.c_str()); + } + + delete[] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(FONTEXT_FIX) +TOKEN_DEF(FONT) +TOKEN_DEF(IMAGE) +TOKEN_DEF(TRANSPARENT) +TOKEN_DEF(COLUMNS) +TOKEN_DEF(TILE_WIDTH) +TOKEN_DEF(TILE_HEIGHT) +TOKEN_DEF(DEFAULT_WIDTH) +TOKEN_DEF(WIDTHS) +TOKEN_DEF(AUTO_WIDTH) +TOKEN_DEF(SPACE_WIDTH) +TOKEN_DEF(EXPAND_WIDTH) +TOKEN_DEF(EDITOR_PROPERTY) +TOKEN_DEF(SPRITE) +TOKEN_DEF(WIDTHS_FRAME) +TOKEN_DEF(PAINT_WHOLE_CELL) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(FONTEXT_FIX) + TOKEN_TABLE(FONT) + TOKEN_TABLE(IMAGE) + TOKEN_TABLE(TRANSPARENT) + TOKEN_TABLE(COLUMNS) + TOKEN_TABLE(TILE_WIDTH) + TOKEN_TABLE(TILE_HEIGHT) + TOKEN_TABLE(DEFAULT_WIDTH) + TOKEN_TABLE(WIDTHS) + TOKEN_TABLE(AUTO_WIDTH) + TOKEN_TABLE(SPACE_WIDTH) + TOKEN_TABLE(EXPAND_WIDTH) + TOKEN_TABLE(EDITOR_PROPERTY) + TOKEN_TABLE(SPRITE) + TOKEN_TABLE(WIDTHS_FRAME) + TOKEN_TABLE(PAINT_WHOLE_CELL) + TOKEN_TABLE_END + + char *params; + int cmd; + BaseParser parser; + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_FONT) { + _gameRef->LOG(0, "'FONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + int widths[300]; + int num = 0, defaultWidth = 8; + int lastWidth = 0; + int i; + int r = 255, g = 255, b = 255; + bool custoTrans = false; + char *surfaceFile = NULL; + char *spriteFile = NULL; + + bool autoWidth = false; + int spaceWidth = 0; + int expandWidth = 0; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + + switch (cmd) { + case TOKEN_IMAGE: + surfaceFile = (char *)params; + break; + + case TOKEN_SPRITE: + spriteFile = (char *)params; + break; + + case TOKEN_TRANSPARENT: + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + custoTrans = true; + break; + + case TOKEN_WIDTHS: + parser.scanStr(params, "%D", widths, &num); + for (i = 0; lastWidth < NUM_CHARACTERS && num > 0; lastWidth++, num--, i++) { + _widths[lastWidth] = (byte)widths[i]; + } + break; + + case TOKEN_DEFAULT_WIDTH: + parser.scanStr(params, "%d", &defaultWidth); + break; + + case TOKEN_WIDTHS_FRAME: + parser.scanStr(params, "%d", &_widthsFrame); + break; + + case TOKEN_COLUMNS: + parser.scanStr(params, "%d", &_numColumns); + break; + + case TOKEN_TILE_WIDTH: + parser.scanStr(params, "%d", &_tileWidth); + break; + + case TOKEN_TILE_HEIGHT: + parser.scanStr(params, "%d", &_tileHeight); + break; + + case TOKEN_AUTO_WIDTH: + parser.scanStr(params, "%b", &autoWidth); + break; + + case TOKEN_FONTEXT_FIX: + parser.scanStr(params, "%b", &_fontextFix); + break; + + case TOKEN_PAINT_WHOLE_CELL: + parser.scanStr(params, "%b", &_wholeCell); + break; + + case TOKEN_SPACE_WIDTH: + parser.scanStr(params, "%d", &spaceWidth); + break; + + case TOKEN_EXPAND_WIDTH: + parser.scanStr(params, "%d", &expandWidth); + break; + + case TOKEN_EDITOR_PROPERTY: + parseEditorProperty((byte *)params, false); + break; + } + + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in FONT definition"); + return STATUS_FAILED; + } + + if (spriteFile != NULL) { + delete _sprite; + _sprite = new BaseSprite(_gameRef, this); + if (!_sprite || DID_FAIL(_sprite->loadFile(spriteFile))) { + delete _sprite; + _sprite = NULL; + } + } + + if (surfaceFile != NULL && !_sprite) { + _subframe = new BaseSubFrame(_gameRef); + if (custoTrans) { + _subframe->setSurface(surfaceFile, false, r, g, b); + } else { + _subframe->setSurface(surfaceFile); + } + } + + + if (((_subframe == NULL || _subframe->_surface == NULL) && _sprite == NULL) || _numColumns == 0 || _tileWidth == 0 || _tileHeight == 0) { + _gameRef->LOG(0, "Incomplete font definition"); + return STATUS_FAILED; + } + + if (autoWidth) { + // calculate characters width + getWidths(); + + // do we need to modify widths? + if (expandWidth != 0) { + for (i = 0; i < NUM_CHARACTERS; i++) { + int newWidth = (int)_widths[i] + expandWidth; + if (newWidth < 0) { + newWidth = 0; + } + + _widths[i] = (byte)newWidth; + } + } + + // handle space character + uint32 spaceChar = ' '; + if (_fontextFix) { + spaceChar--; + } + + if (spaceWidth != 0) { + _widths[spaceChar] = spaceWidth; + } else { + if (_widths[spaceChar] == expandWidth || _widths[spaceChar] == 0) { + _widths[spaceChar] = (_widths['m'] + _widths['i']) / 2; + } + } + } else { + for (i = lastWidth; i < NUM_CHARACTERS; i++) { + _widths[i] = defaultWidth; + } + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::persist(BasePersistenceManager *persistMgr) { + + BaseFont::persist(persistMgr); + persistMgr->transfer(TMEMBER(_numColumns)); + + persistMgr->transfer(TMEMBER(_subframe)); + persistMgr->transfer(TMEMBER(_tileHeight)); + persistMgr->transfer(TMEMBER(_tileWidth)); + persistMgr->transfer(TMEMBER(_sprite)); + persistMgr->transfer(TMEMBER(_widthsFrame)); + + if (persistMgr->getIsSaving()) { + persistMgr->putBytes(_widths, sizeof(_widths)); + } else { + persistMgr->getBytes(_widths, sizeof(_widths)); + } + + + persistMgr->transfer(TMEMBER(_fontextFix)); + persistMgr->transfer(TMEMBER(_wholeCell)); + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getCharWidth(byte index) { + if (_fontextFix) { + index--; + } + return _widths[index]; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontBitmap::getWidths() { + BaseSurface *surf = NULL; + + if (_sprite) { + if (_widthsFrame >= 0 && _widthsFrame < (int32)_sprite->_frames.size()) { + if (_sprite->_frames[_widthsFrame] && (int32)_sprite->_frames[_widthsFrame]->_subframes.size() > 0) { + surf = _sprite->_frames[_widthsFrame]->_subframes[0]->_surface; + } + } + } + if (surf == NULL && _subframe) { + surf = _subframe->_surface; + } + if (!surf || DID_FAIL(surf->startPixelOp())) { + return STATUS_FAILED; + } + + + for (int i = 0; i < NUM_CHARACTERS; i++) { + int xxx = (i % _numColumns) * _tileWidth; + int yyy = (i / _numColumns) * _tileHeight; + + + int minCol = -1; + for (int row = 0; row < _tileHeight; row++) { + for (int col = _tileWidth - 1; col >= minCol + 1; col--) { + if (xxx + col < 0 || xxx + col >= surf->getWidth() || yyy + row < 0 || yyy + row >= surf->getHeight()) { + continue; + } + if (!surf->isTransparentAtLite(xxx + col, yyy + row)) { + //min_col = col; + minCol = MAX(col, minCol); + break; + } + } + if (minCol == _tileWidth - 1) { + break; + } + } + + _widths[i] = minCol + 1; + } + surf->endPixelOp(); + /* + _gameRef->LOG(0, "----- %s ------", _filename); + for(int j=0; j<16; j++) + { + _gameRef->LOG(0, "%02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d %02d", _widths[j*16+0], _widths[j*16+1], _widths[j*16+2], _widths[j*16+3], _widths[j*16+4], _widths[j*16+5], _widths[j*16+6], _widths[j*16+7], _widths[j*16+8], _widths[j*16+9], _widths[j*16+10], _widths[j*16+11], _widths[j*16+12], _widths[j*16+13], _widths[j*16+14], _widths[j*16+15]); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int BaseFontBitmap::getLetterHeight() { + return _tileHeight; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_bitmap.h b/engines/wintermute/base/font/base_font_bitmap.h index 14a6e1cc87..2f3a69d097 100644 --- a/engines/wintermute/base/font/base_font_bitmap.h +++ b/engines/wintermute/base/font/base_font_bitmap.h @@ -1,71 +1,71 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FONTBITMAP_H -#define WINTERMUTE_BASE_FONTBITMAP_H - - -#include "engines/wintermute/base/font/base_font.h" - -namespace Wintermute { -class BaseSubFrame; -class BaseFontBitmap : public BaseFont { -public: - DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) - bool loadBuffer(byte *Buffer); - bool loadFile(const Common::String &filename); - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - BaseFontBitmap(BaseGame *inGame); - virtual ~BaseFontBitmap(); - -private: - bool getWidths(); - BaseSprite *_sprite; - int _widthsFrame; - bool _fontextFix; - int _numColumns; - int _tileHeight; - int _tileWidth; - byte _widths[NUM_CHARACTERS]; - BaseSubFrame *_subframe; - bool _wholeCell; - - int getCharWidth(byte index); - void drawChar(byte c, int x, int y); - - int textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONTBITMAP_H +#define WINTERMUTE_BASE_FONTBITMAP_H + + +#include "engines/wintermute/base/font/base_font.h" + +namespace Wintermute { +class BaseSubFrame; +class BaseFontBitmap : public BaseFont { +public: + DECLARE_PERSISTENT(BaseFontBitmap, BaseFont) + bool loadBuffer(byte *Buffer); + bool loadFile(const Common::String &filename); + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + BaseFontBitmap(BaseGame *inGame); + virtual ~BaseFontBitmap(); + +private: + bool getWidths(); + BaseSprite *_sprite; + int _widthsFrame; + bool _fontextFix; + int _numColumns; + int _tileHeight; + int _tileWidth; + byte _widths[NUM_CHARACTERS]; + BaseSubFrame *_subframe; + bool _wholeCell; + + int getCharWidth(byte index); + void drawChar(byte c, int x, int y); + + int textHeightDraw(const byte *text, int x, int y, int width, TTextAlign align, bool draw, int max_height = -1, int maxLength = -1); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index 298417ec32..d26fa1d593 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -1,142 +1,142 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/font/base_font_storage.h" -#include "engines/wintermute/base/font/base_font.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(BaseFontStorage, true) - -////////////////////////////////////////////////////////////////////////// -BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { -} - -////////////////////////////////////////////////////////////////////////// -BaseFontStorage::~BaseFontStorage() { - cleanup(true); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::cleanup(bool warn) { - for (uint32 i = 0; i < _fonts.size(); i++) { - if (warn) { - _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); - } - delete _fonts[i]; - } - _fonts.clear(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::initLoop() { - for (uint32 i = 0; i < _fonts.size(); i++) { - _fonts[i]->initLoop(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -BaseFont *BaseFontStorage::addFont(const Common::String &filename) { - if (!filename.size()) { - return NULL; - } - - for (uint32 i = 0; i < _fonts.size(); i++) { - if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { - _fonts[i]->_refCount++; - return _fonts[i]; - } - } - - /* - BaseFont* font = new BaseFont(_gameRef); - if (!font) return NULL; - - if (DID_FAIL(font->loadFile(filename))) { - delete font; - return NULL; - } - else { - font->_refCount = 1; - _fonts.add(font); - return font; - } - */ - BaseFont *font = BaseFont::createFromFile(_gameRef, filename); - if (font) { - font->_refCount = 1; - _fonts.add(font); - } - return font; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::removeFont(BaseFont *font) { - if (!font) { - return STATUS_FAILED; - } - - for (uint32 i = 0; i < _fonts.size(); i++) { - if (_fonts[i] == font) { - _fonts[i]->_refCount--; - if (_fonts[i]->_refCount <= 0) { - delete _fonts[i]; - _fonts.remove_at(i); - } - break; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { - - if (!persistMgr->getIsSaving()) { - cleanup(false); - } - - persistMgr->transfer(TMEMBER(_gameRef)); - _fonts.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(BaseFontStorage, true) + +////////////////////////////////////////////////////////////////////////// +BaseFontStorage::BaseFontStorage(BaseGame *inGame) : BaseClass(inGame) { +} + +////////////////////////////////////////////////////////////////////////// +BaseFontStorage::~BaseFontStorage() { + cleanup(true); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::cleanup(bool warn) { + for (uint32 i = 0; i < _fonts.size(); i++) { + if (warn) { + _gameRef->LOG(0, "Removing orphan font '%s'", _fonts[i]->getFilename()); + } + delete _fonts[i]; + } + _fonts.clear(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::initLoop() { + for (uint32 i = 0; i < _fonts.size(); i++) { + _fonts[i]->initLoop(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +BaseFont *BaseFontStorage::addFont(const Common::String &filename) { + if (!filename.size()) { + return NULL; + } + + for (uint32 i = 0; i < _fonts.size(); i++) { + if (scumm_stricmp(_fonts[i]->getFilename(), filename.c_str()) == 0) { + _fonts[i]->_refCount++; + return _fonts[i]; + } + } + + /* + BaseFont* font = new BaseFont(_gameRef); + if (!font) return NULL; + + if (DID_FAIL(font->loadFile(filename))) { + delete font; + return NULL; + } + else { + font->_refCount = 1; + _fonts.add(font); + return font; + } + */ + BaseFont *font = BaseFont::createFromFile(_gameRef, filename); + if (font) { + font->_refCount = 1; + _fonts.add(font); + } + return font; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::removeFont(BaseFont *font) { + if (!font) { + return STATUS_FAILED; + } + + for (uint32 i = 0; i < _fonts.size(); i++) { + if (_fonts[i] == font) { + _fonts[i]->_refCount--; + if (_fonts[i]->_refCount <= 0) { + delete _fonts[i]; + _fonts.remove_at(i); + } + break; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontStorage::persist(BasePersistenceManager *persistMgr) { + + if (!persistMgr->getIsSaving()) { + cleanup(false); + } + + persistMgr->transfer(TMEMBER(_gameRef)); + _fonts.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_storage.h b/engines/wintermute/base/font/base_font_storage.h index 733e1c5da3..60874167e7 100644 --- a/engines/wintermute/base/font/base_font_storage.h +++ b/engines/wintermute/base/font/base_font_storage.h @@ -1,55 +1,55 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FONTSTORAGE_H -#define WINTERMUTE_BASE_FONTSTORAGE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { - -class BaseFont; - -class BaseFontStorage : public BaseClass { -public: - DECLARE_PERSISTENT(BaseFontStorage, BaseClass) - bool cleanup(bool warn = false); - bool removeFont(BaseFont *font); - BaseFont *addFont(const Common::String &filename); - BaseFontStorage(BaseGame *inGame); - virtual ~BaseFontStorage(); - BaseArray _fonts; - bool initLoop(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONTSTORAGE_H +#define WINTERMUTE_BASE_FONTSTORAGE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { + +class BaseFont; + +class BaseFontStorage : public BaseClass { +public: + DECLARE_PERSISTENT(BaseFontStorage, BaseClass) + bool cleanup(bool warn = false); + bool removeFont(BaseFont *font); + BaseFont *addFont(const Common::String &filename); + BaseFontStorage(BaseGame *inGame); + virtual ~BaseFontStorage(); + BaseArray _fonts; + bool initLoop(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 171f33d8ab..599010bbd5 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -1,605 +1,605 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_file.h" -#include "engines/wintermute/base/font/base_font_truetype.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/math/math_util.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_parser.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/wintermute.h" -#include "graphics/fonts/ttf.h" -#include "graphics/fontman.h" -#include - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseFontTT, false) - -////////////////////////////////////////////////////////////////////////// -BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { - _fontHeight = 12; - _isBold = _isItalic = _isUnderline = _isStriked = false; - - _fontFile = NULL; - _font = NULL; - _fallbackFont = NULL; - _deletableFont = NULL; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - _cachedTexts[i] = NULL; - } - - _lineHeight = 0; - _maxCharWidth = _maxCharHeight = 0; -} - -////////////////////////////////////////////////////////////////////////// -BaseFontTT::~BaseFontTT(void) { - clearCache(); - - for (uint32 i = 0; i < _layers.size(); i++) { - delete _layers[i]; - } - _layers.clear(); - - delete[] _fontFile; - _fontFile = NULL; - - delete _deletableFont; - _font = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::clearCache() { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i]) { - delete _cachedTexts[i]; - } - _cachedTexts[i] = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::initLoop() { - // we need more aggressive cache management on iOS not to waste too much memory on fonts - if (_gameRef->_constrainedMemory) { - // purge all cached images not used in the last frame - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - continue; - } - - if (!_cachedTexts[i]->_marked) { - delete _cachedTexts[i]; - _cachedTexts[i] = NULL; - } else { - _cachedTexts[i]->_marked = false; - } - } - } -} - -////////////////////////////////////////////////////////////////////////// -int BaseFontTT::getTextWidth(byte *text, int maxLength) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - textStr = StringUtil::utf8ToWide((char *)text); - } else { - textStr = StringUtil::ansiToWide((char *)text); - } - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - } - //text = text.substr(0, MaxLength); // TODO: Remove - - int textWidth, textHeight; - measureText(textStr, -1, -1, textWidth, textHeight); - - return textWidth; -} - -////////////////////////////////////////////////////////////////////////// -int BaseFontTT::getTextHeight(byte *text, int width) { - WideString textStr; - - if (_gameRef->_textEncoding == TEXT_UTF8) { - textStr = StringUtil::utf8ToWide((char *)text); - } else { - textStr = StringUtil::ansiToWide((char *)text); - } - - - int textWidth, textHeight; - measureText(textStr, width, -1, textWidth, textHeight); - - return textHeight; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { - if (text == NULL || strcmp((const char *)text, "") == 0) { - return; - } - - WideString textStr = (const char *)text; - - // TODO: Why do we still insist on Widestrings everywhere? - /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); - else text = StringUtil::AnsiToWide((char *)Text);*/ - - if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { - textStr = Common::String(textStr.c_str(), (uint32)maxLength); - } - //text = text.substr(0, MaxLength); // TODO: Remove - - BaseRenderer *renderer = _gameRef->_renderer; - - // find cached surface, if exists - int minPriority = INT_MAX; - int minIndex = -1; - BaseSurface *surface = NULL; - int textOffset = 0; - - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - if (_cachedTexts[i] == NULL) { - minPriority = 0; - minIndex = i; - } else { - if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { - surface = _cachedTexts[i]->_surface; - textOffset = _cachedTexts[i]->_textOffset; - _cachedTexts[i]->_priority++; - _cachedTexts[i]->_marked = true; - break; - } else { - if (_cachedTexts[i]->_priority < minPriority) { - minPriority = _cachedTexts[i]->_priority; - minIndex = i; - } - } - } - } - - // not found, create one - if (!surface) { - debugC(kWintermuteDebugFont, "Draw text: %s", text); - surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); - if (surface) { - // write surface to cache - if (_cachedTexts[minIndex] != NULL) { - delete _cachedTexts[minIndex]; - } - _cachedTexts[minIndex] = new BaseCachedTTFontText; - - _cachedTexts[minIndex]->_surface = surface; - _cachedTexts[minIndex]->_align = align; - _cachedTexts[minIndex]->_width = width; - _cachedTexts[minIndex]->_maxHeight = maxHeight; - _cachedTexts[minIndex]->_maxLength = maxLength; - _cachedTexts[minIndex]->_priority = 1; - _cachedTexts[minIndex]->_text = textStr; - _cachedTexts[minIndex]->_textOffset = textOffset; - _cachedTexts[minIndex]->_marked = true; - } - } - - - // and paint it - if (surface) { - Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); - for (uint32 i = 0; i < _layers.size(); i++) { - uint32 color = _layers[i]->_color; - uint32 origForceAlpha = renderer->_forceAlphaColor; - if (renderer->_forceAlphaColor != 0) { - color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); - renderer->_forceAlphaColor = 0; - } - surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); - - renderer->_forceAlphaColor = origForceAlpha; - } - } - - -} - -////////////////////////////////////////////////////////////////////////// -BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { - //TextLineList lines; - // TODO: Use WideString-conversion here. - //WrapText(text, width, maxHeight, lines); - Common::Array lines; - _font->wordWrapText(text, width, lines); - - while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) { - lines.pop_back(); - } - if (lines.size() == 0) { - return NULL; - } - - Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; - if (align == TAL_LEFT) { - alignment = Graphics::kTextAlignLeft; - } else if (align == TAL_CENTER) { - alignment = Graphics::kTextAlignCenter; - } else if (align == TAL_RIGHT) { - alignment = Graphics::kTextAlignRight; - } - - debugC(kWintermuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); -// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; - Graphics::Surface *surface = new Graphics::Surface(); - if (_deletableFont) { // We actually have a TTF - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); - } else { // We are using a fallback, they can't do 32bpp - surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); - } - uint32 useColor = 0xffffffff; - Common::Array::iterator it; - int heightOffset = 0; - for (it = lines.begin(); it != lines.end(); ++it) { - _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); - heightOffset += (int)_lineHeight; - } - - BaseSurface *retSurface = _gameRef->_renderer->createSurface(); - Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); - retSurface->putSurface(*convertedSurface, true); - convertedSurface->free(); - surface->free(); - delete surface; - delete convertedSurface; - return retSurface; - // TODO: _isUnderline, _isBold, _isItalic, _isStriked -} - - -////////////////////////////////////////////////////////////////////////// -int BaseFontTT::getLetterHeight() { - return (int)getLineHeight(); -} - - -////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadFile(const Common::String &filename) { - byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); - if (buffer == NULL) { - _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); - return STATUS_FAILED; - } - - bool ret; - - setFilename(filename.c_str()); - - if (DID_FAIL(ret = loadBuffer(buffer))) { - _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); - } - - delete[] buffer; - - return ret; -} - - -TOKEN_DEF_START -TOKEN_DEF(TTFONT) -TOKEN_DEF(SIZE) -TOKEN_DEF(FACE) -TOKEN_DEF(FILENAME) -TOKEN_DEF(BOLD) -TOKEN_DEF(ITALIC) -TOKEN_DEF(UNDERLINE) -TOKEN_DEF(STRIKE) -TOKEN_DEF(CHARSET) -TOKEN_DEF(COLOR) -TOKEN_DEF(ALPHA) -TOKEN_DEF(LAYER) -TOKEN_DEF(OFFSET_X) -TOKEN_DEF(OFFSET_Y) -TOKEN_DEF_END -////////////////////////////////////////////////////////////////////// -bool BaseFontTT::loadBuffer(byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(TTFONT) - TOKEN_TABLE(SIZE) - TOKEN_TABLE(FACE) - TOKEN_TABLE(FILENAME) - TOKEN_TABLE(BOLD) - TOKEN_TABLE(ITALIC) - TOKEN_TABLE(UNDERLINE) - TOKEN_TABLE(STRIKE) - TOKEN_TABLE(CHARSET) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE(LAYER) - TOKEN_TABLE_END - - char *params; - int cmd; - BaseParser parser; - - if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { - _gameRef->LOG(0, "'TTFONT' keyword expected."); - return STATUS_FAILED; - } - buffer = (byte *)params; - - uint32 baseColor = 0x00000000; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_SIZE: - parser.scanStr(params, "%d", &_fontHeight); - break; - - case TOKEN_FACE: - // we don't need this anymore - break; - - case TOKEN_FILENAME: - BaseUtils::setString(&_fontFile, params); - break; - - case TOKEN_BOLD: - parser.scanStr(params, "%b", &_isBold); - break; - - case TOKEN_ITALIC: - parser.scanStr(params, "%b", &_isItalic); - break; - - case TOKEN_UNDERLINE: - parser.scanStr(params, "%b", &_isUnderline); - break; - - case TOKEN_STRIKE: - parser.scanStr(params, "%b", &_isStriked); - break; - - case TOKEN_CHARSET: - // we don't need this anymore - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - baseColor = BYTETORGBA(r, g, b, RGBCOLGetA(baseColor)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - baseColor = BYTETORGBA(RGBCOLGetR(baseColor), RGBCOLGetG(baseColor), RGBCOLGetB(baseColor), a); - } - break; - - case TOKEN_LAYER: { - BaseTTFontLayer *layer = new BaseTTFontLayer; - if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) { - _layers.add(layer); - } else { - delete layer; - layer = NULL; - cmd = PARSERR_TOKENNOTFOUND; - } - } - break; - - } - } - if (cmd == PARSERR_TOKENNOTFOUND) { - _gameRef->LOG(0, "Syntax error in TTFONT definition"); - return STATUS_FAILED; - } - - // create at least one layer - if (_layers.size() == 0) { - BaseTTFontLayer *layer = new BaseTTFontLayer; - layer->_color = baseColor; - _layers.add(layer); - } - - if (!_fontFile) { - BaseUtils::setString(&_fontFile, "arial.ttf"); - } - - return initFont(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { - TOKEN_TABLE_START(commands) - TOKEN_TABLE(OFFSET_X) - TOKEN_TABLE(OFFSET_Y) - TOKEN_TABLE(COLOR) - TOKEN_TABLE(ALPHA) - TOKEN_TABLE_END - - char *params; - int cmd; - BaseParser parser; - - while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { - switch (cmd) { - case TOKEN_OFFSET_X: - parser.scanStr(params, "%d", &layer->_offsetX); - break; - - case TOKEN_OFFSET_Y: - parser.scanStr(params, "%d", &layer->_offsetY); - break; - - case TOKEN_COLOR: { - int r, g, b; - parser.scanStr(params, "%d,%d,%d", &r, &g, &b); - layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); - } - break; - - case TOKEN_ALPHA: { - int a; - parser.scanStr(params, "%d", &a); - layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); - } - break; - } - } - if (cmd != PARSERR_EOF) { - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { - BaseFont::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_isBold)); - persistMgr->transfer(TMEMBER(_isItalic)); - persistMgr->transfer(TMEMBER(_isUnderline)); - persistMgr->transfer(TMEMBER(_isStriked)); - persistMgr->transfer(TMEMBER(_fontHeight)); - persistMgr->transfer(TMEMBER(_fontFile)); - - - // persist layers - int numLayers; - if (persistMgr->getIsSaving()) { - numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - _layers[i]->persist(persistMgr); - } - } else { - numLayers = _layers.size(); - persistMgr->transfer(TMEMBER(numLayers)); - for (int i = 0; i < numLayers; i++) { - BaseTTFontLayer *layer = new BaseTTFontLayer; - layer->persist(persistMgr); - _layers.add(layer); - } - } - - if (!persistMgr->getIsSaving()) { - for (int i = 0; i < NUM_CACHED_TEXTS; i++) { - _cachedTexts[i] = NULL; - } - _fallbackFont = _font = _deletableFont = NULL; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::afterLoad() { - initFont(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseFontTT::initFont() { - if (!_fontFile) { - return STATUS_FAILED; - } - - Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile); - if (!file) { - //TODO: Try to fallback from Arial to FreeSans - /* - // the requested font file is not in wme file space; try loading a system font - AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); - file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false); - if (!file) { - _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); - //return STATUS_FAILED; - }*/ - } - - if (file) { -#ifdef USE_FREETYPE2 - _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). - _font = _deletableFont; -#endif - } - if (!_font) { - _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); - warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); - } - _lineHeight = _font->getFontHeight(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { - //TextLineList lines; - - if (maxWidth >= 0) { - Common::Array lines; - _font->wordWrapText(text, maxWidth, lines); - Common::Array::iterator it; - textWidth = 0; - for (it = lines.begin(); it != lines.end(); ++it) { - textWidth = MAX(textWidth, _font->getStringWidth(*it)); - } - - //WrapText(text, maxWidth, maxHeight, lines); - - textHeight = (int)(lines.size() * getLineHeight()); - } else { - textWidth = _font->getStringWidth(text); - textHeight = _fontHeight; - } - /* - TextLineList::iterator it; - for (it = lines.begin(); it != lines.end(); ++it) { - TextLine *line = (*it); - textWidth = MAX(textWidth, line->GetWidth()); - delete line; - line = NULL; - }*/ -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/font/base_font_truetype.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_parser.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/wintermute.h" +#include "graphics/fonts/ttf.h" +#include "graphics/fontman.h" +#include + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseFontTT, false) + +////////////////////////////////////////////////////////////////////////// +BaseFontTT::BaseFontTT(BaseGame *inGame) : BaseFont(inGame) { + _fontHeight = 12; + _isBold = _isItalic = _isUnderline = _isStriked = false; + + _fontFile = NULL; + _font = NULL; + _fallbackFont = NULL; + _deletableFont = NULL; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } + + _lineHeight = 0; + _maxCharWidth = _maxCharHeight = 0; +} + +////////////////////////////////////////////////////////////////////////// +BaseFontTT::~BaseFontTT(void) { + clearCache(); + + for (uint32 i = 0; i < _layers.size(); i++) { + delete _layers[i]; + } + _layers.clear(); + + delete[] _fontFile; + _fontFile = NULL; + + delete _deletableFont; + _font = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::clearCache() { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i]) { + delete _cachedTexts[i]; + } + _cachedTexts[i] = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::initLoop() { + // we need more aggressive cache management on iOS not to waste too much memory on fonts + if (_gameRef->_constrainedMemory) { + // purge all cached images not used in the last frame + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + continue; + } + + if (!_cachedTexts[i]->_marked) { + delete _cachedTexts[i]; + _cachedTexts[i] = NULL; + } else { + _cachedTexts[i]->_marked = false; + } + } + } +} + +////////////////////////////////////////////////////////////////////////// +int BaseFontTT::getTextWidth(byte *text, int maxLength) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } + //text = text.substr(0, MaxLength); // TODO: Remove + + int textWidth, textHeight; + measureText(textStr, -1, -1, textWidth, textHeight); + + return textWidth; +} + +////////////////////////////////////////////////////////////////////////// +int BaseFontTT::getTextHeight(byte *text, int width) { + WideString textStr; + + if (_gameRef->_textEncoding == TEXT_UTF8) { + textStr = StringUtil::utf8ToWide((char *)text); + } else { + textStr = StringUtil::ansiToWide((char *)text); + } + + + int textWidth, textHeight; + measureText(textStr, width, -1, textWidth, textHeight); + + return textHeight; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::drawText(const byte *text, int x, int y, int width, TTextAlign align, int maxHeight, int maxLength) { + if (text == NULL || strcmp((const char *)text, "") == 0) { + return; + } + + WideString textStr = (const char *)text; + + // TODO: Why do we still insist on Widestrings everywhere? + /* if (_gameRef->_textEncoding == TEXT_UTF8) text = StringUtil::Utf8ToWide((char *)Text); + else text = StringUtil::AnsiToWide((char *)Text);*/ + + if (maxLength >= 0 && textStr.size() > (uint32)maxLength) { + textStr = Common::String(textStr.c_str(), (uint32)maxLength); + } + //text = text.substr(0, MaxLength); // TODO: Remove + + BaseRenderer *renderer = _gameRef->_renderer; + + // find cached surface, if exists + int minPriority = INT_MAX; + int minIndex = -1; + BaseSurface *surface = NULL; + int textOffset = 0; + + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + if (_cachedTexts[i] == NULL) { + minPriority = 0; + minIndex = i; + } else { + if (_cachedTexts[i]->_text == textStr && _cachedTexts[i]->_align == align && _cachedTexts[i]->_width == width && _cachedTexts[i]->_maxHeight == maxHeight && _cachedTexts[i]->_maxLength == maxLength) { + surface = _cachedTexts[i]->_surface; + textOffset = _cachedTexts[i]->_textOffset; + _cachedTexts[i]->_priority++; + _cachedTexts[i]->_marked = true; + break; + } else { + if (_cachedTexts[i]->_priority < minPriority) { + minPriority = _cachedTexts[i]->_priority; + minIndex = i; + } + } + } + } + + // not found, create one + if (!surface) { + debugC(kWintermuteDebugFont, "Draw text: %s", text); + surface = renderTextToTexture(textStr, width, align, maxHeight, textOffset); + if (surface) { + // write surface to cache + if (_cachedTexts[minIndex] != NULL) { + delete _cachedTexts[minIndex]; + } + _cachedTexts[minIndex] = new BaseCachedTTFontText; + + _cachedTexts[minIndex]->_surface = surface; + _cachedTexts[minIndex]->_align = align; + _cachedTexts[minIndex]->_width = width; + _cachedTexts[minIndex]->_maxHeight = maxHeight; + _cachedTexts[minIndex]->_maxLength = maxLength; + _cachedTexts[minIndex]->_priority = 1; + _cachedTexts[minIndex]->_text = textStr; + _cachedTexts[minIndex]->_textOffset = textOffset; + _cachedTexts[minIndex]->_marked = true; + } + } + + + // and paint it + if (surface) { + Rect32 rc; + BasePlatform::setRect(&rc, 0, 0, surface->getWidth(), surface->getHeight()); + for (uint32 i = 0; i < _layers.size(); i++) { + uint32 color = _layers[i]->_color; + uint32 origForceAlpha = renderer->_forceAlphaColor; + if (renderer->_forceAlphaColor != 0) { + color = BYTETORGBA(RGBCOLGetR(color), RGBCOLGetG(color), RGBCOLGetB(color), RGBCOLGetA(renderer->_forceAlphaColor)); + renderer->_forceAlphaColor = 0; + } + surface->displayTransOffset(x, y - textOffset, rc, color, BLEND_NORMAL, false, false, _layers[i]->_offsetX, _layers[i]->_offsetY); + + renderer->_forceAlphaColor = origForceAlpha; + } + } + + +} + +////////////////////////////////////////////////////////////////////////// +BaseSurface *BaseFontTT::renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset) { + //TextLineList lines; + // TODO: Use WideString-conversion here. + //WrapText(text, width, maxHeight, lines); + Common::Array lines; + _font->wordWrapText(text, width, lines); + + while (maxHeight > 0 && lines.size() * _lineHeight > maxHeight) { + lines.pop_back(); + } + if (lines.size() == 0) { + return NULL; + } + + Graphics::TextAlign alignment = Graphics::kTextAlignInvalid; + if (align == TAL_LEFT) { + alignment = Graphics::kTextAlignLeft; + } else if (align == TAL_CENTER) { + alignment = Graphics::kTextAlignCenter; + } else if (align == TAL_RIGHT) { + alignment = Graphics::kTextAlignRight; + } + + debugC(kWintermuteDebugFont, "%s %d %d %d %d", text.c_str(), RGBCOLGetR(_layers[0]->_color), RGBCOLGetG(_layers[0]->_color), RGBCOLGetB(_layers[0]->_color), RGBCOLGetA(_layers[0]->_color)); +// void drawString(Surface *dst, const Common::String &str, int x, int y, int w, uint32 color, TextAlign align = kTextAlignLeft, int deltax = 0, bool useEllipsis = true) const; + Graphics::Surface *surface = new Graphics::Surface(); + if (_deletableFont) { // We actually have a TTF + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); + } else { // We are using a fallback, they can't do 32bpp + surface->create((uint16)width, (uint16)(_lineHeight * lines.size()), Graphics::PixelFormat(2, 5, 5, 5, 1, 11, 6, 1, 0)); + } + uint32 useColor = 0xffffffff; + Common::Array::iterator it; + int heightOffset = 0; + for (it = lines.begin(); it != lines.end(); ++it) { + _font->drawString(surface, *it, 0, heightOffset, width, useColor, alignment); + heightOffset += (int)_lineHeight; + } + + BaseSurface *retSurface = _gameRef->_renderer->createSurface(); + Graphics::Surface *convertedSurface = surface->convertTo(Graphics::PixelFormat(4, 8, 8, 8, 8, 16, 8, 0, 24)); + retSurface->putSurface(*convertedSurface, true); + convertedSurface->free(); + surface->free(); + delete surface; + delete convertedSurface; + return retSurface; + // TODO: _isUnderline, _isBold, _isItalic, _isStriked +} + + +////////////////////////////////////////////////////////////////////////// +int BaseFontTT::getLetterHeight() { + return (int)getLineHeight(); +} + + +////////////////////////////////////////////////////////////////////// +bool BaseFontTT::loadFile(const Common::String &filename) { + byte *buffer = BaseFileManager::getEngineInstance()->readWholeFile(filename); + if (buffer == NULL) { + _gameRef->LOG(0, "BaseFontTT::LoadFile failed for file '%s'", filename.c_str()); + return STATUS_FAILED; + } + + bool ret; + + setFilename(filename.c_str()); + + if (DID_FAIL(ret = loadBuffer(buffer))) { + _gameRef->LOG(0, "Error parsing TTFONT file '%s'", filename.c_str()); + } + + delete[] buffer; + + return ret; +} + + +TOKEN_DEF_START +TOKEN_DEF(TTFONT) +TOKEN_DEF(SIZE) +TOKEN_DEF(FACE) +TOKEN_DEF(FILENAME) +TOKEN_DEF(BOLD) +TOKEN_DEF(ITALIC) +TOKEN_DEF(UNDERLINE) +TOKEN_DEF(STRIKE) +TOKEN_DEF(CHARSET) +TOKEN_DEF(COLOR) +TOKEN_DEF(ALPHA) +TOKEN_DEF(LAYER) +TOKEN_DEF(OFFSET_X) +TOKEN_DEF(OFFSET_Y) +TOKEN_DEF_END +////////////////////////////////////////////////////////////////////// +bool BaseFontTT::loadBuffer(byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(TTFONT) + TOKEN_TABLE(SIZE) + TOKEN_TABLE(FACE) + TOKEN_TABLE(FILENAME) + TOKEN_TABLE(BOLD) + TOKEN_TABLE(ITALIC) + TOKEN_TABLE(UNDERLINE) + TOKEN_TABLE(STRIKE) + TOKEN_TABLE(CHARSET) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE(LAYER) + TOKEN_TABLE_END + + char *params; + int cmd; + BaseParser parser; + + if (parser.getCommand((char **)&buffer, commands, (char **)¶ms) != TOKEN_TTFONT) { + _gameRef->LOG(0, "'TTFONT' keyword expected."); + return STATUS_FAILED; + } + buffer = (byte *)params; + + uint32 baseColor = 0x00000000; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_SIZE: + parser.scanStr(params, "%d", &_fontHeight); + break; + + case TOKEN_FACE: + // we don't need this anymore + break; + + case TOKEN_FILENAME: + BaseUtils::setString(&_fontFile, params); + break; + + case TOKEN_BOLD: + parser.scanStr(params, "%b", &_isBold); + break; + + case TOKEN_ITALIC: + parser.scanStr(params, "%b", &_isItalic); + break; + + case TOKEN_UNDERLINE: + parser.scanStr(params, "%b", &_isUnderline); + break; + + case TOKEN_STRIKE: + parser.scanStr(params, "%b", &_isStriked); + break; + + case TOKEN_CHARSET: + // we don't need this anymore + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + baseColor = BYTETORGBA(r, g, b, RGBCOLGetA(baseColor)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + baseColor = BYTETORGBA(RGBCOLGetR(baseColor), RGBCOLGetG(baseColor), RGBCOLGetB(baseColor), a); + } + break; + + case TOKEN_LAYER: { + BaseTTFontLayer *layer = new BaseTTFontLayer; + if (layer && DID_SUCCEED(parseLayer(layer, (byte *)params))) { + _layers.add(layer); + } else { + delete layer; + layer = NULL; + cmd = PARSERR_TOKENNOTFOUND; + } + } + break; + + } + } + if (cmd == PARSERR_TOKENNOTFOUND) { + _gameRef->LOG(0, "Syntax error in TTFONT definition"); + return STATUS_FAILED; + } + + // create at least one layer + if (_layers.size() == 0) { + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->_color = baseColor; + _layers.add(layer); + } + + if (!_fontFile) { + BaseUtils::setString(&_fontFile, "arial.ttf"); + } + + return initFont(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontTT::parseLayer(BaseTTFontLayer *layer, byte *buffer) { + TOKEN_TABLE_START(commands) + TOKEN_TABLE(OFFSET_X) + TOKEN_TABLE(OFFSET_Y) + TOKEN_TABLE(COLOR) + TOKEN_TABLE(ALPHA) + TOKEN_TABLE_END + + char *params; + int cmd; + BaseParser parser; + + while ((cmd = parser.getCommand((char **)&buffer, commands, (char **)¶ms)) > 0) { + switch (cmd) { + case TOKEN_OFFSET_X: + parser.scanStr(params, "%d", &layer->_offsetX); + break; + + case TOKEN_OFFSET_Y: + parser.scanStr(params, "%d", &layer->_offsetY); + break; + + case TOKEN_COLOR: { + int r, g, b; + parser.scanStr(params, "%d,%d,%d", &r, &g, &b); + layer->_color = BYTETORGBA(r, g, b, RGBCOLGetA(layer->_color)); + } + break; + + case TOKEN_ALPHA: { + int a; + parser.scanStr(params, "%d", &a); + layer->_color = BYTETORGBA(RGBCOLGetR(layer->_color), RGBCOLGetG(layer->_color), RGBCOLGetB(layer->_color), a); + } + break; + } + } + if (cmd != PARSERR_EOF) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseFontTT::persist(BasePersistenceManager *persistMgr) { + BaseFont::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_isBold)); + persistMgr->transfer(TMEMBER(_isItalic)); + persistMgr->transfer(TMEMBER(_isUnderline)); + persistMgr->transfer(TMEMBER(_isStriked)); + persistMgr->transfer(TMEMBER(_fontHeight)); + persistMgr->transfer(TMEMBER(_fontFile)); + + + // persist layers + int numLayers; + if (persistMgr->getIsSaving()) { + numLayers = _layers.size(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + _layers[i]->persist(persistMgr); + } + } else { + numLayers = _layers.size(); + persistMgr->transfer(TMEMBER(numLayers)); + for (int i = 0; i < numLayers; i++) { + BaseTTFontLayer *layer = new BaseTTFontLayer; + layer->persist(persistMgr); + _layers.add(layer); + } + } + + if (!persistMgr->getIsSaving()) { + for (int i = 0; i < NUM_CACHED_TEXTS; i++) { + _cachedTexts[i] = NULL; + } + _fallbackFont = _font = _deletableFont = NULL; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::afterLoad() { + initFont(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseFontTT::initFont() { + if (!_fontFile) { + return STATUS_FAILED; + } + + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile); + if (!file) { + //TODO: Try to fallback from Arial to FreeSans + /* + // the requested font file is not in wme file space; try loading a system font + AnsiString fontFileName = PathUtil::combine(BasePlatform::getSystemFontPath(), PathUtil::getFileName(_fontFile)); + file = BaseFileManager::getEngineInstance()->openFile(fontFileName.c_str(), false); + if (!file) { + _gameRef->LOG(0, "Error loading TrueType font '%s'", _fontFile); + //return STATUS_FAILED; + }*/ + } + + if (file) { +#ifdef USE_FREETYPE2 + _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). + _font = _deletableFont; +#endif + } + if (!_font) { + _font = _fallbackFont = FontMan.getFontByUsage(Graphics::FontManager::kBigGUIFont); + warning("BaseFontTT::InitFont - Couldn't load font: %s", _fontFile); + } + _lineHeight = _font->getFontHeight(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseFontTT::measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight) { + //TextLineList lines; + + if (maxWidth >= 0) { + Common::Array lines; + _font->wordWrapText(text, maxWidth, lines); + Common::Array::iterator it; + textWidth = 0; + for (it = lines.begin(); it != lines.end(); ++it) { + textWidth = MAX(textWidth, _font->getStringWidth(*it)); + } + + //WrapText(text, maxWidth, maxHeight, lines); + + textHeight = (int)(lines.size() * getLineHeight()); + } else { + textWidth = _font->getStringWidth(text); + textHeight = _fontHeight; + } + /* + TextLineList::iterator it; + for (it = lines.begin(); it != lines.end(); ++it) { + TextLine *line = (*it); + textWidth = MAX(textWidth, line->GetWidth()); + delete line; + line = NULL; + }*/ +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index a93e4efacb..02dca7439f 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -1,152 +1,152 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_FONTTT_H -#define WINTERMUTE_BASE_FONTTT_H - -#include "engines/wintermute/base/font/base_font_storage.h" -#include "engines/wintermute/base/font/base_font.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "graphics/font.h" - -#define NUM_CACHED_TEXTS 30 - -namespace Wintermute { - -class BaseFontTT : public BaseFont { -private: - ////////////////////////////////////////////////////////////////////////// - class BaseCachedTTFontText { - public: - WideString _text; - int _width; - TTextAlign _align; - int _maxHeight; - int _maxLength; - BaseSurface *_surface; - int _priority; - int _textOffset; - bool _marked; - - BaseCachedTTFontText() { - //_text = L""; - _text = ""; - _width = _maxHeight = _maxLength = -1; - _align = TAL_LEFT; - _surface = NULL; - _priority = -1; - _textOffset = 0; - _marked = false; - } - - virtual ~BaseCachedTTFontText() { - if (_surface) { - delete _surface; - } - } - }; - -public: - ////////////////////////////////////////////////////////////////////////// - class BaseTTFontLayer { - public: - BaseTTFontLayer() { - _offsetX = _offsetY = 0; - _color = 0x00000000; - } - - bool persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_offsetX)); - persistMgr->transfer(TMEMBER(_offsetY)); - persistMgr->transfer(TMEMBER(_color)); - return STATUS_OK; - } - - int _offsetX; - int _offsetY; - uint32 _color; - }; - -public: - DECLARE_PERSISTENT(BaseFontTT, BaseFont) - BaseFontTT(BaseGame *inGame); - virtual ~BaseFontTT(void); - - virtual int getTextWidth(byte *text, int maxLength = -1); - virtual int getTextHeight(byte *text, int width); - virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); - virtual int getLetterHeight(); - - bool loadBuffer(byte *buffer); - bool loadFile(const Common::String &filename); - - float getLineHeight() const { - return _lineHeight; - } - - void afterLoad(); - void initLoop(); - -private: - bool parseLayer(BaseTTFontLayer *layer, byte *buffer); - - void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); - - BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); - - BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; - - bool initFont(); - - Graphics::Font *_deletableFont; - const Graphics::Font *_font; - const Graphics::Font *_fallbackFont; - - float _lineHeight; - - size_t _maxCharWidth; - size_t _maxCharHeight; - -public: - bool _isBold; - bool _isItalic; - bool _isUnderline; - bool _isStriked; - int _fontHeight; - char *_fontFile; - - BaseArray _layers; - void clearCache(); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_FONTTT_H +#define WINTERMUTE_BASE_FONTTT_H + +#include "engines/wintermute/base/font/base_font_storage.h" +#include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "graphics/font.h" + +#define NUM_CACHED_TEXTS 30 + +namespace Wintermute { + +class BaseFontTT : public BaseFont { +private: + ////////////////////////////////////////////////////////////////////////// + class BaseCachedTTFontText { + public: + WideString _text; + int _width; + TTextAlign _align; + int _maxHeight; + int _maxLength; + BaseSurface *_surface; + int _priority; + int _textOffset; + bool _marked; + + BaseCachedTTFontText() { + //_text = L""; + _text = ""; + _width = _maxHeight = _maxLength = -1; + _align = TAL_LEFT; + _surface = NULL; + _priority = -1; + _textOffset = 0; + _marked = false; + } + + virtual ~BaseCachedTTFontText() { + if (_surface) { + delete _surface; + } + } + }; + +public: + ////////////////////////////////////////////////////////////////////////// + class BaseTTFontLayer { + public: + BaseTTFontLayer() { + _offsetX = _offsetY = 0; + _color = 0x00000000; + } + + bool persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_offsetX)); + persistMgr->transfer(TMEMBER(_offsetY)); + persistMgr->transfer(TMEMBER(_color)); + return STATUS_OK; + } + + int _offsetX; + int _offsetY; + uint32 _color; + }; + +public: + DECLARE_PERSISTENT(BaseFontTT, BaseFont) + BaseFontTT(BaseGame *inGame); + virtual ~BaseFontTT(void); + + virtual int getTextWidth(byte *text, int maxLength = -1); + virtual int getTextHeight(byte *text, int width); + virtual void drawText(const byte *text, int x, int y, int width, TTextAlign align = TAL_LEFT, int max_height = -1, int maxLength = -1); + virtual int getLetterHeight(); + + bool loadBuffer(byte *buffer); + bool loadFile(const Common::String &filename); + + float getLineHeight() const { + return _lineHeight; + } + + void afterLoad(); + void initLoop(); + +private: + bool parseLayer(BaseTTFontLayer *layer, byte *buffer); + + void measureText(const WideString &text, int maxWidth, int maxHeight, int &textWidth, int &textHeight); + + BaseSurface *renderTextToTexture(const WideString &text, int width, TTextAlign align, int maxHeight, int &textOffset); + + BaseCachedTTFontText *_cachedTexts[NUM_CACHED_TEXTS]; + + bool initFont(); + + Graphics::Font *_deletableFont; + const Graphics::Font *_font; + const Graphics::Font *_fallbackFont; + + float _lineHeight; + + size_t _maxCharWidth; + size_t _maxCharHeight; + +public: + bool _isBold; + bool _isItalic; + bool _isUnderline; + bool _isStriked; + int _fontHeight; + char *_fontFile; + + BaseArray _layers; + void clearCache(); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/base_image.cpp b/engines/wintermute/base/gfx/base_image.cpp index bf11e15307..4b15d563ed 100644 --- a/engines/wintermute/base/gfx/base_image.cpp +++ b/engines/wintermute/base/gfx/base_image.cpp @@ -1,231 +1,231 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/graphics/transparent_surface.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/jpeg.h" -#include "graphics/decoders/bmp.h" -#include "graphics/decoders/tga.h" -#include "graphics/surface.h" -#include "common/textconsole.h" -#include "common/stream.h" -#include "common/system.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseImage::BaseImage() { - _fileManager = BaseFileManager::getEngineInstance(); - _palette = NULL; - _surface = NULL; - _decoder = NULL; - _deletableSurface = NULL; -} - - -////////////////////////////////////////////////////////////////////// -BaseImage::~BaseImage() { - delete _decoder; - if (_deletableSurface) { - _deletableSurface->free(); - } - delete _deletableSurface; -} - -bool BaseImage::loadFile(const Common::String &filename) { - _filename = filename; - _filename.toLowercase(); - if (filename.hasPrefix("savegame:")) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".png")) { - _decoder = new Graphics::PNGDecoder(); - } else if (_filename.hasSuffix(".bmp")) { - _decoder = new Graphics::BitmapDecoder(); - } else if (_filename.hasSuffix(".tga")) { - _decoder = new Graphics::TGADecoder(); - } else if (_filename.hasSuffix(".jpg")) { - _decoder = new Graphics::JPEGDecoder(); - } else { - error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); - } - _filename = filename; - Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); - if (!file) { - return false; - } - - _decoder->loadStream(*file); - _surface = _decoder->getSurface(); - _palette = _decoder->getPalette(); - _fileManager->closeFile(file); - - return true; -} - -byte BaseImage::getAlphaAt(int x, int y) const { - if (!_surface) { - return 0xFF; - } - uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); - byte r, g, b, a; - _surface->format.colorToARGB(color, a, r, g, b); - return a; -} - -void BaseImage::copyFrom(const Graphics::Surface *surface) { - _surface = _deletableSurface = new Graphics::Surface(); - _deletableSurface->copyFrom(*surface); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::saveBMPFile(const char *filename) const { - warning("BaseImage::saveBMPFile - stubbed"); // TODO - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::resize(int newWidth, int newHeight) { - // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - TransparentSurface temp(*_surface, true); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); - temp.free(); - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { - if (!_surface) { - return false; - } - - /* The following is just copied over and inverted to write-ops from the BMP-decoder */ - stream->writeByte('B'); - stream->writeByte('M'); - - /* Since we don't care during reads, we don't care during writes: */ - /* uint32 fileSize = */ - stream->writeUint32LE(54 + _surface->h * _surface->pitch); - /* uint16 res1 = */ - stream->writeUint16LE(0); - /* uint16 res2 = */ - stream->writeUint16LE(0); - const uint32 imageOffset = 54; - stream->writeUint32LE(imageOffset); - - const uint32 infoSize = 40; /* Windows v3 BMP */ - stream->writeUint32LE(infoSize); - - uint32 width = _surface->w; - int32 height = _surface->h; - stream->writeUint32LE(width); - stream->writeUint32LE((uint32)height); - - if (width == 0 || height == 0) { - return false; - } - - if (height < 0) { - warning("Right-side up bitmaps not supported"); - return false; - } - - /* uint16 planes = */ stream->writeUint16LE(1); - const uint16 bitsPerPixel = 24; - stream->writeUint16LE(bitsPerPixel); - - const uint32 compression = 0; - stream->writeUint32LE(compression); - - /* uint32 imageSize = */ - stream->writeUint32LE(_surface->h * _surface->pitch); - /* uint32 pixelsPerMeterX = */ - stream->writeUint32LE(0); - /* uint32 pixelsPerMeterY = */ - stream->writeUint32LE(0); - const uint32 paletteColorCount = 0; - stream->writeUint32LE(paletteColorCount); - /* uint32 colorsImportant = */ - stream->writeUint32LE(0); - - // Start us at the beginning of the image (54 bytes in) - Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); - - // BGRA for 24bpp - if (bitsPerPixel == 24) { - format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); - } - - Graphics::Surface *surface = _surface->convertTo(format); - - int srcPitch = width * (bitsPerPixel >> 3); - const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; - - for (int32 i = height - 1; i >= 0; i--) { - for (uint32 j = 0; j < width; j++) { - byte b, g, r; - uint32 color = *(uint32 *)surface->getBasePtr(j, i); - surface->format.colorToRGB(color, r, g, b); - stream->writeByte(b); - stream->writeByte(g); - stream->writeByte(r); - } - - for (int k = 0; k < extraDataLength; k++) { - stream->writeByte(0); - } - } - surface->free(); - delete surface; - return true; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { - // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. - - TransparentSurface temp(*origImage->_surface, false); - if (_deletableSurface) { - _deletableSurface->free(); - delete _deletableSurface; - _deletableSurface = NULL; - } - _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); - return true; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/bmp.h" +#include "graphics/decoders/tga.h" +#include "graphics/surface.h" +#include "common/textconsole.h" +#include "common/stream.h" +#include "common/system.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseImage::BaseImage() { + _fileManager = BaseFileManager::getEngineInstance(); + _palette = NULL; + _surface = NULL; + _decoder = NULL; + _deletableSurface = NULL; +} + + +////////////////////////////////////////////////////////////////////// +BaseImage::~BaseImage() { + delete _decoder; + if (_deletableSurface) { + _deletableSurface->free(); + } + delete _deletableSurface; +} + +bool BaseImage::loadFile(const Common::String &filename) { + _filename = filename; + _filename.toLowercase(); + if (filename.hasPrefix("savegame:")) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".png")) { + _decoder = new Graphics::PNGDecoder(); + } else if (_filename.hasSuffix(".bmp")) { + _decoder = new Graphics::BitmapDecoder(); + } else if (_filename.hasSuffix(".tga")) { + _decoder = new Graphics::TGADecoder(); + } else if (_filename.hasSuffix(".jpg")) { + _decoder = new Graphics::JPEGDecoder(); + } else { + error("BaseImage::loadFile : Unsupported fileformat %s", filename.c_str()); + } + _filename = filename; + Common::SeekableReadStream *file = _fileManager->openFile(filename.c_str()); + if (!file) { + return false; + } + + _decoder->loadStream(*file); + _surface = _decoder->getSurface(); + _palette = _decoder->getPalette(); + _fileManager->closeFile(file); + + return true; +} + +byte BaseImage::getAlphaAt(int x, int y) const { + if (!_surface) { + return 0xFF; + } + uint32 color = *(const uint32 *)_surface->getBasePtr(x, y); + byte r, g, b, a; + _surface->format.colorToARGB(color, a, r, g, b); + return a; +} + +void BaseImage::copyFrom(const Graphics::Surface *surface) { + _surface = _deletableSurface = new Graphics::Surface(); + _deletableSurface->copyFrom(*surface); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::saveBMPFile(const char *filename) const { + warning("BaseImage::saveBMPFile - stubbed"); // TODO + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::resize(int newWidth, int newHeight) { + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + TransparentSurface temp(*_surface, true); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); + temp.free(); + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::writeBMPToStream(Common::WriteStream *stream) const { + if (!_surface) { + return false; + } + + /* The following is just copied over and inverted to write-ops from the BMP-decoder */ + stream->writeByte('B'); + stream->writeByte('M'); + + /* Since we don't care during reads, we don't care during writes: */ + /* uint32 fileSize = */ + stream->writeUint32LE(54 + _surface->h * _surface->pitch); + /* uint16 res1 = */ + stream->writeUint16LE(0); + /* uint16 res2 = */ + stream->writeUint16LE(0); + const uint32 imageOffset = 54; + stream->writeUint32LE(imageOffset); + + const uint32 infoSize = 40; /* Windows v3 BMP */ + stream->writeUint32LE(infoSize); + + uint32 width = _surface->w; + int32 height = _surface->h; + stream->writeUint32LE(width); + stream->writeUint32LE((uint32)height); + + if (width == 0 || height == 0) { + return false; + } + + if (height < 0) { + warning("Right-side up bitmaps not supported"); + return false; + } + + /* uint16 planes = */ stream->writeUint16LE(1); + const uint16 bitsPerPixel = 24; + stream->writeUint16LE(bitsPerPixel); + + const uint32 compression = 0; + stream->writeUint32LE(compression); + + /* uint32 imageSize = */ + stream->writeUint32LE(_surface->h * _surface->pitch); + /* uint32 pixelsPerMeterX = */ + stream->writeUint32LE(0); + /* uint32 pixelsPerMeterY = */ + stream->writeUint32LE(0); + const uint32 paletteColorCount = 0; + stream->writeUint32LE(paletteColorCount); + /* uint32 colorsImportant = */ + stream->writeUint32LE(0); + + // Start us at the beginning of the image (54 bytes in) + Graphics::PixelFormat format = Graphics::PixelFormat::createFormatCLUT8(); + + // BGRA for 24bpp + if (bitsPerPixel == 24) { + format = Graphics::PixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0); + } + + Graphics::Surface *surface = _surface->convertTo(format); + + int srcPitch = width * (bitsPerPixel >> 3); + const int extraDataLength = (srcPitch % 4) ? 4 - (srcPitch % 4) : 0; + + for (int32 i = height - 1; i >= 0; i--) { + for (uint32 j = 0; j < width; j++) { + byte b, g, r; + uint32 color = *(uint32 *)surface->getBasePtr(j, i); + surface->format.colorToRGB(color, r, g, b); + stream->writeByte(b); + stream->writeByte(g); + stream->writeByte(r); + } + + for (int k = 0; k < extraDataLength; k++) { + stream->writeByte(0); + } + } + surface->free(); + delete surface; + return true; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseImage::copyFrom(BaseImage *origImage, int newWidth, int newHeight) { + // WME Lite used FILTER_BILINEAR with FreeImage_Rescale here. + + TransparentSurface temp(*origImage->_surface, false); + if (_deletableSurface) { + _deletableSurface->free(); + delete _deletableSurface; + _deletableSurface = NULL; + } + _surface = _deletableSurface = temp.scale((uint16)newWidth, (uint16)newHeight); + return true; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_image.h b/engines/wintermute/base/gfx/base_image.h index 560a5f0d74..6d01b84184 100644 --- a/engines/wintermute/base/gfx/base_image.h +++ b/engines/wintermute/base/gfx/base_image.h @@ -1,72 +1,72 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_IMAGE_H -#define WINTERMUTE_BASE_IMAGE_H - -#include "graphics/surface.h" -#include "graphics/pixelformat.h" -#include "graphics/decoders/image_decoder.h" -#include "common/endian.h" -#include "common/str.h" -#include "common/stream.h" - -namespace Wintermute { -class BaseSurface; -class BaseFileManager; -class BaseImage { - -public: - BaseImage(); - ~BaseImage(); - - bool loadFile(const Common::String &filename); - const Graphics::Surface *getSurface() const { - return _surface; - }; - const byte *getPalette() const { - return _palette; - } - byte getAlphaAt(int x, int y) const; - bool writeBMPToStream(Common::WriteStream *stream) const; - bool resize(int newWidth, int newHeight); - bool saveBMPFile(const char *filename) const; - bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); - void copyFrom(const Graphics::Surface *surface); -private: - Common::String _filename; - Graphics::ImageDecoder *_decoder; - const Graphics::Surface *_surface; - Graphics::Surface *_deletableSurface; - const byte *_palette; - BaseFileManager *_fileManager; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_IMAGE_H +#define WINTERMUTE_BASE_IMAGE_H + +#include "graphics/surface.h" +#include "graphics/pixelformat.h" +#include "graphics/decoders/image_decoder.h" +#include "common/endian.h" +#include "common/str.h" +#include "common/stream.h" + +namespace Wintermute { +class BaseSurface; +class BaseFileManager; +class BaseImage { + +public: + BaseImage(); + ~BaseImage(); + + bool loadFile(const Common::String &filename); + const Graphics::Surface *getSurface() const { + return _surface; + }; + const byte *getPalette() const { + return _palette; + } + byte getAlphaAt(int x, int y) const; + bool writeBMPToStream(Common::WriteStream *stream) const; + bool resize(int newWidth, int newHeight); + bool saveBMPFile(const char *filename) const; + bool copyFrom(BaseImage *origImage, int newWidth = 0, int newHeight = 0); + void copyFrom(const Graphics::Surface *surface); +private: + Common::String _filename; + Graphics::ImageDecoder *_decoder; + const Graphics::Surface *_surface; + Graphics::Surface *_deletableSurface; + const byte *_palette; + BaseFileManager *_fileManager; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 202c864683..9205438a5b 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -1,381 +1,381 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_active_rect.h" -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "engines/wintermute/base/base_sub_frame.h" -#include "engines/wintermute/base/base_region.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { - _window = 0; - _clipperWindow = 0; - _active = false; - _ready = false; - _windowed = true; - _forceAlphaColor = 0x00; - - _indicatorDisplay = false; - _indicatorColor = BYTETORGBA(255, 0, 0, 128); - _indicatorProgress = 0; - _indicatorX = -1; - _indicatorY = -1; - _indicatorWidth = -1; - _indicatorHeight = 8; - _indicatorWidthDrawn = 0; - - _loadImageName = ""; - _saveImageName = ""; - _saveLoadImage = NULL; - _loadInProgress = false; - _hasDrawnSaveLoadImage = false; - - _saveImageX = _saveImageY = 0; - _loadImageX = _loadImageY = 0; - - _width = _height = _bPP = 0; - BasePlatform::setRectEmpty(&_monitorRect); - - _realWidth = _realHeight = 0; - _drawOffsetX = _drawOffsetY = 0; -} - - -////////////////////////////////////////////////////////////////////// -BaseRenderer::~BaseRenderer() { - deleteRectList(); - unclipCursor(); - delete _saveLoadImage; -} - - -////////////////////////////////////////////////////////////////////// -void BaseRenderer::initLoop() { - deleteRectList(); -} - -void BaseRenderer::initIndicator() { - if (_indicatorY == -1) { - _indicatorY = _height - _indicatorHeight; - } - if (_indicatorX == -1) { - _indicatorX = 0; - } - if (_indicatorWidth == -1) { - _indicatorWidth = _width; - } -} - -void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 color) { - _indicatorWidth = width; - _indicatorHeight = height; - _indicatorX = x; - _indicatorY = y; - _indicatorColor = color; -} - -void BaseRenderer::setIndicatorVal(int value) { - bool redisplay = (_indicatorProgress != value); - _indicatorProgress = value; - if (redisplay) - displayIndicator(); -} - -void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { - // TODO: Handle NULL - _loadImageName = filename; - _loadImageX = x; - _loadImageY = y; -} - -void BaseRenderer::setSaveImage(const char *filename, int x, int y) { - // TODO: Handle NULL - _saveImageName = filename; - _saveImageX = x; - _saveImageY = y; -} - -void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { - _indicatorDisplay = true; - _indicatorProgress = 0; - _hasDrawnSaveLoadImage = false; - - if (isSaving && !quickSave) { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_saveImageName.size()) { - _saveLoadImage = createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - } else { - delete _saveLoadImage; - _saveLoadImage = NULL; - if (_loadImageName.size()) { - _saveLoadImage = createSurface(); - - if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { - delete _saveLoadImage; - _saveLoadImage = NULL; - } - } - _loadInProgress = true; - } -} - -void BaseRenderer::endSaveLoad() { - _loadInProgress = false; - _indicatorDisplay = false; - _indicatorWidthDrawn = 0; - - delete _saveLoadImage; - _saveLoadImage = NULL; -} - -void BaseRenderer::persistSaveLoadImages(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_loadImageName)); - persistMgr->transfer(TMEMBER(_saveImageName)); - persistMgr->transfer(TMEMBER(_saveImageX)); - persistMgr->transfer(TMEMBER(_saveImageY)); - persistMgr->transfer(TMEMBER(_loadImageX)); - persistMgr->transfer(TMEMBER(_loadImageY)); -} - -////////////////////////////////////////////////////////////////////// -BaseObject *BaseRenderer::getObjectAt(int x, int y) { - Point32 point; - point.x = x; - point.y = y; - - for (int i = _rectList.size() - 1; i >= 0; i--) { - if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { - if (_rectList[i]->_precise) { - // frame - if (_rectList[i]->_frame) { - int xx = (int)((_rectList[i]->_frame->getRect().left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); - int yy = (int)((_rectList[i]->_frame->getRect().top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); - - if (_rectList[i]->_frame->_mirrorX) { - int width = _rectList[i]->_frame->getRect().right - _rectList[i]->_frame->getRect().left; - xx = width - xx; - } - - if (_rectList[i]->_frame->_mirrorY) { - int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().top; - yy = height - yy; - } - - if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) { - return _rectList[i]->_owner; - } - } - // region - else if (_rectList[i]->_region) { - if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) { - return _rectList[i]->_owner; - } - } - } else { - return _rectList[i]->_owner; - } - } - } - - return (BaseObject *)NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRenderer::deleteRectList() { - for (uint32 i = 0; i < _rectList.size(); i++) { - delete _rectList[i]; - } - _rectList.clear(); -} - -////////////////////////////////////////////////////////////////////// -bool BaseRenderer::initRenderer(int width, int height, bool windowed) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////// -void BaseRenderer::onWindowChange() { -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::windowedBlt() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setup2D(bool Force) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setupLines() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { - for (int i = 0; i < width; i++) { - drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up - drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down - - drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left - drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setScreenViewport() { - return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::setViewport(Rect32 *rect) { - return setViewport(rect->left + _drawOffsetX, - rect->top + _drawOffsetY, - rect->right + _drawOffsetX, - rect->bottom + _drawOffsetY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::clipCursor() { - // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) - /* - if (!_windowed) { - Rect32 rc; - GetWindowRect(_window, &rc); - - // if "maintain aspect ratio" is in effect, lock mouse to visible area - rc.left = _drawOffsetX; - rc.top = _drawOffsetY; - rc.right = rc.left + _width; - rc.bottom = rc.top + _height; - - ::ClipCursor(&rc); - } - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::unclipCursor() { - /* - if (!_windowed) ::ClipCursor(NULL); - */ - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::pointInViewport(Point32 *p) { - if (p->x < _drawOffsetX) { - return false; - } - if (p->y < _drawOffsetY) { - return false; - } - if (p->x > _drawOffsetX + _width) { - return false; - } - if (p->y > _drawOffsetY + _height) { - return false; - } - - return true; -} - -void BaseRenderer::addRectToList(BaseActiveRect *rect) { - _rectList.push_back(rect); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderer::displayIndicator() { - if (!_indicatorDisplay || !_indicatorProgress) { - return STATUS_OK; - } - if (_saveLoadImage && !_hasDrawnSaveLoadImage) { - Rect32 rc; - BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); - if (_loadInProgress) { - _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); - } else { - _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); - } - flip(); - _hasDrawnSaveLoadImage = true; - } - - if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { - return STATUS_OK; - } - setupLines(); - int curWidth = (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)); - for (int i = 0; i < _indicatorHeight; i++) { - drawLine(_indicatorX, _indicatorY + i, _indicatorX + curWidth, _indicatorY + i, _indicatorColor); - } - - setup2D(); - _indicatorWidthDrawn = curWidth; - if (_indicatorWidthDrawn) { - indicatorFlip(); - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_active_rect.h" +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/base_sub_frame.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseRenderer::BaseRenderer(BaseGame *inGame) : BaseClass(inGame) { + _window = 0; + _clipperWindow = 0; + _active = false; + _ready = false; + _windowed = true; + _forceAlphaColor = 0x00; + + _indicatorDisplay = false; + _indicatorColor = BYTETORGBA(255, 0, 0, 128); + _indicatorProgress = 0; + _indicatorX = -1; + _indicatorY = -1; + _indicatorWidth = -1; + _indicatorHeight = 8; + _indicatorWidthDrawn = 0; + + _loadImageName = ""; + _saveImageName = ""; + _saveLoadImage = NULL; + _loadInProgress = false; + _hasDrawnSaveLoadImage = false; + + _saveImageX = _saveImageY = 0; + _loadImageX = _loadImageY = 0; + + _width = _height = _bPP = 0; + BasePlatform::setRectEmpty(&_monitorRect); + + _realWidth = _realHeight = 0; + _drawOffsetX = _drawOffsetY = 0; +} + + +////////////////////////////////////////////////////////////////////// +BaseRenderer::~BaseRenderer() { + deleteRectList(); + unclipCursor(); + delete _saveLoadImage; +} + + +////////////////////////////////////////////////////////////////////// +void BaseRenderer::initLoop() { + deleteRectList(); +} + +void BaseRenderer::initIndicator() { + if (_indicatorY == -1) { + _indicatorY = _height - _indicatorHeight; + } + if (_indicatorX == -1) { + _indicatorX = 0; + } + if (_indicatorWidth == -1) { + _indicatorWidth = _width; + } +} + +void BaseRenderer::setIndicator(int width, int height, int x, int y, uint32 color) { + _indicatorWidth = width; + _indicatorHeight = height; + _indicatorX = x; + _indicatorY = y; + _indicatorColor = color; +} + +void BaseRenderer::setIndicatorVal(int value) { + bool redisplay = (_indicatorProgress != value); + _indicatorProgress = value; + if (redisplay) + displayIndicator(); +} + +void BaseRenderer::setLoadingScreen(const char *filename, int x, int y) { + // TODO: Handle NULL + _loadImageName = filename; + _loadImageX = x; + _loadImageY = y; +} + +void BaseRenderer::setSaveImage(const char *filename, int x, int y) { + // TODO: Handle NULL + _saveImageName = filename; + _saveImageX = x; + _saveImageY = y; +} + +void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { + _indicatorDisplay = true; + _indicatorProgress = 0; + _hasDrawnSaveLoadImage = false; + + if (isSaving && !quickSave) { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_saveImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + } else { + delete _saveLoadImage; + _saveLoadImage = NULL; + if (_loadImageName.size()) { + _saveLoadImage = createSurface(); + + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { + delete _saveLoadImage; + _saveLoadImage = NULL; + } + } + _loadInProgress = true; + } +} + +void BaseRenderer::endSaveLoad() { + _loadInProgress = false; + _indicatorDisplay = false; + _indicatorWidthDrawn = 0; + + delete _saveLoadImage; + _saveLoadImage = NULL; +} + +void BaseRenderer::persistSaveLoadImages(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_loadImageName)); + persistMgr->transfer(TMEMBER(_saveImageName)); + persistMgr->transfer(TMEMBER(_saveImageX)); + persistMgr->transfer(TMEMBER(_saveImageY)); + persistMgr->transfer(TMEMBER(_loadImageX)); + persistMgr->transfer(TMEMBER(_loadImageY)); +} + +////////////////////////////////////////////////////////////////////// +BaseObject *BaseRenderer::getObjectAt(int x, int y) { + Point32 point; + point.x = x; + point.y = y; + + for (int i = _rectList.size() - 1; i >= 0; i--) { + if (BasePlatform::ptInRect(&_rectList[i]->_rect, point)) { + if (_rectList[i]->_precise) { + // frame + if (_rectList[i]->_frame) { + int xx = (int)((_rectList[i]->_frame->getRect().left + x - _rectList[i]->_rect.left + _rectList[i]->_offsetX) / (float)((float)_rectList[i]->_zoomX / (float)100)); + int yy = (int)((_rectList[i]->_frame->getRect().top + y - _rectList[i]->_rect.top + _rectList[i]->_offsetY) / (float)((float)_rectList[i]->_zoomY / (float)100)); + + if (_rectList[i]->_frame->_mirrorX) { + int width = _rectList[i]->_frame->getRect().right - _rectList[i]->_frame->getRect().left; + xx = width - xx; + } + + if (_rectList[i]->_frame->_mirrorY) { + int height = _rectList[i]->_frame->getRect().bottom - _rectList[i]->_frame->getRect().top; + yy = height - yy; + } + + if (!_rectList[i]->_frame->_surface->isTransparentAt(xx, yy)) { + return _rectList[i]->_owner; + } + } + // region + else if (_rectList[i]->_region) { + if (_rectList[i]->_region->pointInRegion(x + _rectList[i]->_offsetX, y + _rectList[i]->_offsetY)) { + return _rectList[i]->_owner; + } + } + } else { + return _rectList[i]->_owner; + } + } + } + + return (BaseObject *)NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRenderer::deleteRectList() { + for (uint32 i = 0; i < _rectList.size(); i++) { + delete _rectList[i]; + } + _rectList.clear(); +} + +////////////////////////////////////////////////////////////////////// +bool BaseRenderer::initRenderer(int width, int height, bool windowed) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////// +void BaseRenderer::onWindowChange() { +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::windowedBlt() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setup2D(bool Force) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setupLines() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::drawRect(int x1, int y1, int x2, int y2, uint32 color, int width) { + for (int i = 0; i < width; i++) { + drawLine(x1 + i, y1 + i, x2 - i, y1 + i, color); // up + drawLine(x1 + i, y2 - i, x2 - i + 1, y2 - i, color); // down + + drawLine(x1 + i, y1 + i, x1 + i, y2 - i, color); // left + drawLine(x2 - i, y1 + i, x2 - i, y2 - i + 1, color); // right + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setViewport(int left, int top, int right, int bottom) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setScreenViewport() { + return setViewport(_drawOffsetX, _drawOffsetY, _width + _drawOffsetX, _height + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::setViewport(Rect32 *rect) { + return setViewport(rect->left + _drawOffsetX, + rect->top + _drawOffsetY, + rect->right + _drawOffsetX, + rect->bottom + _drawOffsetY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::clipCursor() { + // TODO: Reimplement this. (Currently aspect-indpendence isn't quite finished) + /* + if (!_windowed) { + Rect32 rc; + GetWindowRect(_window, &rc); + + // if "maintain aspect ratio" is in effect, lock mouse to visible area + rc.left = _drawOffsetX; + rc.top = _drawOffsetY; + rc.right = rc.left + _width; + rc.bottom = rc.top + _height; + + ::ClipCursor(&rc); + } + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::unclipCursor() { + /* + if (!_windowed) ::ClipCursor(NULL); + */ + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::pointInViewport(Point32 *p) { + if (p->x < _drawOffsetX) { + return false; + } + if (p->y < _drawOffsetY) { + return false; + } + if (p->x > _drawOffsetX + _width) { + return false; + } + if (p->y > _drawOffsetY + _height) { + return false; + } + + return true; +} + +void BaseRenderer::addRectToList(BaseActiveRect *rect) { + _rectList.push_back(rect); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderer::displayIndicator() { + if (!_indicatorDisplay || !_indicatorProgress) { + return STATUS_OK; + } + if (_saveLoadImage && !_hasDrawnSaveLoadImage) { + Rect32 rc; + BasePlatform::setRect(&rc, 0, 0, _saveLoadImage->getWidth(), _saveLoadImage->getHeight()); + if (_loadInProgress) { + _saveLoadImage->displayTrans(_loadImageX, _loadImageY, rc); + } else { + _saveLoadImage->displayTrans(_saveImageX, _saveImageY, rc); + } + flip(); + _hasDrawnSaveLoadImage = true; + } + + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { + return STATUS_OK; + } + setupLines(); + int curWidth = (int)(_indicatorWidth * (float)((float)_indicatorProgress / 100.0f)); + for (int i = 0; i < _indicatorHeight; i++) { + drawLine(_indicatorX, _indicatorY + i, _indicatorX + curWidth, _indicatorY + i, _indicatorColor); + } + + setup2D(); + _indicatorWidthDrawn = curWidth; + if (_indicatorWidthDrawn) { + indicatorFlip(); + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_renderer.h b/engines/wintermute/base/gfx/base_renderer.h index 0ff4e6a3be..0475824464 100644 --- a/engines/wintermute/base/gfx/base_renderer.h +++ b/engines/wintermute/base/gfx/base_renderer.h @@ -1,221 +1,221 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_RENDERER_H -#define WINTERMUTE_BASE_RENDERER_H - -#include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/base/base.h" -#include "common/rect.h" -#include "common/array.h" - -namespace Wintermute { - -class BaseImage; -class BaseActiveRect; -class BaseObject; -class BaseSurface; -class BasePersistenceManager; - -/** - * @class BaseRenderer a common interface for the rendering portion of WME - * this interface is mainly intended to wrap away any differencies between - * software-rendering/hardware-rendering. - */ -class BaseRenderer: public BaseClass { -public: - int _realWidth; - int _realHeight; - int _drawOffsetX; - int _drawOffsetY; - - virtual void dumpData(const char *filename) {} - /** - * Take a screenshot of the current screenstate - * - * @return a BaseImage containing the current screen-buffer. - */ - virtual BaseImage *takeScreenshot() = 0; - virtual bool setViewport(int left, int top, int right, int bottom); - virtual bool setViewport(Rect32 *rect); - virtual Rect32 getViewPort() = 0; - virtual bool setScreenViewport(); - - virtual Graphics::PixelFormat getPixelFormat() const = 0; - /** - * Fade the screen to black - * - * @param alpha amount to fade by (alpha value of black) - * @return - */ - virtual void fade(uint16 alpha) = 0; - /** - * Fade a portion of the screen to a specific color - * - * @param r the red component to fade too. - * @param g the green component to fade too. - * @param b the blue component to fade too. - * @param a the alpha component to fade too. - * @param rect the portion of the screen to fade (if NULL, the entire screen will be faded). - */ - virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL) = 0; - virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); - BaseRenderer(BaseGame *inGame = NULL); - virtual ~BaseRenderer(); - virtual bool setProjection() { - return STATUS_OK; - }; - - virtual bool windowedBlt(); - /** - * Fill a portion of the screen with a specified color - * - * @param r the red component to fill with. - * @param g the green component to fill with. - * @param b the blue component to fill with. - */ - virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL) = 0; - virtual void onWindowChange(); - virtual bool initRenderer(int width, int height, bool windowed); - /** - * Flip the backbuffer onto the screen-buffer - * The screen will NOT be updated before calling this function. - * - * @return true if successfull, false on error. - */ - virtual bool flip() = 0; - /** - * Special flip for the indicator drawn during save/load - * essentially, just copies the region defined by the _indicator-variables. - */ - virtual bool indicatorFlip() = 0; - virtual void initLoop(); - virtual bool setup2D(bool force = false); - virtual bool setupLines(); - - /** - * Get the name of the current renderer - * - * @return the name of the renderer. - */ - virtual Common::String getName() const = 0; - virtual bool displayDebugInfo() { - return STATUS_FAILED; - }; - virtual bool drawShaderQuad() { - return STATUS_FAILED; - } - - virtual float getScaleRatioX() const { - return 1.0f; - } - virtual float getScaleRatioY() const { - return 1.0f; - } - - /** - * Create a Surface fit for use with the renderer. - * As diverse implementations of BaseRenderer might have different solutions for storing surfaces - * this allows for a common interface for creating surface-handles. (Mostly usefull to ease future - * implementation of hw-accelerated rendering, or readding 3D-support at some point). - * - * @return a surface that can be used with this renderer - */ - virtual BaseSurface *createSurface() = 0; - - bool clipCursor(); - bool unclipCursor(); - - BaseObject *getObjectAt(int x, int y); - void deleteRectList(); - - virtual bool startSpriteBatch() { - return STATUS_OK; - }; - virtual bool endSpriteBatch() { - return STATUS_OK; - }; - bool pointInViewport(Point32 *P); - bool _active; - bool _ready; - bool _windowed; - int _bPP; - int _height; - int _width; - uint32 _window; - uint32 _forceAlphaColor; - - void addRectToList(BaseActiveRect *rect); - - // Indicator & Save/Load-related functions - void initIndicator(); - void setIndicatorVal(int value); - void setIndicator(int width, int height, int x, int y, uint32 color); - void persistSaveLoadImages(BasePersistenceManager *persistMgr); - void initSaveLoad(bool isSaving, bool quickSave = false); - void endSaveLoad(); - void setLoadingScreen(const char *filename, int x, int y); - void setSaveImage(const char *filename, int x, int y); - - bool displayIndicator(); -protected: - Common::String _loadImageName; - Common::String _saveImageName; - int _saveImageX; - int _saveImageY; - int _loadImageX; - int _loadImageY; - BaseSurface *_saveLoadImage; - bool _hasDrawnSaveLoadImage; - - int _indicatorWidthDrawn; - uint32 _indicatorColor; - int _indicatorX; - int _indicatorY; - int _indicatorWidth; - int _indicatorHeight; - bool _loadInProgress; - bool _indicatorDisplay; - int _indicatorProgress; -protected: - uint32 _clipperWindow; - - Rect32 _windowRect; - Rect32 _viewportRect; - Rect32 _screenRect; - Rect32 _monitorRect; -private: - Common::Array _rectList; -}; - -BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RENDERER_H +#define WINTERMUTE_BASE_RENDERER_H + +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/base/base.h" +#include "common/rect.h" +#include "common/array.h" + +namespace Wintermute { + +class BaseImage; +class BaseActiveRect; +class BaseObject; +class BaseSurface; +class BasePersistenceManager; + +/** + * @class BaseRenderer a common interface for the rendering portion of WME + * this interface is mainly intended to wrap away any differencies between + * software-rendering/hardware-rendering. + */ +class BaseRenderer: public BaseClass { +public: + int _realWidth; + int _realHeight; + int _drawOffsetX; + int _drawOffsetY; + + virtual void dumpData(const char *filename) {} + /** + * Take a screenshot of the current screenstate + * + * @return a BaseImage containing the current screen-buffer. + */ + virtual BaseImage *takeScreenshot() = 0; + virtual bool setViewport(int left, int top, int right, int bottom); + virtual bool setViewport(Rect32 *rect); + virtual Rect32 getViewPort() = 0; + virtual bool setScreenViewport(); + + virtual Graphics::PixelFormat getPixelFormat() const = 0; + /** + * Fade the screen to black + * + * @param alpha amount to fade by (alpha value of black) + * @return + */ + virtual void fade(uint16 alpha) = 0; + /** + * Fade a portion of the screen to a specific color + * + * @param r the red component to fade too. + * @param g the green component to fade too. + * @param b the blue component to fade too. + * @param a the alpha component to fade too. + * @param rect the portion of the screen to fade (if NULL, the entire screen will be faded). + */ + virtual void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL) = 0; + virtual bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + virtual bool drawRect(int x1, int y1, int x2, int y2, uint32 color, int width = 1); + BaseRenderer(BaseGame *inGame = NULL); + virtual ~BaseRenderer(); + virtual bool setProjection() { + return STATUS_OK; + }; + + virtual bool windowedBlt(); + /** + * Fill a portion of the screen with a specified color + * + * @param r the red component to fill with. + * @param g the green component to fill with. + * @param b the blue component to fill with. + */ + virtual bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL) = 0; + virtual void onWindowChange(); + virtual bool initRenderer(int width, int height, bool windowed); + /** + * Flip the backbuffer onto the screen-buffer + * The screen will NOT be updated before calling this function. + * + * @return true if successfull, false on error. + */ + virtual bool flip() = 0; + /** + * Special flip for the indicator drawn during save/load + * essentially, just copies the region defined by the _indicator-variables. + */ + virtual bool indicatorFlip() = 0; + virtual void initLoop(); + virtual bool setup2D(bool force = false); + virtual bool setupLines(); + + /** + * Get the name of the current renderer + * + * @return the name of the renderer. + */ + virtual Common::String getName() const = 0; + virtual bool displayDebugInfo() { + return STATUS_FAILED; + }; + virtual bool drawShaderQuad() { + return STATUS_FAILED; + } + + virtual float getScaleRatioX() const { + return 1.0f; + } + virtual float getScaleRatioY() const { + return 1.0f; + } + + /** + * Create a Surface fit for use with the renderer. + * As diverse implementations of BaseRenderer might have different solutions for storing surfaces + * this allows for a common interface for creating surface-handles. (Mostly usefull to ease future + * implementation of hw-accelerated rendering, or readding 3D-support at some point). + * + * @return a surface that can be used with this renderer + */ + virtual BaseSurface *createSurface() = 0; + + bool clipCursor(); + bool unclipCursor(); + + BaseObject *getObjectAt(int x, int y); + void deleteRectList(); + + virtual bool startSpriteBatch() { + return STATUS_OK; + }; + virtual bool endSpriteBatch() { + return STATUS_OK; + }; + bool pointInViewport(Point32 *P); + bool _active; + bool _ready; + bool _windowed; + int _bPP; + int _height; + int _width; + uint32 _window; + uint32 _forceAlphaColor; + + void addRectToList(BaseActiveRect *rect); + + // Indicator & Save/Load-related functions + void initIndicator(); + void setIndicatorVal(int value); + void setIndicator(int width, int height, int x, int y, uint32 color); + void persistSaveLoadImages(BasePersistenceManager *persistMgr); + void initSaveLoad(bool isSaving, bool quickSave = false); + void endSaveLoad(); + void setLoadingScreen(const char *filename, int x, int y); + void setSaveImage(const char *filename, int x, int y); + + bool displayIndicator(); +protected: + Common::String _loadImageName; + Common::String _saveImageName; + int _saveImageX; + int _saveImageY; + int _loadImageX; + int _loadImageY; + BaseSurface *_saveLoadImage; + bool _hasDrawnSaveLoadImage; + + int _indicatorWidthDrawn; + uint32 _indicatorColor; + int _indicatorX; + int _indicatorY; + int _indicatorWidth; + int _indicatorHeight; + bool _loadInProgress; + bool _indicatorDisplay; + int _indicatorProgress; +protected: + uint32 _clipperWindow; + + Rect32 _windowRect; + Rect32 _viewportRect; + Rect32 _screenRect; + Rect32 _monitorRect; +private: + Common::Array _rectList; +}; + +BaseRenderer *makeOSystemRenderer(BaseGame *inGame); // Implemented in BRenderSDL.cpp + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/base_surface.cpp b/engines/wintermute/base/gfx/base_surface.cpp index cbd665591a..d882adf5ad 100644 --- a/engines/wintermute/base/gfx/base_surface.cpp +++ b/engines/wintermute/base/gfx/base_surface.cpp @@ -1,149 +1,149 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/wintypes.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/gfx/base_surface.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { - _referenceCount = 0; - - _width = _height = 0; - - _filename = ""; - - _pixelOpReady = false; - - _ckDefault = true; - _ckRed = _ckGreen = _ckBlue = 0; - _lifeTime = 0; - _keepLoaded = false; - - _lastUsedTime = 0; - _valid = false; -} - - -////////////////////////////////////////////////////////////////////// -BaseSurface::~BaseSurface() { - if (_pixelOpReady) { - endPixelOp(); - } -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::restore() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::isTransparentAt(int x, int y) { - return false; -} - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::create(int width, int height) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::startPixelOp() { - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::endPixelOp() { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { - return false; -} - - -////////////////////////////////////////////////////////////////////// -bool BaseSurface::isTransparentAtLite(int x, int y) { - return false; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::invalidate() { - return STATUS_FAILED; -} - - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurface::prepareToDraw() { - _lastUsedTime = _gameRef->_liveTimer; - - if (!_valid) { - //_gameRef->LOG(0, "Reviving: %s", _filename); - return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); - } else { - return STATUS_OK; - } -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSurface::setSize(int width, int height) { - _width = width; - _height = height; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/wintypes.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/gfx/base_surface.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +BaseSurface::BaseSurface(BaseGame *inGame) : BaseClass(inGame) { + _referenceCount = 0; + + _width = _height = 0; + + _filename = ""; + + _pixelOpReady = false; + + _ckDefault = true; + _ckRed = _ckGreen = _ckBlue = 0; + _lifeTime = 0; + _keepLoaded = false; + + _lastUsedTime = 0; + _valid = false; +} + + +////////////////////////////////////////////////////////////////////// +BaseSurface::~BaseSurface() { + if (_pixelOpReady) { + endPixelOp(); + } +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::restore() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::isTransparentAt(int x, int y) { + return false; +} + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::displayHalfTrans(int x, int y, Rect32 rect) { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return displayTransZoom(x, y, rect, zoomX, zoomY, alpha, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::create(int width, int height) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::startPixelOp() { + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::endPixelOp() { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::putPixel(int x, int y, byte r, byte g, byte b, int a) { + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::comparePixel(int x, int y, byte r, byte g, byte b, int a) { + return false; +} + + +////////////////////////////////////////////////////////////////////// +bool BaseSurface::isTransparentAtLite(int x, int y) { + return false; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::invalidate() { + return STATUS_FAILED; +} + + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurface::prepareToDraw() { + _lastUsedTime = _gameRef->_liveTimer; + + if (!_valid) { + //_gameRef->LOG(0, "Reviving: %s", _filename); + return create(_filename.c_str(), _ckDefault, _ckRed, _ckGreen, _ckBlue, _lifeTime, _keepLoaded); + } else { + return STATUS_OK; + } +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSurface::setSize(int width, int height) { + _width = width; + _height = height; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/base_surface.h b/engines/wintermute/base/gfx/base_surface.h index f45856f652..ee53c03e77 100644 --- a/engines/wintermute/base/gfx/base_surface.h +++ b/engines/wintermute/base/gfx/base_surface.h @@ -1,99 +1,99 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SURFACE_H -#define WINTERMUTE_BASE_SURFACE_H - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/math/rect32.h" -#include "graphics/surface.h" - -namespace Wintermute { - -class BaseSurface: public BaseClass { -public: - virtual bool invalidate(); - virtual bool prepareToDraw(); - uint32 _lastUsedTime; - bool _valid; - int _lifeTime; - - bool _pixelOpReady; - BaseSurface(BaseGame *inGame); - virtual ~BaseSurface(); - - virtual bool displayHalfTrans(int x, int y, Rect32 rect); - virtual bool isTransparentAt(int x, int y); - virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; - virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; - virtual bool restore(); - virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; - virtual bool create(int width, int height); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { - return STATUS_FAILED; - } - virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); - virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); - virtual bool startPixelOp(); - virtual bool endPixelOp(); - virtual bool isTransparentAtLite(int x, int y); - void setSize(int width, int height); - - int _referenceCount; - - virtual int getWidth() { - return _width; - } - virtual int getHeight() { - return _height; - } - Common::String getFileNameStr() { return _filename; } - const char* getFileName() { return _filename.c_str(); } - //void SetWidth(int Width){ _width = Width; } - //void SetHeight(int Height){ _height = Height; } -protected: - bool _ckDefault; - byte _ckRed; - byte _ckGreen; - byte _ckBlue; - - bool _keepLoaded; - Common::String _filename; - int _height; - int _width; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACE_H +#define WINTERMUTE_BASE_SURFACE_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "graphics/surface.h" + +namespace Wintermute { + +class BaseSurface: public BaseClass { +public: + virtual bool invalidate(); + virtual bool prepareToDraw(); + uint32 _lastUsedTime; + bool _valid; + int _lifeTime; + + bool _pixelOpReady; + BaseSurface(BaseGame *inGame); + virtual ~BaseSurface(); + + virtual bool displayHalfTrans(int x, int y, Rect32 rect); + virtual bool isTransparentAt(int x, int y); + virtual bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0) = 0; + virtual bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false) = 0; + virtual bool restore(); + virtual bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false) = 0; + virtual bool create(int width, int height); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false) { + return STATUS_FAILED; + } + virtual bool putPixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool getPixel(int x, int y, byte *r, byte *g, byte *b, byte *a = NULL); + virtual bool comparePixel(int x, int y, byte r, byte g, byte b, int a = -1); + virtual bool startPixelOp(); + virtual bool endPixelOp(); + virtual bool isTransparentAtLite(int x, int y); + void setSize(int width, int height); + + int _referenceCount; + + virtual int getWidth() { + return _width; + } + virtual int getHeight() { + return _height; + } + Common::String getFileNameStr() { return _filename; } + const char* getFileName() { return _filename.c_str(); } + //void SetWidth(int Width){ _width = Width; } + //void SetHeight(int Height){ _height = Height; } +protected: + bool _ckDefault; + byte _ckRed; + byte _ckGreen; + byte _ckBlue; + + bool _keepLoaded; + Common::String _filename; + int _height; + int _width; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 7a862e4441..6d67253038 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -1,604 +1,604 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/base/base_surface_storage.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/math/math_util.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_sprite.h" -#include "common/system.h" -#include "engines/wintermute/graphics/transparent_surface.h" -#include "common/queue.h" -#include "common/config-manager.h" - -namespace Wintermute { - -RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), - _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { - _colorMod = 0; - _mirror = TransparentSurface::FLIP_NONE; - if (mirrorX) { - _mirror |= TransparentSurface::FLIP_V; - } - if (mirrorY) { - _mirror |= TransparentSurface::FLIP_H; - } - if (surf) { - _surface = new Graphics::Surface(); - _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); - assert(_surface->format.bytesPerPixel == 4); - // Get a clipped copy of the surface - for (int i = 0; i < _surface->h; i++) { - memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); - } - // Then scale it if necessary - if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { - TransparentSurface src(*_surface, false); - Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); - _surface->free(); - delete _surface; - _surface = temp; - } - } else { - _surface = NULL; - } -} - -RenderTicket::~RenderTicket() { - if (_surface) { - _surface->free(); - delete _surface; - } -} - -bool RenderTicket::operator==(RenderTicket &t) { - if ((t._srcRect != _srcRect) || - (t._dstRect != _dstRect) || - (t._mirror != _mirror) || - (t._owner != _owner) || - (t._hasAlpha != _hasAlpha) || - (t._colorMod != _colorMod)) { - return false; - } - return true; -} - -BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { - return new BaseRenderOSystem(inGame); -} - -////////////////////////////////////////////////////////////////////////// -BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { - _renderSurface = new Graphics::Surface(); - _blankSurface = new Graphics::Surface(); - _drawNum = 1; - _needsFlip = true; - - _borderLeft = _borderRight = _borderTop = _borderBottom = 0; - _ratioX = _ratioY = 1.0f; - setAlphaMod(255); - setColorMod(255, 255, 255); - _dirtyRect = NULL; -} - -////////////////////////////////////////////////////////////////////////// -BaseRenderOSystem::~BaseRenderOSystem() { - _renderSurface->free(); - delete _renderSurface; - _blankSurface->free(); - delete _blankSurface; - TransparentSurface::destroyLookup(); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { - _width = width; - _height = height; - _renderRect.setWidth(_width); - _renderRect.setHeight(_height); - - _realWidth = width; - _realHeight = height; - - //TODO: Tiny resolution-displays might want to do some resolution-selection logic here - - //_realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); - //_realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); - - float origAspect = (float)_width / (float)_height; - float realAspect = (float)_realWidth / (float)_realHeight; - - float ratio; - if (origAspect < realAspect) { - // normal to wide - ratio = (float)_realHeight / (float)_height; - } else { - // wide to normal - ratio = (float)_realWidth / (float)_width; - } - - _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); - _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); - - _borderTop = (int)((_realHeight - (_height * ratio)) / 2); - _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); - - - - _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; - _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; - - _windowed = !ConfMan.getBool("fullscreen"); - - Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); - g_system->beginGFXTransaction(); - g_system->initSize(_width, _height, &format); - OSystem::TransactionError gfxError = g_system->endGFXTransaction(); - - if (gfxError != OSystem::kTransactionSuccess) { - warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); - return STATUS_FAILED; - } - - g_system->showMouse(false); - - _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); - _blankSurface->fillRect(Common::Rect(0, 0, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); - _active = true; - - _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); - - return STATUS_OK; -} - -void BaseRenderOSystem::setAlphaMod(byte alpha) { - byte r = RGBCOLGetR(_colorMod); - byte g = RGBCOLGetB(_colorMod); - byte b = RGBCOLGetB(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { - byte alpha = RGBCOLGetA(_colorMod); - _colorMod = BS_ARGB(alpha, r, g, b); -} - -bool BaseRenderOSystem::indicatorFlip() { - g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_indicatorX, _indicatorY), _renderSurface->pitch, _indicatorX, _indicatorY, _indicatorWidthDrawn, _indicatorHeight); - g_system->updateScreen(); - return STATUS_OK; -} - -bool BaseRenderOSystem::flip() { - if (!_disableDirtyRects) { - drawTickets(); - } else { - // Clear the scale-buffered tickets that wasn't reused. - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it)->_wantsDraw == false) { - RenderTicket *ticket = *it; - it = _renderQueue.erase(it); - delete ticket; - } else { - (*it)->_wantsDraw = false; - ++it; - } - } - } - if (_needsFlip || _disableDirtyRects) { - if (_disableDirtyRects) { - g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); - } - // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - delete _dirtyRect; - _dirtyRect = NULL; - g_system->updateScreen(); - _needsFlip = false; - } - _drawNum = 1; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { - _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); - if (!_disableDirtyRects) { - return STATUS_OK; - } - if (!rect) { -// TODO: This should speed things up, but for some reason it misses the size by quite a bit. -/* if (r == 0 && g == 0 && b == 0) { - // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. - memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); - return STATUS_OK; - }*/ - rect = &_renderRect; - } - // TODO: This doesn't work with dirty rects - _renderSurface->fillRect(*rect, _clearColor); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::fade(uint16 alpha) { - byte dwAlpha = (byte)(255 - alpha); - return fadeToColor(0, 0, 0, dwAlpha); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { - // This particular warning is rather messy, as this function is called a ton, - // thus we avoid printing it more than once. - - // TODO: Add fading with dirty rects. - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); - } - - Common::Rect fillRect; - - if (rect) { - fillRect.left = rect->left; - fillRect.top = rect->top; - fillRect.setWidth(rect->width()); - fillRect.setHeight(rect->height()); - } else { - Rect32 rc; - _gameRef->getCurrentViewportRect(&rc); - fillRect.left = (int16)rc.left; - fillRect.top = (int16)rc.top; - fillRect.setWidth((int16)(rc.right - rc.left)); - fillRect.setHeight((int16)(rc.bottom - rc.top)); - } - modTargetRect(&fillRect); - - //TODO: This is only here until I'm sure about the final pixelformat - uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); - - setAlphaMod(255); - setColorMod(255, 255, 255); - Graphics::Surface surf; - surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); - Common::Rect sizeRect(fillRect); - sizeRect.translate(-fillRect.top, -fillRect.left); - surf.fillRect(fillRect, col); - drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); - surf.free(); - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - //SDL_RenderFillRect(_renderer, &fillRect); -} - -Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { - return _renderSurface->format; -} - -void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { - // Skip rects that are completely outside the screen: - if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { - return; - } - - if (owner) { // Fade-tickets are owner-less - RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - compare._colorMod = _colorMod; - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { - if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { - (*it)->_colorMod = _colorMod; - if (_disableDirtyRects) { - drawFromSurface(*it, NULL); - } else { - drawFromTicket(*it); - } - return; - } - } - } - RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); - ticket->_colorMod = _colorMod; - if (!_disableDirtyRects) { - drawFromTicket(ticket); - } else { - ticket->_wantsDraw = true; - _renderQueue.push_back(ticket); - drawFromSurface(ticket, NULL); - } -} - -void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { - addDirtyRect(renderTicket->_dstRect); - renderTicket->_isValid = false; -// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. -} - -void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { - RenderQueueIterator it; - for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { - if ((*it)->_owner == surf) { - invalidateTicket(*it); - } - } -} - -void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { - renderTicket->_wantsDraw = true; - // A new item always has _drawNum == 0 - if (renderTicket->_drawNum == 0) { - // In-order - if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { - renderTicket->_drawNum = _drawNum++; - _renderQueue.push_back(renderTicket); - addDirtyRect(renderTicket->_dstRect); - } else { - // Before something - Common::List::iterator pos; - for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { - if ((*pos)->_drawNum >= _drawNum) { - break; - } - } - _renderQueue.insert(pos, renderTicket); - Common::List::iterator it; - renderTicket->_drawNum = _drawNum++; - // Increment the following tickets, so they still are in line - for (it = pos; it != _renderQueue.end(); ++it) { - (*it)->_drawNum++; - (*it)->_wantsDraw = false; - } - addDirtyRect(renderTicket->_dstRect); - } - } else { - // Was drawn last round, still in the same order - if (_drawNum == renderTicket->_drawNum) { - _drawNum++; - } else { - // Remove the ticket from the list - RenderQueueIterator it = _renderQueue.begin(); - while (it != _renderQueue.end()) { - if ((*it) == renderTicket) { - it = _renderQueue.erase(it); - break; - } else { - ++it; - } - } - if (it != _renderQueue.end()) { - // Decreement the following tickets. - for (; it != _renderQueue.end(); ++it) { - (*it)->_drawNum--; - } - } - // Is not in order, so readd it as if it was a new ticket - renderTicket->_drawNum = 0; - drawFromTicket(renderTicket); - } - } -} - -void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { - if (!_dirtyRect) { - _dirtyRect = new Common::Rect(rect); - } else { - _dirtyRect->extend(rect); - } - _dirtyRect->clip(_renderRect); -} - -void BaseRenderOSystem::drawTickets() { - RenderQueueIterator it = _renderQueue.begin(); - // Clean out the old tickets - int decrement = 0; - while (it != _renderQueue.end()) { - if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { - RenderTicket *ticket = *it; - addDirtyRect((*it)->_dstRect); - it = _renderQueue.erase(it); - delete ticket; - decrement++; - } else { - (*it)->_drawNum -= decrement; - ++it; - } - } - if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { - return; - } - // The color-mods are stored in the RenderTickets on add, since we set that state again during - // draw, we need to keep track of what it was prior to draw. - uint32 oldColorMod = _colorMod; - - // Apply the clear-color to the dirty rect. - _renderSurface->fillRect(*_dirtyRect, _clearColor); - _drawNum = 1; - for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { - RenderTicket *ticket = *it; - assert(ticket->_drawNum == _drawNum++); - if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { - // dstClip is the area we want redrawn. - Common::Rect dstClip(ticket->_dstRect); - // reduce it to the dirty rect - dstClip.clip(*_dirtyRect); - // we need to keep track of the position to redraw the dirty rect - Common::Rect pos(dstClip); - int16 offsetX = ticket->_dstRect.left; - int16 offsetY = ticket->_dstRect.top; - // convert from screen-coords to surface-coords. - dstClip.translate(-offsetX, -offsetY); - - _colorMod = ticket->_colorMod; - drawFromSurface(ticket->getSurface(), &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); - _needsFlip = true; - } - // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) - ticket->_wantsDraw = false; - } - g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); - - // Revert the colorMod-state. - _colorMod = oldColorMod; -} - -// Replacement for SDL2's SDL_RenderCopy -void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect) { - TransparentSurface src(*ticket->getSurface(), false); - bool doDelete = false; - if (!clipRect) { - doDelete = true; - clipRect = new Common::Rect(); - clipRect->setWidth(ticket->getSurface()->w); - clipRect->setHeight(ticket->getSurface()->h); - } - - src._enableAlphaBlit = ticket->_hasAlpha; - src.blit(*_renderSurface, ticket->_dstRect.left, ticket->_dstRect.top, ticket->_mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) { - delete clipRect; - } -} -void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { - TransparentSurface src(*surf, false); - bool doDelete = false; - if (!clipRect) { - doDelete = true; - clipRect = new Common::Rect(); - clipRect->setWidth(surf->w); - clipRect->setHeight(surf->h); - } - - src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); - if (doDelete) { - delete clipRect; - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { - - if (!_disableDirtyRects) { - warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); - } - - byte r = RGBCOLGetR(color); - byte g = RGBCOLGetG(color); - byte b = RGBCOLGetB(color); - byte a = RGBCOLGetA(color); - - //SDL_SetRenderDrawColor(_renderer, r, g, b, a); - //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); - - Point32 point1, point2; - point1.x = x1; - point1.y = y1; - pointToScreen(&point1); - - point2.x = x2; - point2.y = y2; - pointToScreen(&point2); - - // TODO: This thing is mostly here until I'm sure about the final color-format. - uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); - _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); - //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -BaseImage *BaseRenderOSystem::takeScreenshot() { -// TODO: Clip by viewport. - BaseImage *screenshot = new BaseImage(); - screenshot->copyFrom(_renderSurface); - return screenshot; -} - -////////////////////////////////////////////////////////////////////////// -Common::String BaseRenderOSystem::getName() const { - return "ScummVM-OSystem-renderer"; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { - Common::Rect rect; - // TODO: Hopefully this is the same logic that ScummVM uses. - rect.left = (int16)(left + _borderLeft); - rect.top = (int16)(top + _borderTop); - rect.right = (int16)((right - left) * _ratioX); - rect.bottom = (int16)((bottom - top) * _ratioY); - - _renderRect = rect; - return STATUS_OK; -} - -Rect32 BaseRenderOSystem::getViewPort() { - Rect32 ret; - ret.top = _renderRect.top; - ret.bottom = _renderRect.bottom; - ret.left = _renderRect.left; - ret.right = _renderRect.right; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { - rect->left = (int16)MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); - rect->top = (int16)MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); - rect->setWidth((int16)MathUtil::roundUp(rect->width() * _ratioX)); - rect->setHeight((int16)MathUtil::roundUp(rect->height() * _ratioY)); -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::pointFromScreen(Point32 *point) { - point->x = (int16)(point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left); - point->y = (int16)(point->y / _ratioY - _borderTop / _ratioY + _renderRect.top); -} - - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::pointToScreen(Point32 *point) { - point->x = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; - point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; -} - -////////////////////////////////////////////////////////////////////////// -void BaseRenderOSystem::dumpData(const char *filename) { - warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO -} - -BaseSurface *BaseRenderOSystem::createSurface() { - return new BaseSurfaceOSystem(_gameRef); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/base_surface_storage.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/math/math_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_sprite.h" +#include "common/system.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#include "common/queue.h" +#include "common/config-manager.h" + +namespace Wintermute { + +RenderTicket::RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) : _owner(owner), + _srcRect(*srcRect), _dstRect(*dstRect), _drawNum(0), _isValid(true), _wantsDraw(true), _hasAlpha(!disableAlpha) { + _colorMod = 0; + _mirror = TransparentSurface::FLIP_NONE; + if (mirrorX) { + _mirror |= TransparentSurface::FLIP_V; + } + if (mirrorY) { + _mirror |= TransparentSurface::FLIP_H; + } + if (surf) { + _surface = new Graphics::Surface(); + _surface->create((uint16)srcRect->width(), (uint16)srcRect->height(), surf->format); + assert(_surface->format.bytesPerPixel == 4); + // Get a clipped copy of the surface + for (int i = 0; i < _surface->h; i++) { + memcpy(_surface->getBasePtr(0, i), surf->getBasePtr(srcRect->left, srcRect->top + i), srcRect->width() * _surface->format.bytesPerPixel); + } + // Then scale it if necessary + if (dstRect->width() != srcRect->width() || dstRect->height() != srcRect->height()) { + TransparentSurface src(*_surface, false); + Graphics::Surface *temp = src.scale(dstRect->width(), dstRect->height()); + _surface->free(); + delete _surface; + _surface = temp; + } + } else { + _surface = NULL; + } +} + +RenderTicket::~RenderTicket() { + if (_surface) { + _surface->free(); + delete _surface; + } +} + +bool RenderTicket::operator==(RenderTicket &t) { + if ((t._srcRect != _srcRect) || + (t._dstRect != _dstRect) || + (t._mirror != _mirror) || + (t._owner != _owner) || + (t._hasAlpha != _hasAlpha) || + (t._colorMod != _colorMod)) { + return false; + } + return true; +} + +BaseRenderer *makeOSystemRenderer(BaseGame *inGame) { + return new BaseRenderOSystem(inGame); +} + +////////////////////////////////////////////////////////////////////////// +BaseRenderOSystem::BaseRenderOSystem(BaseGame *inGame) : BaseRenderer(inGame) { + _renderSurface = new Graphics::Surface(); + _blankSurface = new Graphics::Surface(); + _drawNum = 1; + _needsFlip = true; + + _borderLeft = _borderRight = _borderTop = _borderBottom = 0; + _ratioX = _ratioY = 1.0f; + setAlphaMod(255); + setColorMod(255, 255, 255); + _dirtyRect = NULL; +} + +////////////////////////////////////////////////////////////////////////// +BaseRenderOSystem::~BaseRenderOSystem() { + _renderSurface->free(); + delete _renderSurface; + _blankSurface->free(); + delete _blankSurface; + TransparentSurface::destroyLookup(); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::initRenderer(int width, int height, bool windowed) { + _width = width; + _height = height; + _renderRect.setWidth(_width); + _renderRect.setHeight(_height); + + _realWidth = width; + _realHeight = height; + + //TODO: Tiny resolution-displays might want to do some resolution-selection logic here + + //_realWidth = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResWidth", _width); + //_realHeight = BaseEngine::instance().getRegistry()->readInt("Debug", "ForceResHeight", _height); + + float origAspect = (float)_width / (float)_height; + float realAspect = (float)_realWidth / (float)_realHeight; + + float ratio; + if (origAspect < realAspect) { + // normal to wide + ratio = (float)_realHeight / (float)_height; + } else { + // wide to normal + ratio = (float)_realWidth / (float)_width; + } + + _borderLeft = (int)((_realWidth - (_width * ratio)) / 2); + _borderRight = (int)(_realWidth - (_width * ratio) - _borderLeft); + + _borderTop = (int)((_realHeight - (_height * ratio)) / 2); + _borderBottom = (int)(_realHeight - (_height * ratio) - _borderTop); + + + + _ratioX = (float)(_realWidth - _borderLeft - _borderRight) / (float)_width; + _ratioY = (float)(_realHeight - _borderTop - _borderBottom) / (float)_height; + + _windowed = !ConfMan.getBool("fullscreen"); + + Graphics::PixelFormat format(4, 8, 8, 8, 8, 16, 8, 0, 24); + g_system->beginGFXTransaction(); + g_system->initSize(_width, _height, &format); + OSystem::TransactionError gfxError = g_system->endGFXTransaction(); + + if (gfxError != OSystem::kTransactionSuccess) { + warning("Couldn't setup GFX-backend for %dx%dx%d", _width, _height, format.bytesPerPixel * 8); + return STATUS_FAILED; + } + + g_system->showMouse(false); + + _renderSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->create(g_system->getWidth(), g_system->getHeight(), g_system->getScreenFormat()); + _blankSurface->fillRect(Common::Rect(0, 0, _blankSurface->h, _blankSurface->w), _blankSurface->format.ARGBToColor(255, 0, 0, 0)); + _active = true; + + _clearColor = _renderSurface->format.ARGBToColor(255, 0, 0, 0); + + return STATUS_OK; +} + +void BaseRenderOSystem::setAlphaMod(byte alpha) { + byte r = RGBCOLGetR(_colorMod); + byte g = RGBCOLGetB(_colorMod); + byte b = RGBCOLGetB(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +void BaseRenderOSystem::setColorMod(byte r, byte g, byte b) { + byte alpha = RGBCOLGetA(_colorMod); + _colorMod = BS_ARGB(alpha, r, g, b); +} + +bool BaseRenderOSystem::indicatorFlip() { + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_indicatorX, _indicatorY), _renderSurface->pitch, _indicatorX, _indicatorY, _indicatorWidthDrawn, _indicatorHeight); + g_system->updateScreen(); + return STATUS_OK; +} + +bool BaseRenderOSystem::flip() { + if (!_disableDirtyRects) { + drawTickets(); + } else { + // Clear the scale-buffered tickets that wasn't reused. + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false) { + RenderTicket *ticket = *it; + it = _renderQueue.erase(it); + delete ticket; + } else { + (*it)->_wantsDraw = false; + ++it; + } + } + } + if (_needsFlip || _disableDirtyRects) { + if (_disableDirtyRects) { + g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, 0, 0, _renderSurface->w, _renderSurface->h); + } + // g_system->copyRectToScreen((byte *)_renderSurface->pixels, _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + delete _dirtyRect; + _dirtyRect = NULL; + g_system->updateScreen(); + _needsFlip = false; + } + _drawNum = 1; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::fill(byte r, byte g, byte b, Common::Rect *rect) { + _clearColor = _renderSurface->format.ARGBToColor(0xFF, r, g, b); + if (!_disableDirtyRects) { + return STATUS_OK; + } + if (!rect) { +// TODO: This should speed things up, but for some reason it misses the size by quite a bit. +/* if (r == 0 && g == 0 && b == 0) { + // Simply memcpy from the buffered black-surface, way faster than Surface::fillRect. + memcpy(_renderSurface->pixels, _blankSurface->pixels, _renderSurface->pitch * _renderSurface->h); + return STATUS_OK; + }*/ + rect = &_renderRect; + } + // TODO: This doesn't work with dirty rects + _renderSurface->fillRect(*rect, _clearColor); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::fade(uint16 alpha) { + byte dwAlpha = (byte)(255 - alpha); + return fadeToColor(0, 0, 0, dwAlpha); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { + // This particular warning is rather messy, as this function is called a ton, + // thus we avoid printing it more than once. + + // TODO: Add fading with dirty rects. + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); + } + + Common::Rect fillRect; + + if (rect) { + fillRect.left = rect->left; + fillRect.top = rect->top; + fillRect.setWidth(rect->width()); + fillRect.setHeight(rect->height()); + } else { + Rect32 rc; + _gameRef->getCurrentViewportRect(&rc); + fillRect.left = (int16)rc.left; + fillRect.top = (int16)rc.top; + fillRect.setWidth((int16)(rc.right - rc.left)); + fillRect.setHeight((int16)(rc.bottom - rc.top)); + } + modTargetRect(&fillRect); + + //TODO: This is only here until I'm sure about the final pixelformat + uint32 col = _renderSurface->format.ARGBToColor(a, r, g, b); + + setAlphaMod(255); + setColorMod(255, 255, 255); + Graphics::Surface surf; + surf.create((uint16)fillRect.width(), (uint16)fillRect.height(), _renderSurface->format); + Common::Rect sizeRect(fillRect); + sizeRect.translate(-fillRect.top, -fillRect.left); + surf.fillRect(fillRect, col); + drawSurface(NULL, &surf, &sizeRect, &fillRect, false, false); + surf.free(); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + //SDL_RenderFillRect(_renderer, &fillRect); +} + +Graphics::PixelFormat BaseRenderOSystem::getPixelFormat() const { + return _renderSurface->format; +} + +void BaseRenderOSystem::drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha) { + // Skip rects that are completely outside the screen: + if ((dstRect->left < 0 && dstRect->right < 0) || (dstRect->top < 0 && dstRect->bottom < 0)) { + return; + } + + if (owner) { // Fade-tickets are owner-less + RenderTicket compare(owner, NULL, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); + compare._colorMod = _colorMod; + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + if ((*it)->_owner == owner && *(*it) == compare && (*it)->_isValid) { + (*it)->_colorMod = _colorMod; + if (_disableDirtyRects) { + drawFromSurface(*it, NULL); + } else { + drawFromTicket(*it); + } + return; + } + } + } + RenderTicket *ticket = new RenderTicket(owner, surf, srcRect, dstRect, mirrorX, mirrorY, disableAlpha); + ticket->_colorMod = _colorMod; + if (!_disableDirtyRects) { + drawFromTicket(ticket); + } else { + ticket->_wantsDraw = true; + _renderQueue.push_back(ticket); + drawFromSurface(ticket, NULL); + } +} + +void BaseRenderOSystem::invalidateTicket(RenderTicket *renderTicket) { + addDirtyRect(renderTicket->_dstRect); + renderTicket->_isValid = false; +// renderTicket->_canDelete = true; // TODO: Maybe readd this, to avoid even more duplicates. +} + +void BaseRenderOSystem::invalidateTicketsFromSurface(BaseSurfaceOSystem *surf) { + RenderQueueIterator it; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + if ((*it)->_owner == surf) { + invalidateTicket(*it); + } + } +} + +void BaseRenderOSystem::drawFromTicket(RenderTicket *renderTicket) { + renderTicket->_wantsDraw = true; + // A new item always has _drawNum == 0 + if (renderTicket->_drawNum == 0) { + // In-order + if (_renderQueue.empty() || _drawNum > (_renderQueue.back())->_drawNum) { + renderTicket->_drawNum = _drawNum++; + _renderQueue.push_back(renderTicket); + addDirtyRect(renderTicket->_dstRect); + } else { + // Before something + Common::List::iterator pos; + for (pos = _renderQueue.begin(); pos != _renderQueue.end(); pos++) { + if ((*pos)->_drawNum >= _drawNum) { + break; + } + } + _renderQueue.insert(pos, renderTicket); + Common::List::iterator it; + renderTicket->_drawNum = _drawNum++; + // Increment the following tickets, so they still are in line + for (it = pos; it != _renderQueue.end(); ++it) { + (*it)->_drawNum++; + (*it)->_wantsDraw = false; + } + addDirtyRect(renderTicket->_dstRect); + } + } else { + // Was drawn last round, still in the same order + if (_drawNum == renderTicket->_drawNum) { + _drawNum++; + } else { + // Remove the ticket from the list + RenderQueueIterator it = _renderQueue.begin(); + while (it != _renderQueue.end()) { + if ((*it) == renderTicket) { + it = _renderQueue.erase(it); + break; + } else { + ++it; + } + } + if (it != _renderQueue.end()) { + // Decreement the following tickets. + for (; it != _renderQueue.end(); ++it) { + (*it)->_drawNum--; + } + } + // Is not in order, so readd it as if it was a new ticket + renderTicket->_drawNum = 0; + drawFromTicket(renderTicket); + } + } +} + +void BaseRenderOSystem::addDirtyRect(const Common::Rect &rect) { + if (!_dirtyRect) { + _dirtyRect = new Common::Rect(rect); + } else { + _dirtyRect->extend(rect); + } + _dirtyRect->clip(_renderRect); +} + +void BaseRenderOSystem::drawTickets() { + RenderQueueIterator it = _renderQueue.begin(); + // Clean out the old tickets + int decrement = 0; + while (it != _renderQueue.end()) { + if ((*it)->_wantsDraw == false || (*it)->_isValid == false) { + RenderTicket *ticket = *it; + addDirtyRect((*it)->_dstRect); + it = _renderQueue.erase(it); + delete ticket; + decrement++; + } else { + (*it)->_drawNum -= decrement; + ++it; + } + } + if (!_dirtyRect || _dirtyRect->width() == 0 || _dirtyRect->height() == 0) { + return; + } + // The color-mods are stored in the RenderTickets on add, since we set that state again during + // draw, we need to keep track of what it was prior to draw. + uint32 oldColorMod = _colorMod; + + // Apply the clear-color to the dirty rect. + _renderSurface->fillRect(*_dirtyRect, _clearColor); + _drawNum = 1; + for (it = _renderQueue.begin(); it != _renderQueue.end(); ++it) { + RenderTicket *ticket = *it; + assert(ticket->_drawNum == _drawNum++); + if (ticket->_isValid && ticket->_dstRect.intersects(*_dirtyRect)) { + // dstClip is the area we want redrawn. + Common::Rect dstClip(ticket->_dstRect); + // reduce it to the dirty rect + dstClip.clip(*_dirtyRect); + // we need to keep track of the position to redraw the dirty rect + Common::Rect pos(dstClip); + int16 offsetX = ticket->_dstRect.left; + int16 offsetY = ticket->_dstRect.top; + // convert from screen-coords to surface-coords. + dstClip.translate(-offsetX, -offsetY); + + _colorMod = ticket->_colorMod; + drawFromSurface(ticket->getSurface(), &ticket->_srcRect, &pos, &dstClip, ticket->_mirror); + _needsFlip = true; + } + // Some tickets want redraw but don't actually clip the dirty area (typically the ones that shouldnt become clear-color) + ticket->_wantsDraw = false; + } + g_system->copyRectToScreen((byte *)_renderSurface->getBasePtr(_dirtyRect->left, _dirtyRect->top), _renderSurface->pitch, _dirtyRect->left, _dirtyRect->top, _dirtyRect->width(), _dirtyRect->height()); + + // Revert the colorMod-state. + _colorMod = oldColorMod; +} + +// Replacement for SDL2's SDL_RenderCopy +void BaseRenderOSystem::drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect) { + TransparentSurface src(*ticket->getSurface(), false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(ticket->getSurface()->w); + clipRect->setHeight(ticket->getSurface()->h); + } + + src._enableAlphaBlit = ticket->_hasAlpha; + src.blit(*_renderSurface, ticket->_dstRect.left, ticket->_dstRect.top, ticket->_mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) { + delete clipRect; + } +} +void BaseRenderOSystem::drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror) { + TransparentSurface src(*surf, false); + bool doDelete = false; + if (!clipRect) { + doDelete = true; + clipRect = new Common::Rect(); + clipRect->setWidth(surf->w); + clipRect->setHeight(surf->h); + } + + src.blit(*_renderSurface, dstRect->left, dstRect->top, mirror, clipRect, _colorMod, clipRect->width(), clipRect->height()); + if (doDelete) { + delete clipRect; + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::drawLine(int x1, int y1, int x2, int y2, uint32 color) { + + if (!_disableDirtyRects) { + warning("BaseRenderOSystem::DrawLine - doesn't work for dirty rects yet"); + } + + byte r = RGBCOLGetR(color); + byte g = RGBCOLGetG(color); + byte b = RGBCOLGetB(color); + byte a = RGBCOLGetA(color); + + //SDL_SetRenderDrawColor(_renderer, r, g, b, a); + //SDL_SetRenderDrawBlendMode(_renderer, SDL_BLENDMODE_BLEND); + + Point32 point1, point2; + point1.x = x1; + point1.y = y1; + pointToScreen(&point1); + + point2.x = x2; + point2.y = y2; + pointToScreen(&point2); + + // TODO: This thing is mostly here until I'm sure about the final color-format. + uint32 colorVal = _renderSurface->format.ARGBToColor(a, r, g, b); + _renderSurface->drawLine(point1.x, point1.y, point2.x, point2.y, colorVal); + //SDL_RenderDrawLine(_renderer, point1.x, point1.y, point2.x, point2.y); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +BaseImage *BaseRenderOSystem::takeScreenshot() { +// TODO: Clip by viewport. + BaseImage *screenshot = new BaseImage(); + screenshot->copyFrom(_renderSurface); + return screenshot; +} + +////////////////////////////////////////////////////////////////////////// +Common::String BaseRenderOSystem::getName() const { + return "ScummVM-OSystem-renderer"; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseRenderOSystem::setViewport(int left, int top, int right, int bottom) { + Common::Rect rect; + // TODO: Hopefully this is the same logic that ScummVM uses. + rect.left = (int16)(left + _borderLeft); + rect.top = (int16)(top + _borderTop); + rect.right = (int16)((right - left) * _ratioX); + rect.bottom = (int16)((bottom - top) * _ratioY); + + _renderRect = rect; + return STATUS_OK; +} + +Rect32 BaseRenderOSystem::getViewPort() { + Rect32 ret; + ret.top = _renderRect.top; + ret.bottom = _renderRect.bottom; + ret.left = _renderRect.left; + ret.right = _renderRect.right; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { + rect->left = (int16)MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); + rect->top = (int16)MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); + rect->setWidth((int16)MathUtil::roundUp(rect->width() * _ratioX)); + rect->setHeight((int16)MathUtil::roundUp(rect->height() * _ratioY)); +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::pointFromScreen(Point32 *point) { + point->x = (int16)(point->x / _ratioX - _borderLeft / _ratioX + _renderRect.left); + point->y = (int16)(point->y / _ratioY - _borderTop / _ratioY + _renderRect.top); +} + + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::pointToScreen(Point32 *point) { + point->x = (int16)MathUtil::roundUp(point->x * _ratioX) + _borderLeft - _renderRect.left; + point->y = (int16)MathUtil::roundUp(point->y * _ratioY) + _borderTop - _renderRect.top; +} + +////////////////////////////////////////////////////////////////////////// +void BaseRenderOSystem::dumpData(const char *filename) { + warning("BaseRenderOSystem::DumpData(%s) - stubbed", filename); // TODO +} + +BaseSurface *BaseRenderOSystem::createSurface() { + return new BaseSurfaceOSystem(_gameRef); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.h b/engines/wintermute/base/gfx/osystem/base_render_osystem.h index aebb4cf888..1e72508cd0 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.h @@ -1,131 +1,131 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_RENDERER_SDL_H -#define WINTERMUTE_BASE_RENDERER_SDL_H - -#include "engines/wintermute/base/gfx/base_renderer.h" -#include "common/rect.h" -#include "graphics/surface.h" -#include "common/list.h" - -namespace Wintermute { -class BaseSurfaceOSystem; -class RenderTicket { - Graphics::Surface *_surface; -public: - RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false); - RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} - ~RenderTicket(); - const Graphics::Surface *getSurface() { return _surface; } - Common::Rect _srcRect; - Common::Rect _dstRect; - uint32 _mirror; - bool _hasAlpha; - - bool _isValid; - bool _wantsDraw; - uint32 _drawNum; - uint32 _colorMod; - - BaseSurfaceOSystem *_owner; - bool operator==(RenderTicket &a); -}; - -class BaseRenderOSystem : public BaseRenderer { -public: - BaseRenderOSystem(BaseGame *inGame); - ~BaseRenderOSystem(); - - Common::String getName() const; - - bool initRenderer(int width, int height, bool windowed); - bool flip(); - virtual bool indicatorFlip(); - bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); - Graphics::PixelFormat getPixelFormat() const; - void fade(uint16 alpha); - void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL); - - bool drawLine(int x1, int y1, int x2, int y2, uint32 color); - - BaseImage *takeScreenshot(); - - void setAlphaMod(byte alpha); - void setColorMod(byte r, byte g, byte b); - void invalidateTicket(RenderTicket *renderTicket); - void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); - void drawFromTicket(RenderTicket *renderTicket); - - bool setViewport(int left, int top, int right, int bottom); - bool setViewport(Rect32 *rect) { return BaseRenderer::setViewport(rect); } - Rect32 getViewPort(); - void modTargetRect(Common::Rect *rect); - void pointFromScreen(Point32 *point); - void pointToScreen(Point32 *point); - - void dumpData(const char *filename); - - float getScaleRatioX() const { - return _ratioX; - } - float getScaleRatioY() const { - return _ratioY; - } - - void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false); - BaseSurface *createSurface(); -private: - void addDirtyRect(const Common::Rect &rect); - void drawTickets(); - void drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect); - void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); - typedef Common::List::iterator RenderQueueIterator; - Common::Rect *_dirtyRect; - Common::List _renderQueue; - bool _needsFlip; - uint32 _drawNum; - Common::Rect _renderRect; - Graphics::Surface *_renderSurface; - Graphics::Surface *_blankSurface; - - int _borderLeft; - int _borderTop; - int _borderRight; - int _borderBottom; - - static const bool _disableDirtyRects = true; - float _ratioX; - float _ratioY; - uint32 _colorMod; - uint32 _clearColor; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_RENDERER_SDL_H +#define WINTERMUTE_BASE_RENDERER_SDL_H + +#include "engines/wintermute/base/gfx/base_renderer.h" +#include "common/rect.h" +#include "graphics/surface.h" +#include "common/list.h" + +namespace Wintermute { +class BaseSurfaceOSystem; +class RenderTicket { + Graphics::Surface *_surface; +public: + RenderTicket(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRest, bool mirrorX = false, bool mirrorY = false, bool disableAlpha = false); + RenderTicket() : _isValid(true), _wantsDraw(false), _drawNum(0) {} + ~RenderTicket(); + const Graphics::Surface *getSurface() { return _surface; } + Common::Rect _srcRect; + Common::Rect _dstRect; + uint32 _mirror; + bool _hasAlpha; + + bool _isValid; + bool _wantsDraw; + uint32 _drawNum; + uint32 _colorMod; + + BaseSurfaceOSystem *_owner; + bool operator==(RenderTicket &a); +}; + +class BaseRenderOSystem : public BaseRenderer { +public: + BaseRenderOSystem(BaseGame *inGame); + ~BaseRenderOSystem(); + + Common::String getName() const; + + bool initRenderer(int width, int height, bool windowed); + bool flip(); + virtual bool indicatorFlip(); + bool fill(byte r, byte g, byte b, Common::Rect *rect = NULL); + Graphics::PixelFormat getPixelFormat() const; + void fade(uint16 alpha); + void fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect = NULL); + + bool drawLine(int x1, int y1, int x2, int y2, uint32 color); + + BaseImage *takeScreenshot(); + + void setAlphaMod(byte alpha); + void setColorMod(byte r, byte g, byte b); + void invalidateTicket(RenderTicket *renderTicket); + void invalidateTicketsFromSurface(BaseSurfaceOSystem *surf); + void drawFromTicket(RenderTicket *renderTicket); + + bool setViewport(int left, int top, int right, int bottom); + bool setViewport(Rect32 *rect) { return BaseRenderer::setViewport(rect); } + Rect32 getViewPort(); + void modTargetRect(Common::Rect *rect); + void pointFromScreen(Point32 *point); + void pointToScreen(Point32 *point); + + void dumpData(const char *filename); + + float getScaleRatioX() const { + return _ratioX; + } + float getScaleRatioY() const { + return _ratioY; + } + + void drawSurface(BaseSurfaceOSystem *owner, const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, bool mirrorX, bool mirrorY, bool disableAlpha = false); + BaseSurface *createSurface(); +private: + void addDirtyRect(const Common::Rect &rect); + void drawTickets(); + void drawFromSurface(RenderTicket *ticket, Common::Rect *clipRect); + void drawFromSurface(const Graphics::Surface *surf, Common::Rect *srcRect, Common::Rect *dstRect, Common::Rect *clipRect, uint32 mirror); + typedef Common::List::iterator RenderQueueIterator; + Common::Rect *_dirtyRect; + Common::List _renderQueue; + bool _needsFlip; + uint32 _drawNum; + Common::Rect _renderRect; + Graphics::Surface *_renderSurface; + Graphics::Surface *_blankSurface; + + int _borderLeft; + int _borderTop; + int _borderRight; + int _borderBottom; + + static const bool _disableDirtyRects = true; + float _ratioX; + float _ratioY; + uint32 _colorMod; + uint32 _clearColor; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index 7724a93481..d5464782a3 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -1,429 +1,429 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_file.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" -#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" -#include "engines/wintermute/base/gfx/base_image.h" -#include "engines/wintermute/platform_osystem.h" -#include "graphics/decoders/png.h" -#include "graphics/decoders/bmp.h" -#include "graphics/decoders/jpeg.h" -#include "graphics/decoders/tga.h" -#include "engines/wintermute/graphics/transparent_surface.h" -#include "graphics/pixelformat.h" -#include "graphics/surface.h" -#include "common/stream.h" -#include "common/system.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { - _surface = new Graphics::Surface(); - _alphaMask = NULL; - _hasAlpha = true; - _lockPixels = NULL; - _lockPitch = 0; - _loaded = false; -} - -////////////////////////////////////////////////////////////////////////// -BaseSurfaceOSystem::~BaseSurfaceOSystem() { - if (_surface) { - _surface->free(); - delete _surface; - _surface = NULL; - } - - delete[] _alphaMask; - _alphaMask = NULL; - - _gameRef->addMem(-_width * _height * 4); - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); -} - -bool hasTransparency(Graphics::Surface *surf) { - if (surf->format.bytesPerPixel != 4) { - warning("hasTransparency:: non 32 bpp surface passed as argument"); - return false; - } - uint8 r, g, b, a; - for (int i = 0; i < surf->h; i++) { - for (int j = 0; j < surf->w; j++) { - uint32 pix = *(uint32 *)surf->getBasePtr(j, i); - surf->format.colorToARGB(pix, a, r, g, b); - if (a != 255) { - return true; - } - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { - /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ - _filename = filename; -// const Graphics::Surface *surface = image->getSurface(); - - if (defaultCK) { - ckRed = 255; - ckGreen = 0; - ckBlue = 255; - } - - _ckDefault = defaultCK; - _ckRed = ckRed; - _ckGreen = ckGreen; - _ckBlue = ckBlue; - - if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) { - _lifeTime = lifeTime; - } - - _keepLoaded = keepLoaded; - if (_keepLoaded) { - _lifeTime = -1; - } - - return STATUS_OK; -} - -bool BaseSurfaceOSystem::finishLoad() { - BaseImage *image = new BaseImage(); - if (!image->loadFile(_filename)) { - return false; - } - - _width = image->getSurface()->w; - _height = image->getSurface()->h; - - bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); - if (isSaveGameGrayscale) { - warning("grayscaleConversion not yet implemented"); - // FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO - } - - // no alpha, set color key - /* if (surface->format.bytesPerPixel != 4) - SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ - - // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) - // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. - _surface->free(); - delete _surface; - if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); - } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { - _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); - if (image->getSurface()->format.bytesPerPixel == 3) { - TransparentSurface trans(*_surface); - trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); - } - } else { - _surface = new Graphics::Surface(); - _surface->copyFrom(*image->getSurface()); - } - - _hasAlpha = hasTransparency(_surface); - _valid = true; - - _gameRef->addMem(_width * _height * 4); - - delete image; - - _loaded = true; - - return true; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { - warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); - return; - // TODO: Reimplement this - delete[] _alphaMask; - _alphaMask = NULL; - if (!surface) { - return; - } - - bool hasColorKey; - /* uint32 colorKey; */ - uint8 ckRed, ckGreen, ckBlue; - /* if (SDL_GetColorKey(surface, &colorKey) == 0) { - hasColorKey = true; - SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); - } else hasColorKey = false; - */ - _alphaMask = new byte[surface->w * surface->h]; - - bool hasTransparency = false; - for (int y = 0; y < surface->h; y++) { - for (int x = 0; x < surface->w; x++) { - uint32 pixel = getPixelAt(surface, x, y); - - uint8 r, g, b, a; - surface->format.colorToARGB(pixel, a, r, g, b); - //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); - - if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) { - a = 0; - } - - _alphaMask[y * surface->w + x] = a; - if (a < 255) { - hasTransparency = true; - } - } - } - - if (!hasTransparency) { - delete[] _alphaMask; - _alphaMask = NULL; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 BaseSurfaceOSystem::getPixelAt(Graphics::Surface *surface, int x, int y) { - warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); - int bpp = surface->format.bytesPerPixel; - /* Here p is the address to the pixel we want to retrieve */ - uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; - - switch (bpp) { - case 1: - return *p; - break; - - case 2: - return *(uint16 *)p; - break; - - case 3: -#ifdef SCUMM_BIG_ENDIAN - // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) - return p[0] << 16 | p[1] << 8 | p[2]; -#else - //else - return p[0] | p[1] << 8 | p[2] << 16; -#endif - break; - - case 4: - return *(uint32 *)p; - break; - - default: - return 0; /* shouldn't happen, but avoids warnings */ - } - return 0; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::create(int width, int height) { - _width = width; - _height = height; - - _gameRef->addMem(_width * _height * 4); - - _valid = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { - return isTransparentAtLite(x, y); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { - if (x < 0 || x >= _surface->w || y < 0 || y >= _surface->h) { - return true; - } - - if (_surface->format.bytesPerPixel == 4) { - uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); - uint8 r, g, b, a; - _surface->format.colorToARGB(pixel, a, r, g, b); - if (a <= 128) { - return true; - } else { - return false; - } - } - - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::startPixelOp() { - //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); - // Any pixel-op makes the caching useless: - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::endPixelOp() { - //SDL_UnlockTexture(_texture); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !transparent, blendMode, mirrorX, mirrorY); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { - return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - - if (!_loaded) { - finishLoad(); - } - - if (renderer->_forceAlphaColor != 0) { - alpha = renderer->_forceAlphaColor; - } - - byte r = RGBCOLGetR(alpha); - byte g = RGBCOLGetG(alpha); - byte b = RGBCOLGetB(alpha); - byte a = RGBCOLGetA(alpha); - - renderer->setAlphaMod(a); - renderer->setColorMod(r, g, b); - -#if 0 // These are kept for reference if BlendMode is reimplemented at some point. - if (alphaDisable) { - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); - } else { - SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); - } -#endif - // TODO: This _might_ miss the intended behaviour by 1 in each direction - // But I think it fits the model used in Wintermute. - Common::Rect srcRect; - srcRect.left = rect->left; - srcRect.top = rect->top; - srcRect.setWidth(rect->right - rect->left); - srcRect.setHeight(rect->bottom - rect->top); - - Common::Rect position; - position.left = x + offsetX; - position.top = y + offsetY; - - // Crop off-by-ones: - if (position.left == -1) { - position.left = 0; // TODO: Something is wrong - } - if (position.top == -1) { - position.top = 0; // TODO: Something is wrong - } - - position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); - position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); - - renderer->modTargetRect(&position); - - /* position.left += offsetX; - position.top += offsetY;*/ - - // TODO: This actually requires us to have the SAME source-offsets every time, - // But no checking is in place for that yet. - - // TODO: Optimize by not doing alpha-blits if we lack or disable alpha - bool hasAlpha; - if (_hasAlpha && !alphaDisable) { - hasAlpha = true; - } else { - hasAlpha = false; - } - if (alphaDisable) { - warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); - } - - renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); - - return STATUS_OK; -} - -bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { - _loaded = true; - _surface->free(); - _surface->copyFrom(surface); - _hasAlpha = hasAlpha; - BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); - renderer->invalidateTicketsFromSurface(this); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" +#include "engines/wintermute/base/gfx/osystem/base_render_osystem.h" +#include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/platform_osystem.h" +#include "graphics/decoders/png.h" +#include "graphics/decoders/bmp.h" +#include "graphics/decoders/jpeg.h" +#include "graphics/decoders/tga.h" +#include "engines/wintermute/graphics/transparent_surface.h" +#include "graphics/pixelformat.h" +#include "graphics/surface.h" +#include "common/stream.h" +#include "common/system.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +BaseSurfaceOSystem::BaseSurfaceOSystem(BaseGame *inGame) : BaseSurface(inGame) { + _surface = new Graphics::Surface(); + _alphaMask = NULL; + _hasAlpha = true; + _lockPixels = NULL; + _lockPitch = 0; + _loaded = false; +} + +////////////////////////////////////////////////////////////////////////// +BaseSurfaceOSystem::~BaseSurfaceOSystem() { + if (_surface) { + _surface->free(); + delete _surface; + _surface = NULL; + } + + delete[] _alphaMask; + _alphaMask = NULL; + + _gameRef->addMem(-_width * _height * 4); + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); +} + +bool hasTransparency(Graphics::Surface *surf) { + if (surf->format.bytesPerPixel != 4) { + warning("hasTransparency:: non 32 bpp surface passed as argument"); + return false; + } + uint8 r, g, b, a; + for (int i = 0; i < surf->h; i++) { + for (int j = 0; j < surf->w; j++) { + uint32 pix = *(uint32 *)surf->getBasePtr(j, i); + surf->format.colorToARGB(pix, a, r, g, b); + if (a != 255) { + return true; + } + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime, bool keepLoaded) { + /* BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); */ + _filename = filename; +// const Graphics::Surface *surface = image->getSurface(); + + if (defaultCK) { + ckRed = 255; + ckGreen = 0; + ckBlue = 255; + } + + _ckDefault = defaultCK; + _ckRed = ckRed; + _ckGreen = ckGreen; + _ckBlue = ckBlue; + + if (_lifeTime == 0 || lifeTime == -1 || lifeTime > _lifeTime) { + _lifeTime = lifeTime; + } + + _keepLoaded = keepLoaded; + if (_keepLoaded) { + _lifeTime = -1; + } + + return STATUS_OK; +} + +bool BaseSurfaceOSystem::finishLoad() { + BaseImage *image = new BaseImage(); + if (!image->loadFile(_filename)) { + return false; + } + + _width = image->getSurface()->w; + _height = image->getSurface()->h; + + bool isSaveGameGrayscale = scumm_strnicmp(_filename.c_str(), "savegame:", 9) == 0 && (_filename.c_str()[_filename.size() - 1] == 'g' || _filename.c_str()[_filename.size() - 1] == 'G'); + if (isSaveGameGrayscale) { + warning("grayscaleConversion not yet implemented"); + // FIBITMAP *newImg = FreeImage_ConvertToGreyscale(img); TODO + } + + // no alpha, set color key + /* if (surface->format.bytesPerPixel != 4) + SDL_SetColorKey(surf, SDL_TRUE, SDL_MapRGB(surf->format, ck_red, ck_green, ck_blue));*/ + + // convert 32-bit BMPs to 24-bit or they appear totally transparent (does any app actually write alpha in BMP properly?) + // Well, actually, we don't convert via 24-bit as the color-key application overwrites the Alpha-channel anyhow. + _surface->free(); + delete _surface; + if (_filename.hasSuffix(".bmp") && image->getSurface()->format.bytesPerPixel == 4) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue); + } else if (image->getSurface()->format.bytesPerPixel == 1 && image->getPalette()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat(), image->getPalette()); + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } else if (image->getSurface()->format.bytesPerPixel >= 3 && image->getSurface()->format != g_system->getScreenFormat()) { + _surface = image->getSurface()->convertTo(g_system->getScreenFormat()); + if (image->getSurface()->format.bytesPerPixel == 3) { + TransparentSurface trans(*_surface); + trans.applyColorKey(_ckRed, _ckGreen, _ckBlue, true); + } + } else { + _surface = new Graphics::Surface(); + _surface->copyFrom(*image->getSurface()); + } + + _hasAlpha = hasTransparency(_surface); + _valid = true; + + _gameRef->addMem(_width * _height * 4); + + delete image; + + _loaded = true; + + return true; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSurfaceOSystem::genAlphaMask(Graphics::Surface *surface) { + warning("BaseSurfaceOSystem::GenAlphaMask - Not ported yet"); + return; + // TODO: Reimplement this + delete[] _alphaMask; + _alphaMask = NULL; + if (!surface) { + return; + } + + bool hasColorKey; + /* uint32 colorKey; */ + uint8 ckRed, ckGreen, ckBlue; + /* if (SDL_GetColorKey(surface, &colorKey) == 0) { + hasColorKey = true; + SDL_GetRGB(colorKey, surface->format, &ckRed, &ckGreen, &ckBlue); + } else hasColorKey = false; + */ + _alphaMask = new byte[surface->w * surface->h]; + + bool hasTransparency = false; + for (int y = 0; y < surface->h; y++) { + for (int x = 0; x < surface->w; x++) { + uint32 pixel = getPixelAt(surface, x, y); + + uint8 r, g, b, a; + surface->format.colorToARGB(pixel, a, r, g, b); + //SDL_GetRGBA(pixel, surface->format, &r, &g, &b, &a); + + if (hasColorKey && r == ckRed && g == ckGreen && b == ckBlue) { + a = 0; + } + + _alphaMask[y * surface->w + x] = a; + if (a < 255) { + hasTransparency = true; + } + } + } + + if (!hasTransparency) { + delete[] _alphaMask; + _alphaMask = NULL; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 BaseSurfaceOSystem::getPixelAt(Graphics::Surface *surface, int x, int y) { + warning("BaseSurfaceOSystem::GetPixel - Not ported yet"); + int bpp = surface->format.bytesPerPixel; + /* Here p is the address to the pixel we want to retrieve */ + uint8 *p = (uint8 *)surface->pixels + y * surface->pitch + x * bpp; + + switch (bpp) { + case 1: + return *p; + break; + + case 2: + return *(uint16 *)p; + break; + + case 3: +#ifdef SCUMM_BIG_ENDIAN + // if (SDL_BYTEORDER == SDL_BIG_ENDIAN) + return p[0] << 16 | p[1] << 8 | p[2]; +#else + //else + return p[0] | p[1] << 8 | p[2] << 16; +#endif + break; + + case 4: + return *(uint32 *)p; + break; + + default: + return 0; /* shouldn't happen, but avoids warnings */ + } + return 0; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::create(int width, int height) { + _width = width; + _height = height; + + _gameRef->addMem(_width * _height * 4); + + _valid = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::isTransparentAt(int x, int y) { + return isTransparentAtLite(x, y); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::isTransparentAtLite(int x, int y) { + if (x < 0 || x >= _surface->w || y < 0 || y >= _surface->h) { + return true; + } + + if (_surface->format.bytesPerPixel == 4) { + uint32 pixel = *(uint32 *)_surface->getBasePtr(x, y); + uint8 r, g, b, a; + _surface->format.colorToARGB(pixel, a, r, g, b); + if (a <= 128) { + return true; + } else { + return false; + } + } + + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::startPixelOp() { + //SDL_LockTexture(_texture, NULL, &_lockPixels, &_lockPitch); + // Any pixel-op makes the caching useless: + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::endPixelOp() { + //SDL_UnlockTexture(_texture); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, 0xFFFFFFFF, true, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayTrans(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayTransOffset(int x, int y, Rect32 rect, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + return drawSprite(x, y, &rect, 100, 100, alpha, false, blendMode, mirrorX, mirrorY, offsetX, offsetY); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha, bool transparent, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, !transparent, blendMode, mirrorX, mirrorY); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::displayTransform(int x, int y, int hotX, int hotY, Rect32 rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY) { + return drawSprite(x, y, &rect, zoomX, zoomY, alpha, false, blendMode, mirrorX, mirrorY); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSurfaceOSystem::drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX, int offsetY) { + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + + if (!_loaded) { + finishLoad(); + } + + if (renderer->_forceAlphaColor != 0) { + alpha = renderer->_forceAlphaColor; + } + + byte r = RGBCOLGetR(alpha); + byte g = RGBCOLGetG(alpha); + byte b = RGBCOLGetB(alpha); + byte a = RGBCOLGetA(alpha); + + renderer->setAlphaMod(a); + renderer->setColorMod(r, g, b); + +#if 0 // These are kept for reference if BlendMode is reimplemented at some point. + if (alphaDisable) { + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_NONE); + } else { + SDL_SetTextureBlendMode(_texture, SDL_BLENDMODE_BLEND); + } +#endif + // TODO: This _might_ miss the intended behaviour by 1 in each direction + // But I think it fits the model used in Wintermute. + Common::Rect srcRect; + srcRect.left = rect->left; + srcRect.top = rect->top; + srcRect.setWidth(rect->right - rect->left); + srcRect.setHeight(rect->bottom - rect->top); + + Common::Rect position; + position.left = x + offsetX; + position.top = y + offsetY; + + // Crop off-by-ones: + if (position.left == -1) { + position.left = 0; // TODO: Something is wrong + } + if (position.top == -1) { + position.top = 0; // TODO: Something is wrong + } + + position.setWidth((int16)((float)srcRect.width() * zoomX / 100.f)); + position.setHeight((int16)((float)srcRect.height() * zoomX / 100.f)); + + renderer->modTargetRect(&position); + + /* position.left += offsetX; + position.top += offsetY;*/ + + // TODO: This actually requires us to have the SAME source-offsets every time, + // But no checking is in place for that yet. + + // TODO: Optimize by not doing alpha-blits if we lack or disable alpha + bool hasAlpha; + if (_hasAlpha && !alphaDisable) { + hasAlpha = true; + } else { + hasAlpha = false; + } + if (alphaDisable) { + warning("BaseSurfaceOSystem::drawSprite - AlphaDisable ignored"); + } + + renderer->drawSurface(this, _surface, &srcRect, &position, mirrorX, mirrorY, !hasAlpha); + + return STATUS_OK; +} + +bool BaseSurfaceOSystem::putSurface(const Graphics::Surface &surface, bool hasAlpha) { + _loaded = true; + _surface->free(); + _surface->copyFrom(surface); + _hasAlpha = hasAlpha; + BaseRenderOSystem *renderer = static_cast(_gameRef->_renderer); + renderer->invalidateTicketsFromSurface(this); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h index b68fac4e3b..43422ef4e7 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.h +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.h @@ -1,99 +1,99 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SURFACESDL_H -#define WINTERMUTE_BASE_SURFACESDL_H - -#include "graphics/surface.h" -#include "engines/wintermute/base/gfx/base_surface.h" -#include "common/list.h" - -namespace Wintermute { -struct TransparentSurface; -class BaseImage; -class BaseSurfaceOSystem : public BaseSurface { -public: - BaseSurfaceOSystem(BaseGame *inGame); - ~BaseSurfaceOSystem(); - - bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); - bool create(int width, int height); - - bool isTransparentAt(int x, int y); - bool isTransparentAtLite(int x, int y); - - bool startPixelOp(); - bool endPixelOp(); - - - bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); - bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); - virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); - /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); - static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); - static long DLL_CALLCONV TellProc(fi_handle handle);*/ - virtual int getWidth() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->w; - } - return _width; - } - virtual int getHeight() { - if (!_loaded) { - finishLoad(); - } - if (_surface) { - return _surface->h; - } - return _height; - } - -private: - Graphics::Surface *_surface; - bool _loaded; - bool finishLoad(); - bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); - void genAlphaMask(Graphics::Surface *surface); - uint32 getPixelAt(Graphics::Surface *surface, int x, int y); - - bool _hasAlpha; - void *_lockPixels; - int _lockPitch; - byte *_alphaMask; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SURFACESDL_H +#define WINTERMUTE_BASE_SURFACESDL_H + +#include "graphics/surface.h" +#include "engines/wintermute/base/gfx/base_surface.h" +#include "common/list.h" + +namespace Wintermute { +struct TransparentSurface; +class BaseImage; +class BaseSurfaceOSystem : public BaseSurface { +public: + BaseSurfaceOSystem(BaseGame *inGame); + ~BaseSurfaceOSystem(); + + bool create(const Common::String &filename, bool defaultCK, byte ckRed, byte ckGreen, byte ckBlue, int lifeTime = -1, bool keepLoaded = false); + bool create(int width, int height); + + bool isTransparentAt(int x, int y); + bool isTransparentAtLite(int x, int y); + + bool startPixelOp(); + bool endPixelOp(); + + + bool displayTransZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTrans(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransOffset(int x, int y, Rect32 rect, uint32 alpha = 0xFFFFFFFF, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false, int offsetX = 0, int offsetY = 0); + bool display(int x, int y, Rect32 rect, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayZoom(int x, int y, Rect32 rect, float zoomX, float zoomY, uint32 alpha = 0xFFFFFFFF, bool transparent = false, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + bool displayTransform(int x, int y, int hotX, int hotY, Rect32 Rect, float zoomX, float zoomY, uint32 alpha, float rotate, TSpriteBlendMode blendMode = BLEND_NORMAL, bool mirrorX = false, bool mirrorY = false); + virtual bool putSurface(const Graphics::Surface &surface, bool hasAlpha = false); + /* static unsigned DLL_CALLCONV ReadProc(void *buffer, unsigned size, unsigned count, fi_handle handle); + static int DLL_CALLCONV SeekProc(fi_handle handle, long offset, int origin); + static long DLL_CALLCONV TellProc(fi_handle handle);*/ + virtual int getWidth() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->w; + } + return _width; + } + virtual int getHeight() { + if (!_loaded) { + finishLoad(); + } + if (_surface) { + return _surface->h; + } + return _height; + } + +private: + Graphics::Surface *_surface; + bool _loaded; + bool finishLoad(); + bool drawSprite(int x, int y, Rect32 *rect, float zoomX, float zoomY, uint32 alpha, bool alphaDisable, TSpriteBlendMode blendMode, bool mirrorX, bool mirrorY, int offsetX = 0, int offsetY = 0); + void genAlphaMask(Graphics::Surface *surface); + uint32 getPixelAt(Graphics::Surface *surface, int x, int y); + + bool _hasAlpha; + void *_lockPixels; + int _lockPitch; + byte *_alphaMask; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 7012bef86f..3655b89131 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -1,1256 +1,1256 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/particles/part_emitter.h" -#include "engines/wintermute/base/particles/part_particle.h" -#include "engines/wintermute/math/vector2.h" -#include "engines/wintermute/math/matrix4.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_region.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" -#include "common/math.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(PartEmitter, false) - -////////////////////////////////////////////////////////////////////////// -PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { - _width = _height = 0; - - BasePlatform::setRectEmpty(&_border); - _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; - - _angle1 = _angle2 = 0; - - _velocity1 = _velocity2 = 0.0f; - _velocityZBased = false; - - _scale1 = _scale2 = 100.0f; - _scaleZBased = false; - - _maxParticles = 100; - - _lifeTime1 = _lifeTime2 = 1000; - _lifeTimeZBased = false; - - _lastGenTime = 0; - _genInterval = 0; - _genAmount = 1; - - _overheadTime = 0; - _running = false; - - _maxBatches = 0; - _batchesGenerated = 0; - - _fadeInTime = _fadeOutTime = 0; - - _alpha1 = _alpha2 = 255; - _alphaTimeBased = false; - - _rotation1 = _rotation2 = 0.0f; - _angVelocity1 = _angVelocity2 = 0.0f; - - _growthRate1 = _growthRate2 = 0.0f; - _exponentialGrowth = false; - - _useRegion = false; - - _emitEvent = NULL; - _owner = owner; -} - - -////////////////////////////////////////////////////////////////////////// -PartEmitter::~PartEmitter(void) { - for (uint32 i = 0; i < _particles.size(); i++) { - delete _particles[i]; - } - _particles.clear(); - - for (uint32 i = 0; i < _forces.size(); i++) { - delete _forces[i]; - } - _forces.clear(); - - - for (uint32 i = 0; i < _sprites.size(); i++) { - delete[] _sprites[i]; - } - _sprites.clear(); - - delete[] _emitEvent; - _emitEvent = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::addSprite(const char *filename) { - if (!filename) { - return STATUS_FAILED; - } - - // do we already have the file? - for (uint32 i = 0; i < _sprites.size(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - return STATUS_OK; - } - } - - // check if file exists - Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); - if (!File) { - _gameRef->LOG(0, "Sprite '%s' not found", filename); - return STATUS_FAILED; - } else { - BaseFileManager::getEngineInstance()->closeFile(File); - } - - char *str = new char[strlen(filename) + 1]; - strcpy(str, filename); - _sprites.add(str); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeSprite(const char *filename) { - for (uint32 i = 0; i < _sprites.size(); i++) { - if (scumm_stricmp(filename, _sprites[i]) == 0) { - delete[] _sprites[i]; - _sprites.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { - if (!particle) { - return STATUS_FAILED; - } - if (_sprites.size() == 0) { - return STATUS_FAILED; - } - - int posX = BaseUtils::randomInt(_posX, _posX + _width); - int posY = BaseUtils::randomInt(_posY, _posY + _height); - float posZ = BaseUtils::randomFloat(0.0f, 100.0f); - - float velocity; - if (_velocityZBased) { - velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; - } else { - velocity = BaseUtils::randomFloat(_velocity1, _velocity2); - } - - float scale; - if (_scaleZBased) { - scale = _scale1 + posZ * (_scale2 - _scale1) / 100; - } else { - scale = BaseUtils::randomFloat(_scale1, _scale2); - } - - int lifeTime; - if (_lifeTimeZBased) { - lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); - } else { - lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); - } - - float angle = BaseUtils::randomAngle(_angle1, _angle2); - int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); - - float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); - float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); - float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); - - if (!BasePlatform::isRectEmpty(&_border)) { - int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); - int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); - int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); - int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); - - particle->_border = _border; - particle->_border.left += thicknessLeft; - particle->_border.right -= thicknessRight; - particle->_border.top += thicknessTop; - particle->_border.bottom -= thicknessBottom; - } - - Vector2 vecPos((float)posX, (float)posY); - Vector2 vecVel(0, velocity); - - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(vecVel); - - if (_alphaTimeBased) { - particle->_alpha1 = _alpha1; - particle->_alpha2 = _alpha2; - } else { - int alpha = BaseUtils::randomInt(_alpha1, _alpha2); - particle->_alpha1 = alpha; - particle->_alpha2 = alpha; - } - - particle->_creationTime = currentTime; - particle->_pos = vecPos; - particle->_posZ = posZ; - particle->_velocity = vecVel; - particle->_scale = scale; - particle->_lifeTime = lifeTime; - particle->_rotation = rotation; - particle->_angVelocity = angVelocity; - particle->_growthRate = growthRate; - particle->_exponentialGrowth = _exponentialGrowth; - particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); - particle->fadeIn(currentTime, _fadeInTime); - - - if (particle->_isDead) { - return STATUS_FAILED; - } else { - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::update() { - if (!_running) { - return STATUS_OK; - } else { - return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { - int numLive = 0; - - for (uint32 i = 0; i < _particles.size(); i++) { - _particles[i]->update(this, currentTime, timerDelta); - - if (!_particles[i]->_isDead) { - numLive++; - } - } - - - // we're understaffed - if (numLive < _maxParticles) { - bool needsSort = false; - if ((int)(currentTime - _lastGenTime) > _genInterval) { - _lastGenTime = currentTime; - _batchesGenerated++; - - if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { - return STATUS_OK; - } - - int toGen = MIN(_genAmount, _maxParticles - numLive); - while (toGen > 0) { - int firstDeadIndex = -1; - for (uint32 i = 0; i < _particles.size(); i++) { - if (_particles[i]->_isDead) { - firstDeadIndex = i; - break; - } - } - - PartParticle *particle; - if (firstDeadIndex >= 0) { - particle = _particles[firstDeadIndex]; - } else { - particle = new PartParticle(_gameRef); - _particles.add(particle); - } - initParticle(particle, currentTime, timerDelta); - needsSort = true; - - toGen--; - } - } - if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) { - sortParticlesByZ(); - } - - // we actually generated some particles and we're not in fast-forward mode - if (needsSort && _overheadTime == 0) { - if (_owner && _emitEvent) { - _owner->applyEvent(_emitEvent); - } - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::display(BaseRegion *region) { - if (_sprites.size() <= 1) { - _gameRef->_renderer->startSpriteBatch(); - } - - for (uint32 i = 0; i < _particles.size(); i++) { - if (region != NULL && _useRegion) { - if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { - continue; - } - } - - _particles[i]->display(this); - } - - if (_sprites.size() <= 1) { - _gameRef->_renderer->endSpriteBatch(); - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::start() { - for (uint32 i = 0; i < _particles.size(); i++) { - _particles[i]->_isDead = true; - } - _running = true; - _batchesGenerated = 0; - - - if (_overheadTime > 0) { - uint32 delta = 500; - int steps = _overheadTime / delta; - uint32 currentTime = _gameRef->_timer - _overheadTime; - - for (int i = 0; i < steps; i++) { - updateInternal(currentTime, delta); - currentTime += delta; - } - _overheadTime = 0; - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::sortParticlesByZ() { - // sort particles by _posY - Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int PartEmitter::compareZ(const void *obj1, const void *obj2) { - const PartParticle *p1 = *(const PartParticle *const *)obj1; - const PartParticle *p2 = *(const PartParticle *const *)obj2; - - if (p1->_posZ < p2->_posZ) { - return -1; - } else if (p1->_posZ > p2->_posZ) { - return 1; - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::setBorder(int x, int y, int width, int height) { - BasePlatform::setRect(&_border, x, y, x + width, y + height); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { - _borderThicknessLeft = thicknessLeft; - _borderThicknessRight = thicknessRight; - _borderThicknessTop = thicknessTop; - _borderThicknessBottom = thicknessBottom; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -PartForce *PartEmitter::addForceByName(const Common::String &name) { - PartForce *force = NULL; - - for (uint32 i = 0; i < _forces.size(); i++) { - if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { - force = _forces[i]; - break; - } - } - if (!force) { - force = new PartForce(_gameRef); - if (force) { - force->setName(name.c_str()); - _forces.add(force); - } - } - return force; -} - - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { - PartForce *force = addForceByName(name); - if (!force) { - return STATUS_FAILED; - } - - force->_type = type; - force->_pos = Vector2(posX, posY); - - force->_direction = Vector2(0, strength); - Matrix4 matRot; - matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); - matRot.transformVector2(force->_direction); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::removeForce(const Common::String &name) { - for (uint32 i = 0; i < _forces.size(); i++) { - if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { - delete _forces[i]; - _forces.remove_at(i); - return STATUS_OK; - } - } - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -// high level scripting interface -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetBorder - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetBorder") == 0) { - stack->correctParams(4); - int borderX = stack->pop()->getInt(); - int borderY = stack->pop()->getInt(); - int borderWidth = stack->pop()->getInt(); - int borderHeight = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetBorderThickness - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBorderThickness") == 0) { - stack->correctParams(4); - int left = stack->pop()->getInt(); - int right = stack->pop()->getInt(); - int top = stack->pop()->getInt(); - int bottom = stack->pop()->getInt(); - - stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AddSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); - - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // RemoveSprite - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveSprite") == 0) { - stack->correctParams(1); - const char *spriteFile = stack->pop()->getString(); - stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Start - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Start") == 0) { - stack->correctParams(1); - _overheadTime = stack->pop()->getInt(); - stack->pushBool(DID_SUCCEED(start())); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Stop - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Stop") == 0) { - stack->correctParams(0); - - for (uint32 i = 0; i < _particles.size(); i++) { - delete _particles[i]; - } - _particles.clear(); - - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pause - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pause") == 0) { - stack->correctParams(0); - _running = false; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Resume - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Resume") == 0) { - stack->correctParams(0); - _running = true; - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddGlobalForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddGlobalForce") == 0) { - stack->correctParams(3); - const char *forceName = stack->pop()->getString(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, 0, 0, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AddPointForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AddPointForce") == 0) { - stack->correctParams(5); - const char *forceName = stack->pop()->getString(); - int posX = stack->pop()->getInt(); - int posY = stack->pop()->getInt(); - float angle = stack->pop()->getFloat(); - float strength = stack->pop()->getFloat(); - - stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, posX, posY, angle, strength))); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RemoveForce - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RemoveForce") == 0) { - stack->correctParams(1); - const char *forceName = stack->pop()->getString(); - - stack->pushBool(DID_SUCCEED(removeForce(forceName))); - - return STATUS_OK; - } else { - return BaseObject::scCallMethod(script, stack, thisStack, name); - } -} - -////////////////////////////////////////////////////////////////////////// -ScValue *PartEmitter::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("particle-emitter"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { - _scValue->setInt(_posX); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _scValue->setInt(_posY); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _scValue->setInt(_width); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _scValue->setInt(_height); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scValue->setFloat(_scale1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scValue->setFloat(_scale2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scValue->setBool(_scaleZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _scValue->setFloat(_velocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _scValue->setFloat(_velocity2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _scValue->setBool(_velocityZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _scValue->setInt(_lifeTime1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _scValue->setInt(_lifeTime2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _scValue->setBool(_lifeTimeZBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _scValue->setInt(_angle1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _scValue->setInt(_angle2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _scValue->setFloat(_angVelocity1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _scValue->setFloat(_angVelocity2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _scValue->setFloat(_rotation1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _scValue->setFloat(_rotation2); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _scValue->setInt(_alpha1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _scValue->setInt(_alpha2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _scValue->setBool(_alphaTimeBased); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _scValue->setInt(_maxParticles); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // NumLiveParticles (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { - int numAlive = 0; - for (uint32 i = 0; i < _particles.size(); i++) { - if (_particles[i] && !_particles[i]->_isDead) { - numAlive++; - } - } - _scValue->setInt(numAlive); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _scValue->setInt(_genInterval); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _scValue->setInt(_genAmount); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _scValue->setInt(_maxBatches); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _scValue->setInt(_fadeInTime); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _scValue->setInt(_fadeOutTime); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _scValue->setFloat(_growthRate1); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _scValue->setFloat(_growthRate2); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _scValue->setBool(_exponentialGrowth); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _scValue->setBool(_useRegion); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - if (!_emitEvent) { - _scValue->setNULL(); - } else { - _scValue->setString(_emitEvent); - } - return _scValue; - } else { - return BaseObject::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // X - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "X") == 0) { - _posX = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Y - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { - _posY = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Width - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { - _width = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Height - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { - _height = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Scale1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { - _scale1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Scale2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { - _scale2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ScaleZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { - _scaleZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Velocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { - _velocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Velocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { - _velocity2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // VelocityZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { - _velocityZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // LifeTime1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { - _lifeTime1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTime2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { - _lifeTime2 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // LifeTimeZBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { - _lifeTimeZBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Angle1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { - _angle1 = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Angle2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { - _angle2 = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // AngVelocity1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { - _angVelocity1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AngVelocity2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { - _angVelocity2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Rotation1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { - _rotation1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Rotation2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { - _rotation2 = value->getFloat(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Alpha1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { - _alpha1 = value->getInt(); - if (_alpha1 < 0) { - _alpha1 = 0; - } - if (_alpha1 > 255) { - _alpha1 = 255; - } - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // Alpha2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { - _alpha2 = value->getInt(); - if (_alpha2 < 0) { - _alpha2 = 0; - } - if (_alpha2 > 255) { - _alpha2 = 255; - } - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // AlphaTimeBased - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { - _alphaTimeBased = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // MaxParticles - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { - _maxParticles = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GenerationInterval - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { - _genInterval = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GenerationAmount - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { - _genAmount = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // MaxBatches - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { - _maxBatches = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // FadeInTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { - _fadeInTime = value->getInt(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // FadeOutTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { - _fadeOutTime = value->getInt(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GrowthRate1 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { - _growthRate1 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GrowthRate2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { - _growthRate2 = value->getFloat(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // ExponentialGrowth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { - _exponentialGrowth = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // UseRegion - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { - _useRegion = value->getBool(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // EmitEvent - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { - delete[] _emitEvent; - _emitEvent = NULL; - if (!value->isNULL()) { - BaseUtils::setString(&_emitEvent, value->getString()); - } - return STATUS_OK; - } else { - return BaseObject::scSetProperty(name, value); - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *PartEmitter::scToString() { - return "[particle emitter]"; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool PartEmitter::persist(BasePersistenceManager *persistMgr) { - BaseObject::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_width)); - persistMgr->transfer(TMEMBER(_height)); - - persistMgr->transfer(TMEMBER(_angle1)); - persistMgr->transfer(TMEMBER(_angle2)); - - persistMgr->transfer(TMEMBER(_velocity1)); - persistMgr->transfer(TMEMBER(_velocity2)); - persistMgr->transfer(TMEMBER(_velocityZBased)); - - persistMgr->transfer(TMEMBER(_scale1)); - persistMgr->transfer(TMEMBER(_scale2)); - persistMgr->transfer(TMEMBER(_scaleZBased)); - - persistMgr->transfer(TMEMBER(_maxParticles)); - - persistMgr->transfer(TMEMBER(_lifeTime1)); - persistMgr->transfer(TMEMBER(_lifeTime2)); - persistMgr->transfer(TMEMBER(_lifeTimeZBased)); - - persistMgr->transfer(TMEMBER(_genInterval)); - persistMgr->transfer(TMEMBER(_genAmount)); - - persistMgr->transfer(TMEMBER(_running)); - persistMgr->transfer(TMEMBER(_overheadTime)); - - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_borderThicknessLeft)); - persistMgr->transfer(TMEMBER(_borderThicknessRight)); - persistMgr->transfer(TMEMBER(_borderThicknessTop)); - persistMgr->transfer(TMEMBER(_borderThicknessBottom)); - - persistMgr->transfer(TMEMBER(_fadeInTime)); - persistMgr->transfer(TMEMBER(_fadeOutTime)); - - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_alphaTimeBased)); - - persistMgr->transfer(TMEMBER(_angVelocity1)); - persistMgr->transfer(TMEMBER(_angVelocity2)); - - persistMgr->transfer(TMEMBER(_rotation1)); - persistMgr->transfer(TMEMBER(_rotation2)); - - persistMgr->transfer(TMEMBER(_growthRate1)); - persistMgr->transfer(TMEMBER(_growthRate2)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - - persistMgr->transfer(TMEMBER(_useRegion)); - - persistMgr->transfer(TMEMBER_INT(_maxBatches)); - persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); - - persistMgr->transfer(TMEMBER(_emitEvent)); - persistMgr->transfer(TMEMBER(_owner)); - - - _sprites.persist(persistMgr); - - uint32 numForces; - if (persistMgr->getIsSaving()) { - numForces = _forces.size(); - persistMgr->transfer(TMEMBER(numForces)); - for (uint32 i = 0; i < _forces.size(); i++) { - _forces[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numForces)); - for (uint32 i = 0; i < numForces; i++) { - PartForce *force = new PartForce(_gameRef); - force->persist(persistMgr); - _forces.add(force); - } - } - - uint32 numParticles; - if (persistMgr->getIsSaving()) { - numParticles = _particles.size(); - persistMgr->transfer(TMEMBER(numParticles)); - for (uint32 i = 0; i < _particles.size(); i++) { - _particles[i]->persist(persistMgr); - } - } else { - persistMgr->transfer(TMEMBER(numParticles)); - for (uint32 i = 0; i < numParticles; i++) { - PartParticle *particle = new PartParticle(_gameRef); - particle->persist(persistMgr); - _particles.add(particle); - } - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/math/vector2.h" +#include "engines/wintermute/math/matrix4.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" +#include "common/math.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(PartEmitter, false) + +////////////////////////////////////////////////////////////////////////// +PartEmitter::PartEmitter(BaseGame *inGame, BaseScriptHolder *owner) : BaseObject(inGame) { + _width = _height = 0; + + BasePlatform::setRectEmpty(&_border); + _borderThicknessLeft = _borderThicknessRight = _borderThicknessTop = _borderThicknessBottom = 0; + + _angle1 = _angle2 = 0; + + _velocity1 = _velocity2 = 0.0f; + _velocityZBased = false; + + _scale1 = _scale2 = 100.0f; + _scaleZBased = false; + + _maxParticles = 100; + + _lifeTime1 = _lifeTime2 = 1000; + _lifeTimeZBased = false; + + _lastGenTime = 0; + _genInterval = 0; + _genAmount = 1; + + _overheadTime = 0; + _running = false; + + _maxBatches = 0; + _batchesGenerated = 0; + + _fadeInTime = _fadeOutTime = 0; + + _alpha1 = _alpha2 = 255; + _alphaTimeBased = false; + + _rotation1 = _rotation2 = 0.0f; + _angVelocity1 = _angVelocity2 = 0.0f; + + _growthRate1 = _growthRate2 = 0.0f; + _exponentialGrowth = false; + + _useRegion = false; + + _emitEvent = NULL; + _owner = owner; +} + + +////////////////////////////////////////////////////////////////////////// +PartEmitter::~PartEmitter(void) { + for (uint32 i = 0; i < _particles.size(); i++) { + delete _particles[i]; + } + _particles.clear(); + + for (uint32 i = 0; i < _forces.size(); i++) { + delete _forces[i]; + } + _forces.clear(); + + + for (uint32 i = 0; i < _sprites.size(); i++) { + delete[] _sprites[i]; + } + _sprites.clear(); + + delete[] _emitEvent; + _emitEvent = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::addSprite(const char *filename) { + if (!filename) { + return STATUS_FAILED; + } + + // do we already have the file? + for (uint32 i = 0; i < _sprites.size(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + return STATUS_OK; + } + } + + // check if file exists + Common::SeekableReadStream *File = BaseFileManager::getEngineInstance()->openFile(filename); + if (!File) { + _gameRef->LOG(0, "Sprite '%s' not found", filename); + return STATUS_FAILED; + } else { + BaseFileManager::getEngineInstance()->closeFile(File); + } + + char *str = new char[strlen(filename) + 1]; + strcpy(str, filename); + _sprites.add(str); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::removeSprite(const char *filename) { + for (uint32 i = 0; i < _sprites.size(); i++) { + if (scumm_stricmp(filename, _sprites[i]) == 0) { + delete[] _sprites[i]; + _sprites.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta) { + if (!particle) { + return STATUS_FAILED; + } + if (_sprites.size() == 0) { + return STATUS_FAILED; + } + + int posX = BaseUtils::randomInt(_posX, _posX + _width); + int posY = BaseUtils::randomInt(_posY, _posY + _height); + float posZ = BaseUtils::randomFloat(0.0f, 100.0f); + + float velocity; + if (_velocityZBased) { + velocity = _velocity1 + posZ * (_velocity2 - _velocity1) / 100; + } else { + velocity = BaseUtils::randomFloat(_velocity1, _velocity2); + } + + float scale; + if (_scaleZBased) { + scale = _scale1 + posZ * (_scale2 - _scale1) / 100; + } else { + scale = BaseUtils::randomFloat(_scale1, _scale2); + } + + int lifeTime; + if (_lifeTimeZBased) { + lifeTime = (int)(_lifeTime2 - posZ * (_lifeTime2 - _lifeTime1) / 100); + } else { + lifeTime = BaseUtils::randomInt(_lifeTime1, _lifeTime2); + } + + float angle = BaseUtils::randomAngle(_angle1, _angle2); + int spriteIndex = BaseUtils::randomInt(0, _sprites.size() - 1); + + float rotation = BaseUtils::randomAngle(_rotation1, _rotation2); + float angVelocity = BaseUtils::randomFloat(_angVelocity1, _angVelocity2); + float growthRate = BaseUtils::randomFloat(_growthRate1, _growthRate2); + + if (!BasePlatform::isRectEmpty(&_border)) { + int thicknessLeft = (int)(_borderThicknessLeft - (float)_borderThicknessLeft * posZ / 100.0f); + int thicknessRight = (int)(_borderThicknessRight - (float)_borderThicknessRight * posZ / 100.0f); + int thicknessTop = (int)(_borderThicknessTop - (float)_borderThicknessTop * posZ / 100.0f); + int thicknessBottom = (int)(_borderThicknessBottom - (float)_borderThicknessBottom * posZ / 100.0f); + + particle->_border = _border; + particle->_border.left += thicknessLeft; + particle->_border.right -= thicknessRight; + particle->_border.top += thicknessTop; + particle->_border.bottom -= thicknessBottom; + } + + Vector2 vecPos((float)posX, (float)posY); + Vector2 vecVel(0, velocity); + + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(vecVel); + + if (_alphaTimeBased) { + particle->_alpha1 = _alpha1; + particle->_alpha2 = _alpha2; + } else { + int alpha = BaseUtils::randomInt(_alpha1, _alpha2); + particle->_alpha1 = alpha; + particle->_alpha2 = alpha; + } + + particle->_creationTime = currentTime; + particle->_pos = vecPos; + particle->_posZ = posZ; + particle->_velocity = vecVel; + particle->_scale = scale; + particle->_lifeTime = lifeTime; + particle->_rotation = rotation; + particle->_angVelocity = angVelocity; + particle->_growthRate = growthRate; + particle->_exponentialGrowth = _exponentialGrowth; + particle->_isDead = DID_FAIL(particle->setSprite(_sprites[spriteIndex])); + particle->fadeIn(currentTime, _fadeInTime); + + + if (particle->_isDead) { + return STATUS_FAILED; + } else { + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::update() { + if (!_running) { + return STATUS_OK; + } else { + return updateInternal(_gameRef->_timer, _gameRef->_timerDelta); + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::updateInternal(uint32 currentTime, uint32 timerDelta) { + int numLive = 0; + + for (uint32 i = 0; i < _particles.size(); i++) { + _particles[i]->update(this, currentTime, timerDelta); + + if (!_particles[i]->_isDead) { + numLive++; + } + } + + + // we're understaffed + if (numLive < _maxParticles) { + bool needsSort = false; + if ((int)(currentTime - _lastGenTime) > _genInterval) { + _lastGenTime = currentTime; + _batchesGenerated++; + + if (_maxBatches > 0 && _batchesGenerated > _maxBatches) { + return STATUS_OK; + } + + int toGen = MIN(_genAmount, _maxParticles - numLive); + while (toGen > 0) { + int firstDeadIndex = -1; + for (uint32 i = 0; i < _particles.size(); i++) { + if (_particles[i]->_isDead) { + firstDeadIndex = i; + break; + } + } + + PartParticle *particle; + if (firstDeadIndex >= 0) { + particle = _particles[firstDeadIndex]; + } else { + particle = new PartParticle(_gameRef); + _particles.add(particle); + } + initParticle(particle, currentTime, timerDelta); + needsSort = true; + + toGen--; + } + } + if (needsSort && (_scaleZBased || _velocityZBased || _lifeTimeZBased)) { + sortParticlesByZ(); + } + + // we actually generated some particles and we're not in fast-forward mode + if (needsSort && _overheadTime == 0) { + if (_owner && _emitEvent) { + _owner->applyEvent(_emitEvent); + } + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::display(BaseRegion *region) { + if (_sprites.size() <= 1) { + _gameRef->_renderer->startSpriteBatch(); + } + + for (uint32 i = 0; i < _particles.size(); i++) { + if (region != NULL && _useRegion) { + if (!region->pointInRegion((int)_particles[i]->_pos.x, (int)_particles[i]->_pos.y)) { + continue; + } + } + + _particles[i]->display(this); + } + + if (_sprites.size() <= 1) { + _gameRef->_renderer->endSpriteBatch(); + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::start() { + for (uint32 i = 0; i < _particles.size(); i++) { + _particles[i]->_isDead = true; + } + _running = true; + _batchesGenerated = 0; + + + if (_overheadTime > 0) { + uint32 delta = 500; + int steps = _overheadTime / delta; + uint32 currentTime = _gameRef->_timer - _overheadTime; + + for (int i = 0; i < steps; i++) { + updateInternal(currentTime, delta); + currentTime += delta; + } + _overheadTime = 0; + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::sortParticlesByZ() { + // sort particles by _posY + Common::sort(_particles.begin(), _particles.end(), PartEmitter::compareZ); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int PartEmitter::compareZ(const void *obj1, const void *obj2) { + const PartParticle *p1 = *(const PartParticle *const *)obj1; + const PartParticle *p2 = *(const PartParticle *const *)obj2; + + if (p1->_posZ < p2->_posZ) { + return -1; + } else if (p1->_posZ > p2->_posZ) { + return 1; + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::setBorder(int x, int y, int width, int height) { + BasePlatform::setRect(&_border, x, y, x + width, y + height); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom) { + _borderThicknessLeft = thicknessLeft; + _borderThicknessRight = thicknessRight; + _borderThicknessTop = thicknessTop; + _borderThicknessBottom = thicknessBottom; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +PartForce *PartEmitter::addForceByName(const Common::String &name) { + PartForce *force = NULL; + + for (uint32 i = 0; i < _forces.size(); i++) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { + force = _forces[i]; + break; + } + } + if (!force) { + force = new PartForce(_gameRef); + if (force) { + force->setName(name.c_str()); + _forces.add(force); + } + } + return force; +} + + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength) { + PartForce *force = addForceByName(name); + if (!force) { + return STATUS_FAILED; + } + + force->_type = type; + force->_pos = Vector2(posX, posY); + + force->_direction = Vector2(0, strength); + Matrix4 matRot; + matRot.rotationZ(Common::deg2rad(BaseUtils::normalizeAngle(angle - 180))); + matRot.transformVector2(force->_direction); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::removeForce(const Common::String &name) { + for (uint32 i = 0; i < _forces.size(); i++) { + if (scumm_stricmp(name.c_str(), _forces[i]->getName()) == 0) { + delete _forces[i]; + _forces.remove_at(i); + return STATUS_OK; + } + } + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +// high level scripting interface +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetBorder + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetBorder") == 0) { + stack->correctParams(4); + int borderX = stack->pop()->getInt(); + int borderY = stack->pop()->getInt(); + int borderWidth = stack->pop()->getInt(); + int borderHeight = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorder(borderX, borderY, borderWidth, borderHeight))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetBorderThickness + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBorderThickness") == 0) { + stack->correctParams(4); + int left = stack->pop()->getInt(); + int right = stack->pop()->getInt(); + int top = stack->pop()->getInt(); + int bottom = stack->pop()->getInt(); + + stack->pushBool(DID_SUCCEED(setBorderThickness(left, right, top, bottom))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AddSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(addSprite(spriteFile))); + + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // RemoveSprite + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveSprite") == 0) { + stack->correctParams(1); + const char *spriteFile = stack->pop()->getString(); + stack->pushBool(DID_SUCCEED(removeSprite(spriteFile))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Start + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Start") == 0) { + stack->correctParams(1); + _overheadTime = stack->pop()->getInt(); + stack->pushBool(DID_SUCCEED(start())); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Stop + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Stop") == 0) { + stack->correctParams(0); + + for (uint32 i = 0; i < _particles.size(); i++) { + delete _particles[i]; + } + _particles.clear(); + + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pause + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pause") == 0) { + stack->correctParams(0); + _running = false; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Resume + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Resume") == 0) { + stack->correctParams(0); + _running = true; + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddGlobalForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddGlobalForce") == 0) { + stack->correctParams(3); + const char *forceName = stack->pop()->getString(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, 0, 0, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AddPointForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AddPointForce") == 0) { + stack->correctParams(5); + const char *forceName = stack->pop()->getString(); + int posX = stack->pop()->getInt(); + int posY = stack->pop()->getInt(); + float angle = stack->pop()->getFloat(); + float strength = stack->pop()->getFloat(); + + stack->pushBool(DID_SUCCEED(addForce(forceName, PartForce::FORCE_GLOBAL, posX, posY, angle, strength))); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RemoveForce + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RemoveForce") == 0) { + stack->correctParams(1); + const char *forceName = stack->pop()->getString(); + + stack->pushBool(DID_SUCCEED(removeForce(forceName))); + + return STATUS_OK; + } else { + return BaseObject::scCallMethod(script, stack, thisStack, name); + } +} + +////////////////////////////////////////////////////////////////////////// +ScValue *PartEmitter::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("particle-emitter"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "X") == 0) { + _scValue->setInt(_posX); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _scValue->setInt(_posY); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _scValue->setInt(_width); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _scValue->setInt(_height); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scValue->setFloat(_scale1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scValue->setFloat(_scale2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scValue->setBool(_scaleZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _scValue->setFloat(_velocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _scValue->setFloat(_velocity2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _scValue->setBool(_velocityZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _scValue->setInt(_lifeTime1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _scValue->setInt(_lifeTime2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _scValue->setBool(_lifeTimeZBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _scValue->setInt(_angle1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _scValue->setInt(_angle2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _scValue->setFloat(_angVelocity1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _scValue->setFloat(_angVelocity2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _scValue->setFloat(_rotation1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _scValue->setFloat(_rotation2); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _scValue->setInt(_alpha1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _scValue->setInt(_alpha2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _scValue->setBool(_alphaTimeBased); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _scValue->setInt(_maxParticles); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // NumLiveParticles (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "NumLiveParticles") == 0) { + int numAlive = 0; + for (uint32 i = 0; i < _particles.size(); i++) { + if (_particles[i] && !_particles[i]->_isDead) { + numAlive++; + } + } + _scValue->setInt(numAlive); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _scValue->setInt(_genInterval); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _scValue->setInt(_genAmount); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _scValue->setInt(_maxBatches); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _scValue->setInt(_fadeInTime); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _scValue->setInt(_fadeOutTime); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _scValue->setFloat(_growthRate1); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _scValue->setFloat(_growthRate2); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _scValue->setBool(_exponentialGrowth); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _scValue->setBool(_useRegion); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + if (!_emitEvent) { + _scValue->setNULL(); + } else { + _scValue->setString(_emitEvent); + } + return _scValue; + } else { + return BaseObject::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // X + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "X") == 0) { + _posX = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Y + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Y") == 0) { + _posY = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Width + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Width") == 0) { + _width = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Height + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Height") == 0) { + _height = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Scale1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale1") == 0) { + _scale1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Scale2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Scale2") == 0) { + _scale2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ScaleZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ScaleZBased") == 0) { + _scaleZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Velocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity1") == 0) { + _velocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Velocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Velocity2") == 0) { + _velocity2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // VelocityZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "VelocityZBased") == 0) { + _velocityZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // LifeTime1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime1") == 0) { + _lifeTime1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTime2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTime2") == 0) { + _lifeTime2 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // LifeTimeZBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "LifeTimeZBased") == 0) { + _lifeTimeZBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Angle1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle1") == 0) { + _angle1 = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Angle2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Angle2") == 0) { + _angle2 = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // AngVelocity1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity1") == 0) { + _angVelocity1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AngVelocity2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AngVelocity2") == 0) { + _angVelocity2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Rotation1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation1") == 0) { + _rotation1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Rotation2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Rotation2") == 0) { + _rotation2 = value->getFloat(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Alpha1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha1") == 0) { + _alpha1 = value->getInt(); + if (_alpha1 < 0) { + _alpha1 = 0; + } + if (_alpha1 > 255) { + _alpha1 = 255; + } + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // Alpha2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Alpha2") == 0) { + _alpha2 = value->getInt(); + if (_alpha2 < 0) { + _alpha2 = 0; + } + if (_alpha2 > 255) { + _alpha2 = 255; + } + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // AlphaTimeBased + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AlphaTimeBased") == 0) { + _alphaTimeBased = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // MaxParticles + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxParticles") == 0) { + _maxParticles = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GenerationInterval + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationInterval") == 0) { + _genInterval = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GenerationAmount + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GenerationAmount") == 0) { + _genAmount = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // MaxBatches + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "MaxBatches") == 0) { + _maxBatches = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // FadeInTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeInTime") == 0) { + _fadeInTime = value->getInt(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // FadeOutTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "FadeOutTime") == 0) { + _fadeOutTime = value->getInt(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GrowthRate1 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate1") == 0) { + _growthRate1 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GrowthRate2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GrowthRate2") == 0) { + _growthRate2 = value->getFloat(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // ExponentialGrowth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ExponentialGrowth") == 0) { + _exponentialGrowth = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // UseRegion + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "UseRegion") == 0) { + _useRegion = value->getBool(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // EmitEvent + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "EmitEvent") == 0) { + delete[] _emitEvent; + _emitEvent = NULL; + if (!value->isNULL()) { + BaseUtils::setString(&_emitEvent, value->getString()); + } + return STATUS_OK; + } else { + return BaseObject::scSetProperty(name, value); + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *PartEmitter::scToString() { + return "[particle emitter]"; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool PartEmitter::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_width)); + persistMgr->transfer(TMEMBER(_height)); + + persistMgr->transfer(TMEMBER(_angle1)); + persistMgr->transfer(TMEMBER(_angle2)); + + persistMgr->transfer(TMEMBER(_velocity1)); + persistMgr->transfer(TMEMBER(_velocity2)); + persistMgr->transfer(TMEMBER(_velocityZBased)); + + persistMgr->transfer(TMEMBER(_scale1)); + persistMgr->transfer(TMEMBER(_scale2)); + persistMgr->transfer(TMEMBER(_scaleZBased)); + + persistMgr->transfer(TMEMBER(_maxParticles)); + + persistMgr->transfer(TMEMBER(_lifeTime1)); + persistMgr->transfer(TMEMBER(_lifeTime2)); + persistMgr->transfer(TMEMBER(_lifeTimeZBased)); + + persistMgr->transfer(TMEMBER(_genInterval)); + persistMgr->transfer(TMEMBER(_genAmount)); + + persistMgr->transfer(TMEMBER(_running)); + persistMgr->transfer(TMEMBER(_overheadTime)); + + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_borderThicknessLeft)); + persistMgr->transfer(TMEMBER(_borderThicknessRight)); + persistMgr->transfer(TMEMBER(_borderThicknessTop)); + persistMgr->transfer(TMEMBER(_borderThicknessBottom)); + + persistMgr->transfer(TMEMBER(_fadeInTime)); + persistMgr->transfer(TMEMBER(_fadeOutTime)); + + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_alphaTimeBased)); + + persistMgr->transfer(TMEMBER(_angVelocity1)); + persistMgr->transfer(TMEMBER(_angVelocity2)); + + persistMgr->transfer(TMEMBER(_rotation1)); + persistMgr->transfer(TMEMBER(_rotation2)); + + persistMgr->transfer(TMEMBER(_growthRate1)); + persistMgr->transfer(TMEMBER(_growthRate2)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + + persistMgr->transfer(TMEMBER(_useRegion)); + + persistMgr->transfer(TMEMBER_INT(_maxBatches)); + persistMgr->transfer(TMEMBER_INT(_batchesGenerated)); + + persistMgr->transfer(TMEMBER(_emitEvent)); + persistMgr->transfer(TMEMBER(_owner)); + + + _sprites.persist(persistMgr); + + uint32 numForces; + if (persistMgr->getIsSaving()) { + numForces = _forces.size(); + persistMgr->transfer(TMEMBER(numForces)); + for (uint32 i = 0; i < _forces.size(); i++) { + _forces[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numForces)); + for (uint32 i = 0; i < numForces; i++) { + PartForce *force = new PartForce(_gameRef); + force->persist(persistMgr); + _forces.add(force); + } + } + + uint32 numParticles; + if (persistMgr->getIsSaving()) { + numParticles = _particles.size(); + persistMgr->transfer(TMEMBER(numParticles)); + for (uint32 i = 0; i < _particles.size(); i++) { + _particles[i]->persist(persistMgr); + } + } else { + persistMgr->transfer(TMEMBER(numParticles)); + for (uint32 i = 0; i < numParticles; i++) { + PartParticle *particle = new PartParticle(_gameRef); + particle->persist(persistMgr); + _particles.add(particle); + } + } + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index dd02cf7f17..9a35cd9bbc 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -1,140 +1,140 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTEMITTER_H -#define WINTERMUTE_PARTEMITTER_H - - -#include "engines/wintermute/base/base_object.h" -#include "engines/wintermute/base/particles/part_force.h" - -namespace Wintermute { -class BaseRegion; -class PartParticle; -class PartEmitter : public BaseObject { -public: - DECLARE_PERSISTENT(PartEmitter, BaseObject) - - PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); - virtual ~PartEmitter(void); - - int _fadeOutTime; - - bool start(); - - bool update(); - bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. - bool display(BaseRegion *region); - - bool sortParticlesByZ(); - bool addSprite(const char *filename); - bool removeSprite(const char *filename); - bool setBorder(int x, int y, int width, int height); - bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); - - bool addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); - bool removeForce(const Common::String &name); - - BaseArray _forces; - - // scripting interface - virtual ScValue *scGetProperty(const char *name); - virtual bool scSetProperty(const char *name, ScValue *value); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - virtual const char *scToString(); - - -private: - int _width; - int _height; - - int _angle1; - int _angle2; - - float _rotation1; - float _rotation2; - - float _angVelocity1; - float _angVelocity2; - - float _growthRate1; - float _growthRate2; - bool _exponentialGrowth; - - float _velocity1; - float _velocity2; - bool _velocityZBased; - - float _scale1; - float _scale2; - bool _scaleZBased; - - int _maxParticles; - - int _lifeTime1; - int _lifeTime2; - bool _lifeTimeZBased; - - int _genInterval; - int _genAmount; - - bool _running; - int _overheadTime; - - int _maxBatches; - int _batchesGenerated; - - Rect32 _border; - int _borderThicknessLeft; - int _borderThicknessRight; - int _borderThicknessTop; - int _borderThicknessBottom; - - int _fadeInTime; - - int _alpha1; - int _alpha2; - bool _alphaTimeBased; - - bool _useRegion; - - char *_emitEvent; - BaseScriptHolder *_owner; - - PartForce *addForceByName(const Common::String &name); - int static compareZ(const void *obj1, const void *obj2); - bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); - bool updateInternal(uint32 currentTime, uint32 timerDelta); - uint32 _lastGenTime; - BaseArray _particles; - BaseArray _sprites; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTEMITTER_H +#define WINTERMUTE_PARTEMITTER_H + + +#include "engines/wintermute/base/base_object.h" +#include "engines/wintermute/base/particles/part_force.h" + +namespace Wintermute { +class BaseRegion; +class PartParticle; +class PartEmitter : public BaseObject { +public: + DECLARE_PERSISTENT(PartEmitter, BaseObject) + + PartEmitter(BaseGame *inGame, BaseScriptHolder *Owner); + virtual ~PartEmitter(void); + + int _fadeOutTime; + + bool start(); + + bool update(); + bool display() { return display(NULL); } // To avoid shadowing the inherited display-function. + bool display(BaseRegion *region); + + bool sortParticlesByZ(); + bool addSprite(const char *filename); + bool removeSprite(const char *filename); + bool setBorder(int x, int y, int width, int height); + bool setBorderThickness(int thicknessLeft, int thicknessRight, int thicknessTop, int thicknessBottom); + + bool addForce(const Common::String &name, PartForce::TForceType type, int posX, int posY, float angle, float strength); + bool removeForce(const Common::String &name); + + BaseArray _forces; + + // scripting interface + virtual ScValue *scGetProperty(const char *name); + virtual bool scSetProperty(const char *name, ScValue *value); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + virtual const char *scToString(); + + +private: + int _width; + int _height; + + int _angle1; + int _angle2; + + float _rotation1; + float _rotation2; + + float _angVelocity1; + float _angVelocity2; + + float _growthRate1; + float _growthRate2; + bool _exponentialGrowth; + + float _velocity1; + float _velocity2; + bool _velocityZBased; + + float _scale1; + float _scale2; + bool _scaleZBased; + + int _maxParticles; + + int _lifeTime1; + int _lifeTime2; + bool _lifeTimeZBased; + + int _genInterval; + int _genAmount; + + bool _running; + int _overheadTime; + + int _maxBatches; + int _batchesGenerated; + + Rect32 _border; + int _borderThicknessLeft; + int _borderThicknessRight; + int _borderThicknessTop; + int _borderThicknessBottom; + + int _fadeInTime; + + int _alpha1; + int _alpha2; + bool _alphaTimeBased; + + bool _useRegion; + + char *_emitEvent; + BaseScriptHolder *_owner; + + PartForce *addForceByName(const Common::String &name); + int static compareZ(const void *obj1, const void *obj2); + bool initParticle(PartParticle *particle, uint32 currentTime, uint32 timerDelta); + bool updateInternal(uint32 currentTime, uint32 timerDelta); + uint32 _lastGenTime; + BaseArray _particles; + BaseArray _sprites; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_force.cpp b/engines/wintermute/base/particles/part_force.cpp index abbaa2819d..df84162504 100644 --- a/engines/wintermute/base/particles/part_force.cpp +++ b/engines/wintermute/base/particles/part_force.cpp @@ -1,65 +1,65 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/particles/part_force.h" -#include "engines/wintermute/base/base_persistence_manager.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { - _pos = Vector2(0.0f, 0.0f); - _direction = Vector2(0.0f, 0.0f); - _type = FORCE_POINT; -} - - -////////////////////////////////////////////////////////////////////////// -PartForce::~PartForce(void) { -} - - -////////////////////////////////////////////////////////////////////////// -bool PartForce::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->getIsSaving()) { - const char *name = getName(); - persistMgr->transfer(TMEMBER(name)); - } else { - const char *name; - persistMgr->transfer(TMEMBER(name)); - setName(name); - } - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_direction)); - persistMgr->transfer(TMEMBER_INT(_type)); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/particles/part_force.h" +#include "engines/wintermute/base/base_persistence_manager.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +PartForce::PartForce(BaseGame *inGame) : BaseNamedObject(inGame) { + _pos = Vector2(0.0f, 0.0f); + _direction = Vector2(0.0f, 0.0f); + _type = FORCE_POINT; +} + + +////////////////////////////////////////////////////////////////////////// +PartForce::~PartForce(void) { +} + + +////////////////////////////////////////////////////////////////////////// +bool PartForce::persist(BasePersistenceManager *persistMgr) { + if (persistMgr->getIsSaving()) { + const char *name = getName(); + persistMgr->transfer(TMEMBER(name)); + } else { + const char *name; + persistMgr->transfer(TMEMBER(name)); + setName(name); + } + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_direction)); + persistMgr->transfer(TMEMBER_INT(_type)); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_force.h b/engines/wintermute/base/particles/part_force.h index 6903a919e9..27f4cb7d90 100644 --- a/engines/wintermute/base/particles/part_force.h +++ b/engines/wintermute/base/particles/part_force.h @@ -1,57 +1,57 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTFORCE_H -#define WINTERMUTE_PARTFORCE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/base_named_object.h" -#include "engines/wintermute/math/vector2.h" - -namespace Wintermute { - -class PartForce : public BaseNamedObject { -public: - enum TForceType { - FORCE_POINT, FORCE_GLOBAL - }; - - PartForce(BaseGame *inGame); - virtual ~PartForce(void); - - Vector2 _pos; - Vector2 _direction; - TForceType _type; - - bool persist(BasePersistenceManager *PersistMgr); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTFORCE_H +#define WINTERMUTE_PARTFORCE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/base_named_object.h" +#include "engines/wintermute/math/vector2.h" + +namespace Wintermute { + +class PartForce : public BaseNamedObject { +public: + enum TForceType { + FORCE_POINT, FORCE_GLOBAL + }; + + PartForce(BaseGame *inGame); + virtual ~PartForce(void); + + Vector2 _pos; + Vector2 _direction; + TForceType _type; + + bool persist(BasePersistenceManager *PersistMgr); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/particles/part_particle.cpp b/engines/wintermute/base/particles/part_particle.cpp index 5f523612b8..0b850d9618 100644 --- a/engines/wintermute/base/particles/part_particle.cpp +++ b/engines/wintermute/base/particles/part_particle.cpp @@ -1,269 +1,269 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/particles/part_particle.h" -#include "engines/wintermute/base/particles/part_emitter.h" -#include "engines/wintermute/base/base_sprite.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/platform_osystem.h" -#include "common/str.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////////// -PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { - _pos = Vector2(0.0f, 0.0f); - _posZ = 0.0f; - _velocity = Vector2(0.0f, 0.0f); - _scale = 100.0f; - _sprite = NULL; - _creationTime = 0; - _lifeTime = 0; - _isDead = true; - BasePlatform::setRectEmpty(&_border); - - _state = PARTICLE_NORMAL; - _fadeStart = 0; - _fadeTime = 0; - _currentAlpha = 255; - - _alpha1 = _alpha2 = 255; - - _rotation = 0.0f; - _angVelocity = 0.0f; - - _growthRate = 0.0f; - _exponentialGrowth = false; -} - - -////////////////////////////////////////////////////////////////////////// -PartParticle::~PartParticle(void) { - delete _sprite; - _sprite = NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::setSprite(const Common::String &filename) { - if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { - _sprite->reset(); - return STATUS_OK; - } - - delete _sprite; - _sprite = NULL; - - SystemClassRegistry::getInstance()->_disabled = true; - _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); - if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { - SystemClassRegistry::getInstance()->_disabled = false; - return STATUS_OK; - } else { - delete _sprite; - _sprite = NULL; - SystemClassRegistry::getInstance()->_disabled = false; - return STATUS_FAILED; - } - -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { - if (_state == PARTICLE_FADEIN) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _state = PARTICLE_NORMAL; - _currentAlpha = _alpha1; - } else { - _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); - } - - return STATUS_OK; - } else if (_state == PARTICLE_FADEOUT) { - if (currentTime - _fadeStart >= (uint32)_fadeTime) { - _isDead = true; - return STATUS_OK; - } else { - _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); - } - - return STATUS_OK; - } else { - // time is up - if (_lifeTime > 0) { - if (currentTime - _creationTime >= (uint32)_lifeTime) { - if (emitter->_fadeOutTime > 0) { - fadeOut(currentTime, emitter->_fadeOutTime); - } else { - _isDead = true; - } - } - } - - // particle hit the border - if (!_isDead && !BasePlatform::isRectEmpty(&_border)) { - Point32 p; - p.x = (int32)_pos.x; - p.y = (int32)_pos.y; - if (!BasePlatform::ptInRect(&_border, p)) { - fadeOut(currentTime, emitter->_fadeOutTime); - } - } - if (_state != PARTICLE_NORMAL) { - return STATUS_OK; - } - - // update alpha - if (_lifeTime > 0) { - int age = (int)(currentTime - _creationTime); - int alphaDelta = (int)(_alpha2 - _alpha1); - - _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); - } - - // update position - float elapsedTime = (float)timerDelta / 1000.f; - - for (uint32 i = 0; i < emitter->_forces.size(); i++) { - PartForce *force = emitter->_forces[i]; - switch (force->_type) { - case PartForce::FORCE_GLOBAL: - _velocity += force->_direction * elapsedTime; - break; - - case PartForce::FORCE_POINT: { - Vector2 vecDist = force->_pos - _pos; - float dist = fabs(vecDist.length()); - - dist = 100.0f / dist; - - _velocity += force->_direction * dist * elapsedTime; - } - break; - } - } - _pos += _velocity * elapsedTime; - - // update rotation - _rotation += _angVelocity * elapsedTime; - _rotation = BaseUtils::normalizeAngle(_rotation); - - // update scale - if (_exponentialGrowth) { - _scale += _scale / 100.0f * _growthRate * elapsedTime; - } else { - _scale += _growthRate * elapsedTime; - } - - if (_scale <= 0.0f) { - _isDead = true; - } - - - return STATUS_OK; - } -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::display(PartEmitter *emitter) { - if (!_sprite) { - return STATUS_FAILED; - } - if (_isDead) { - return STATUS_OK; - } - - _sprite->getCurrentFrame(); - return _sprite->display((int)_pos.x, (int)_pos.y, - NULL, - _scale, _scale, - BYTETORGBA(255, 255, 255, _currentAlpha), - _rotation, - emitter->_blendMode); -} - - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { - _currentAlpha = 0; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEIN; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { - //_currentAlpha = 255; - _fadeStartAlpha = _currentAlpha; - _fadeStart = currentTime; - _fadeTime = fadeTime; - _state = PARTICLE_FADEOUT; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool PartParticle::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_alpha1)); - persistMgr->transfer(TMEMBER(_alpha2)); - persistMgr->transfer(TMEMBER(_border)); - persistMgr->transfer(TMEMBER(_pos)); - persistMgr->transfer(TMEMBER(_posZ)); - persistMgr->transfer(TMEMBER(_velocity)); - persistMgr->transfer(TMEMBER(_scale)); - persistMgr->transfer(TMEMBER(_creationTime)); - persistMgr->transfer(TMEMBER(_lifeTime)); - persistMgr->transfer(TMEMBER(_isDead)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_fadeStart)); - persistMgr->transfer(TMEMBER(_fadeTime)); - persistMgr->transfer(TMEMBER(_currentAlpha)); - persistMgr->transfer(TMEMBER(_angVelocity)); - persistMgr->transfer(TMEMBER(_rotation)); - persistMgr->transfer(TMEMBER(_growthRate)); - persistMgr->transfer(TMEMBER(_exponentialGrowth)); - persistMgr->transfer(TMEMBER(_fadeStartAlpha)); - - if (persistMgr->getIsSaving()) { - const char *filename = _sprite->getFilename(); - persistMgr->transfer(TMEMBER(filename)); - } else { - char *filename; - persistMgr->transfer(TMEMBER(filename)); - SystemClassRegistry::getInstance()->_disabled = true; - setSprite(filename); - SystemClassRegistry::getInstance()->_disabled = false; - delete[] filename; - filename = NULL; - } - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/particles/part_particle.h" +#include "engines/wintermute/base/particles/part_emitter.h" +#include "engines/wintermute/base/base_sprite.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/platform_osystem.h" +#include "common/str.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////////// +PartParticle::PartParticle(BaseGame *inGame) : BaseClass(inGame) { + _pos = Vector2(0.0f, 0.0f); + _posZ = 0.0f; + _velocity = Vector2(0.0f, 0.0f); + _scale = 100.0f; + _sprite = NULL; + _creationTime = 0; + _lifeTime = 0; + _isDead = true; + BasePlatform::setRectEmpty(&_border); + + _state = PARTICLE_NORMAL; + _fadeStart = 0; + _fadeTime = 0; + _currentAlpha = 255; + + _alpha1 = _alpha2 = 255; + + _rotation = 0.0f; + _angVelocity = 0.0f; + + _growthRate = 0.0f; + _exponentialGrowth = false; +} + + +////////////////////////////////////////////////////////////////////////// +PartParticle::~PartParticle(void) { + delete _sprite; + _sprite = NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::setSprite(const Common::String &filename) { + if (_sprite && _sprite->getFilename() && scumm_stricmp(filename.c_str(), _sprite->getFilename()) == 0) { + _sprite->reset(); + return STATUS_OK; + } + + delete _sprite; + _sprite = NULL; + + SystemClassRegistry::getInstance()->_disabled = true; + _sprite = new BaseSprite(_gameRef, (BaseObject*)_gameRef); + if (_sprite && DID_SUCCEED(_sprite->loadFile(filename))) { + SystemClassRegistry::getInstance()->_disabled = false; + return STATUS_OK; + } else { + delete _sprite; + _sprite = NULL; + SystemClassRegistry::getInstance()->_disabled = false; + return STATUS_FAILED; + } + +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta) { + if (_state == PARTICLE_FADEIN) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _state = PARTICLE_NORMAL; + _currentAlpha = _alpha1; + } else { + _currentAlpha = (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _alpha1); + } + + return STATUS_OK; + } else if (_state == PARTICLE_FADEOUT) { + if (currentTime - _fadeStart >= (uint32)_fadeTime) { + _isDead = true; + return STATUS_OK; + } else { + _currentAlpha = _fadeStartAlpha - (int)(((float)currentTime - (float)_fadeStart) / (float)_fadeTime * _fadeStartAlpha); + } + + return STATUS_OK; + } else { + // time is up + if (_lifeTime > 0) { + if (currentTime - _creationTime >= (uint32)_lifeTime) { + if (emitter->_fadeOutTime > 0) { + fadeOut(currentTime, emitter->_fadeOutTime); + } else { + _isDead = true; + } + } + } + + // particle hit the border + if (!_isDead && !BasePlatform::isRectEmpty(&_border)) { + Point32 p; + p.x = (int32)_pos.x; + p.y = (int32)_pos.y; + if (!BasePlatform::ptInRect(&_border, p)) { + fadeOut(currentTime, emitter->_fadeOutTime); + } + } + if (_state != PARTICLE_NORMAL) { + return STATUS_OK; + } + + // update alpha + if (_lifeTime > 0) { + int age = (int)(currentTime - _creationTime); + int alphaDelta = (int)(_alpha2 - _alpha1); + + _currentAlpha = _alpha1 + (int)(((float)alphaDelta / (float)_lifeTime * (float)age)); + } + + // update position + float elapsedTime = (float)timerDelta / 1000.f; + + for (uint32 i = 0; i < emitter->_forces.size(); i++) { + PartForce *force = emitter->_forces[i]; + switch (force->_type) { + case PartForce::FORCE_GLOBAL: + _velocity += force->_direction * elapsedTime; + break; + + case PartForce::FORCE_POINT: { + Vector2 vecDist = force->_pos - _pos; + float dist = fabs(vecDist.length()); + + dist = 100.0f / dist; + + _velocity += force->_direction * dist * elapsedTime; + } + break; + } + } + _pos += _velocity * elapsedTime; + + // update rotation + _rotation += _angVelocity * elapsedTime; + _rotation = BaseUtils::normalizeAngle(_rotation); + + // update scale + if (_exponentialGrowth) { + _scale += _scale / 100.0f * _growthRate * elapsedTime; + } else { + _scale += _growthRate * elapsedTime; + } + + if (_scale <= 0.0f) { + _isDead = true; + } + + + return STATUS_OK; + } +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::display(PartEmitter *emitter) { + if (!_sprite) { + return STATUS_FAILED; + } + if (_isDead) { + return STATUS_OK; + } + + _sprite->getCurrentFrame(); + return _sprite->display((int)_pos.x, (int)_pos.y, + NULL, + _scale, _scale, + BYTETORGBA(255, 255, 255, _currentAlpha), + _rotation, + emitter->_blendMode); +} + + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::fadeIn(uint32 currentTime, int fadeTime) { + _currentAlpha = 0; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEIN; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::fadeOut(uint32 currentTime, int fadeTime) { + //_currentAlpha = 255; + _fadeStartAlpha = _currentAlpha; + _fadeStart = currentTime; + _fadeTime = fadeTime; + _state = PARTICLE_FADEOUT; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool PartParticle::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_alpha1)); + persistMgr->transfer(TMEMBER(_alpha2)); + persistMgr->transfer(TMEMBER(_border)); + persistMgr->transfer(TMEMBER(_pos)); + persistMgr->transfer(TMEMBER(_posZ)); + persistMgr->transfer(TMEMBER(_velocity)); + persistMgr->transfer(TMEMBER(_scale)); + persistMgr->transfer(TMEMBER(_creationTime)); + persistMgr->transfer(TMEMBER(_lifeTime)); + persistMgr->transfer(TMEMBER(_isDead)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_fadeStart)); + persistMgr->transfer(TMEMBER(_fadeTime)); + persistMgr->transfer(TMEMBER(_currentAlpha)); + persistMgr->transfer(TMEMBER(_angVelocity)); + persistMgr->transfer(TMEMBER(_rotation)); + persistMgr->transfer(TMEMBER(_growthRate)); + persistMgr->transfer(TMEMBER(_exponentialGrowth)); + persistMgr->transfer(TMEMBER(_fadeStartAlpha)); + + if (persistMgr->getIsSaving()) { + const char *filename = _sprite->getFilename(); + persistMgr->transfer(TMEMBER(filename)); + } else { + char *filename; + persistMgr->transfer(TMEMBER(filename)); + SystemClassRegistry::getInstance()->_disabled = true; + setSprite(filename); + SystemClassRegistry::getInstance()->_disabled = false; + delete[] filename; + filename = NULL; + } + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/particles/part_particle.h b/engines/wintermute/base/particles/part_particle.h index 3c8fc2c68b..4b8c2f131e 100644 --- a/engines/wintermute/base/particles/part_particle.h +++ b/engines/wintermute/base/particles/part_particle.h @@ -1,90 +1,90 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_PARTPARTICLE_H -#define WINTERMUTE_PARTPARTICLE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/math/rect32.h" -#include "engines/wintermute/math/vector2.h" - -namespace Wintermute { - -class PartEmitter; -class BaseSprite; -class BasePersistenceManager; - -class PartParticle : public BaseClass { -public: - enum TParticleState { - PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT - }; - - PartParticle(BaseGame *inGame); - virtual ~PartParticle(void); - - float _growthRate; - bool _exponentialGrowth; - - float _rotation; - float _angVelocity; - - int _alpha1; - int _alpha2; - - Rect32 _border; - Vector2 _pos; - float _posZ; - Vector2 _velocity; - float _scale; - BaseSprite *_sprite; - uint32 _creationTime; - int _lifeTime; - bool _isDead; - TParticleState _state; - - bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); - bool display(PartEmitter *emitter); - - bool setSprite(const Common::String &filename); - - bool fadeIn(uint32 currentTime, int fadeTime); - bool fadeOut(uint32 currentTime, int fadeTime); - - bool persist(BasePersistenceManager *PersistMgr); -private: - uint32 _fadeStart; - int _fadeTime; - int _currentAlpha; - int _fadeStartAlpha; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_PARTPARTICLE_H +#define WINTERMUTE_PARTPARTICLE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/math/rect32.h" +#include "engines/wintermute/math/vector2.h" + +namespace Wintermute { + +class PartEmitter; +class BaseSprite; +class BasePersistenceManager; + +class PartParticle : public BaseClass { +public: + enum TParticleState { + PARTICLE_NORMAL, PARTICLE_FADEIN, PARTICLE_FADEOUT + }; + + PartParticle(BaseGame *inGame); + virtual ~PartParticle(void); + + float _growthRate; + bool _exponentialGrowth; + + float _rotation; + float _angVelocity; + + int _alpha1; + int _alpha2; + + Rect32 _border; + Vector2 _pos; + float _posZ; + Vector2 _velocity; + float _scale; + BaseSprite *_sprite; + uint32 _creationTime; + int _lifeTime; + bool _isDead; + TParticleState _state; + + bool update(PartEmitter *emitter, uint32 currentTime, uint32 timerDelta); + bool display(PartEmitter *emitter); + + bool setSprite(const Common::String &filename); + + bool fadeIn(uint32 currentTime, int fadeTime); + bool fadeOut(uint32 currentTime, int fadeTime); + + bool persist(BasePersistenceManager *PersistMgr); +private: + uint32 _fadeStart; + int _fadeTime; + int _currentAlpha; + int _fadeStartAlpha; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/dcscript.h b/engines/wintermute/base/scriptables/dcscript.h index 6810fdf665..4aae897dc2 100644 --- a/engines/wintermute/base/scriptables/dcscript.h +++ b/engines/wintermute/base/scriptables/dcscript.h @@ -1,141 +1,141 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_DCSCRIPT_H -#define WINTERMUTE_DCSCRIPT_H - -namespace Wintermute { - -#define SCRIPT_MAGIC 0xDEC0ADDE -#define SCRIPT_VERSION 0x0102 - -// value types -typedef enum { - VAL_NULL, - VAL_STRING, - VAL_INT, - VAL_BOOL, - VAL_FLOAT, - VAL_OBJECT, - VAL_NATIVE, - VAL_VARIABLE_REF -} TValType; - - -// script states -typedef enum { - SCRIPT_RUNNING, - SCRIPT_WAITING, - SCRIPT_SLEEPING, - SCRIPT_FINISHED, - SCRIPT_PERSISTENT, - SCRIPT_ERROR, - SCRIPT_PAUSED, - SCRIPT_WAITING_SCRIPT, - SCRIPT_THREAD_FINISHED -} TScriptState; - -// opcodes -typedef enum { - II_DEF_VAR = 0, - II_DEF_GLOB_VAR, - II_RET, - II_RET_EVENT, - II_CALL, - II_CALL_BY_EXP, - II_EXTERNAL_CALL, - II_SCOPE, - II_CORRECT_STACK, - II_CREATE_OBJECT, - II_POP_EMPTY, - II_PUSH_VAR, - II_PUSH_VAR_REF, - II_POP_VAR, - II_PUSH_VAR_THIS, // push current this on stack - II_PUSH_INT, - II_PUSH_BOOL, - II_PUSH_FLOAT, - II_PUSH_STRING, - II_PUSH_NULL, - II_PUSH_THIS_FROM_STACK, - II_PUSH_THIS, - II_POP_THIS, - II_PUSH_BY_EXP, - II_POP_BY_EXP, - II_JMP, - II_JMP_FALSE, - II_ADD, - II_SUB, - II_MUL, - II_DIV, - II_MODULO, - II_NOT, - II_AND, - II_OR, - II_CMP_EQ, - II_CMP_NE, - II_CMP_L, - II_CMP_G, - II_CMP_LE, - II_CMP_GE, - II_CMP_STRICT_EQ, - II_CMP_STRICT_NE, - II_DBG_LINE, - II_POP_REG1, - II_PUSH_REG1, - II_DEF_CONST_VAR -} TInstruction; - -// external data types -typedef enum { - TYPE_VOID = 0, - TYPE_BOOL, - TYPE_LONG, - TYPE_BYTE, - TYPE_STRING, - TYPE_FLOAT, - TYPE_DOUBLE, - TYPE_MEMBUFFER -} TExternalType; - - -// call types -typedef enum { - CALL_STDCALL = 0, - CALL_CDECL, - CALL_THISCALL -} TCallType; - -// element types -typedef enum { - ELEMENT_STRING = 0 -} TElementType; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_DCSCRIPT_H +#define WINTERMUTE_DCSCRIPT_H + +namespace Wintermute { + +#define SCRIPT_MAGIC 0xDEC0ADDE +#define SCRIPT_VERSION 0x0102 + +// value types +typedef enum { + VAL_NULL, + VAL_STRING, + VAL_INT, + VAL_BOOL, + VAL_FLOAT, + VAL_OBJECT, + VAL_NATIVE, + VAL_VARIABLE_REF +} TValType; + + +// script states +typedef enum { + SCRIPT_RUNNING, + SCRIPT_WAITING, + SCRIPT_SLEEPING, + SCRIPT_FINISHED, + SCRIPT_PERSISTENT, + SCRIPT_ERROR, + SCRIPT_PAUSED, + SCRIPT_WAITING_SCRIPT, + SCRIPT_THREAD_FINISHED +} TScriptState; + +// opcodes +typedef enum { + II_DEF_VAR = 0, + II_DEF_GLOB_VAR, + II_RET, + II_RET_EVENT, + II_CALL, + II_CALL_BY_EXP, + II_EXTERNAL_CALL, + II_SCOPE, + II_CORRECT_STACK, + II_CREATE_OBJECT, + II_POP_EMPTY, + II_PUSH_VAR, + II_PUSH_VAR_REF, + II_POP_VAR, + II_PUSH_VAR_THIS, // push current this on stack + II_PUSH_INT, + II_PUSH_BOOL, + II_PUSH_FLOAT, + II_PUSH_STRING, + II_PUSH_NULL, + II_PUSH_THIS_FROM_STACK, + II_PUSH_THIS, + II_POP_THIS, + II_PUSH_BY_EXP, + II_POP_BY_EXP, + II_JMP, + II_JMP_FALSE, + II_ADD, + II_SUB, + II_MUL, + II_DIV, + II_MODULO, + II_NOT, + II_AND, + II_OR, + II_CMP_EQ, + II_CMP_NE, + II_CMP_L, + II_CMP_G, + II_CMP_LE, + II_CMP_GE, + II_CMP_STRICT_EQ, + II_CMP_STRICT_NE, + II_DBG_LINE, + II_POP_REG1, + II_PUSH_REG1, + II_DEF_CONST_VAR +} TInstruction; + +// external data types +typedef enum { + TYPE_VOID = 0, + TYPE_BOOL, + TYPE_LONG, + TYPE_BYTE, + TYPE_STRING, + TYPE_FLOAT, + TYPE_DOUBLE, + TYPE_MEMBUFFER +} TExternalType; + + +// call types +typedef enum { + CALL_STDCALL = 0, + CALL_CDECL, + CALL_THISCALL +} TCallType; + +// element types +typedef enum { + ELEMENT_STRING = 0 +} TElementType; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script.cpp b/engines/wintermute/base/scriptables/script.cpp index 269ea1ea03..9469bd46a7 100644 --- a/engines/wintermute/base/scriptables/script.cpp +++ b/engines/wintermute/base/scriptables/script.cpp @@ -1,1467 +1,1467 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "common/memstream.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(ScScript, false) - -////////////////////////////////////////////////////////////////////////// -ScScript::ScScript(BaseGame *inGame, ScEngine *engine) : BaseClass(inGame) { - _buffer = NULL; - _bufferSize = _iP = 0; - _scriptStream = NULL; - _filename = NULL; - _currentLine = 0; - - _symbols = NULL; - _numSymbols = 0; - - _engine = engine; - - _globals = NULL; - - _scopeStack = NULL; - _callStack = NULL; - _thisStack = NULL; - _stack = NULL; - - _operand = NULL; - _reg1 = NULL; - - _functions = NULL; - _numFunctions = 0; - - _methods = NULL; - _numMethods = 0; - - _events = NULL; - _numEvents = 0; - - _externals = NULL; - _numExternals = 0; - - _state = SCRIPT_FINISHED; - _origState = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _timeSlice = 0; - - _thread = false; - _methodThread = false; - _threadEvent = NULL; - - _freezable = true; - _owner = NULL; - - _unbreakable = false; - _parentScript = NULL; - - _tracingMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript::~ScScript() { - cleanup(); -} - -void ScScript::readHeader() { - uint32 oldPos = _scriptStream->pos(); - _scriptStream->seek(0); - _header.magic = _scriptStream->readUint32LE(); - _header.version = _scriptStream->readUint32LE(); - _header.codeStart = _scriptStream->readUint32LE(); - _header.funcTable = _scriptStream->readUint32LE(); - _header.symbolTable = _scriptStream->readUint32LE(); - _header.eventTable = _scriptStream->readUint32LE(); - _header.externalsTable = _scriptStream->readUint32LE(); - _header.methodTable = _scriptStream->readUint32LE(); - _scriptStream->seek(oldPos); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::initScript() { - if (!_scriptStream) { - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - } - readHeader(); - - if (_header.magic != SCRIPT_MAGIC) { - _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); - cleanup(); - return STATUS_FAILED; - } - - if (_header.version > SCRIPT_VERSION) { - _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); - cleanup(); - return STATUS_FAILED; - } - - initTables(); - - // init stacks - _scopeStack = new ScStack(_gameRef); - _callStack = new ScStack(_gameRef); - _thisStack = new ScStack(_gameRef); - _stack = new ScStack(_gameRef); - - _operand = new ScValue(_gameRef); - _reg1 = new ScValue(_gameRef); - - - // skip to the beginning - _iP = _header.codeStart; - _scriptStream->seek(_iP); - _currentLine = 0; - - // ready to rumble... - _state = SCRIPT_RUNNING; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::initTables() { - uint32 origIP = _iP; - - readHeader(); - // load symbol table - _iP = _header.symbolTable; - - _numSymbols = getDWORD(); - _symbols = new char*[_numSymbols]; - for (uint32 i = 0; i < _numSymbols; i++) { - uint32 index = getDWORD(); - _symbols[index] = getString(); - } - - // load functions table - _iP = _header.funcTable; - - _numFunctions = getDWORD(); - _functions = new TFunctionPos[_numFunctions]; - for (uint32 i = 0; i < _numFunctions; i++) { - _functions[i].pos = getDWORD(); - _functions[i].name = getString(); - } - - - // load events table - _iP = _header.eventTable; - - _numEvents = getDWORD(); - _events = new TEventPos[_numEvents]; - for (uint32 i = 0; i < _numEvents; i++) { - _events[i].pos = getDWORD(); - _events[i].name = getString(); - } - - - // load externals - if (_header.version >= 0x0101) { - _iP = _header.externalsTable; - - _numExternals = getDWORD(); - _externals = new TExternalFunction[_numExternals]; - for (uint32 i = 0; i < _numExternals; i++) { - _externals[i].dll_name = getString(); - _externals[i].name = getString(); - _externals[i].call_type = (TCallType)getDWORD(); - _externals[i].returns = (TExternalType)getDWORD(); - _externals[i].nu_params = getDWORD(); - if (_externals[i].nu_params > 0) { - _externals[i].params = new TExternalType[_externals[i].nu_params]; - for (int j = 0; j < _externals[i].nu_params; j++) { - _externals[i].params[j] = (TExternalType)getDWORD(); - } - } - } - } - - // load method table - _iP = _header.methodTable; - - _numMethods = getDWORD(); - _methods = new TMethodPos[_numMethods]; - for (uint32 i = 0; i < _numMethods; i++) { - _methods[i].pos = getDWORD(); - _methods[i].name = getString(); - } - - - _iP = origIP; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner) { - cleanup(); - - _thread = false; - _methodThread = false; - - delete[] _threadEvent; - _threadEvent = NULL; - - _filename = new char[strlen(filename) + 1]; - if (_filename) { - strcpy(_filename, filename); - } - - _buffer = new byte [size]; - if (!_buffer) { - return STATUS_FAILED; - } - - memcpy(_buffer, buffer, size); - - _bufferSize = size; - - bool res = initScript(); - if (DID_FAIL(res)) { - return res; - } - - // establish global variables table - _globals = new ScValue(_gameRef); - - _owner = owner; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { - cleanup(); - - _thread = true; - _methodThread = false; - _threadEvent = new char[eventName.size() + 1]; - if (_threadEvent) { - strcpy(_threadEvent, eventName.c_str()); - } - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) { - strcpy(_filename, original->_filename); - } - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) { - return STATUS_FAILED; - } - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) { - return res; - } - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = initIP; - _scriptStream->seek(_iP); - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { - uint32 ip = original->getMethodPos(methodName); - if (ip == 0) { - return STATUS_FAILED; - } - - cleanup(); - - _thread = true; - _methodThread = true; - _threadEvent = new char[methodName.size() + 1]; - if (_threadEvent) { - strcpy(_threadEvent, methodName.c_str()); - } - - // copy filename - _filename = new char[strlen(original->_filename) + 1]; - if (_filename) { - strcpy(_filename, original->_filename); - } - - // copy buffer - _buffer = new byte [original->_bufferSize]; - if (!_buffer) { - return STATUS_FAILED; - } - - memcpy(_buffer, original->_buffer, original->_bufferSize); - _bufferSize = original->_bufferSize; - - // initialize - bool res = initScript(); - if (DID_FAIL(res)) { - return res; - } - - // copy globals - _globals = original->_globals; - - // skip to the beginning of the event - _iP = ip; - - _timeSlice = original->_timeSlice; - _freezable = original->_freezable; - _owner = original->_owner; - - _engine = original->_engine; - _parentScript = original; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void ScScript::cleanup() { - if (_buffer) { - delete[] _buffer; - } - _buffer = NULL; - - if (_filename) { - delete[] _filename; - } - _filename = NULL; - - if (_symbols) { - delete[] _symbols; - } - _symbols = NULL; - _numSymbols = 0; - - if (_globals && !_thread) { - delete _globals; - } - _globals = NULL; - - delete _scopeStack; - _scopeStack = NULL; - - delete _callStack; - _callStack = NULL; - - delete _thisStack; - _thisStack = NULL; - - delete _stack; - _stack = NULL; - - if (_functions) { - delete[] _functions; - } - _functions = NULL; - _numFunctions = 0; - - if (_methods) { - delete[] _methods; - } - _methods = NULL; - _numMethods = 0; - - if (_events) { - delete[] _events; - } - _events = NULL; - _numEvents = 0; - - - if (_externals) { - for (uint32 i = 0; i < _numExternals; i++) { - if (_externals[i].nu_params > 0) { - delete[] _externals[i].params; - } - } - delete[] _externals; - } - _externals = NULL; - _numExternals = 0; - - delete _operand; - delete _reg1; - _operand = NULL; - _reg1 = NULL; - - delete[] _threadEvent; - _threadEvent = NULL; - - _state = SCRIPT_FINISHED; - - _waitObject = NULL; - _waitTime = 0; - _waitFrozen = false; - _waitScript = NULL; - - _parentScript = NULL; // ref only - - delete _scriptStream; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getDWORD() { - _scriptStream->seek((int32)_iP); - uint32 ret = _scriptStream->readUint32LE(); - _iP += sizeof(uint32); -// assert(oldRet == ret); - return ret; -} - -////////////////////////////////////////////////////////////////////////// -double ScScript::getFloat() { - _scriptStream->seek((int32)_iP); - byte buffer[8]; - _scriptStream->read(buffer, 8); - -#ifdef SCUMM_BIG_ENDIAN - // TODO: For lack of a READ_LE_UINT64 - SWAP(buffer[0], buffer[7]); - SWAP(buffer[1], buffer[6]); - SWAP(buffer[2], buffer[5]); - SWAP(buffer[3], buffer[4]); -#endif - - double ret = *(double *)(buffer); - _iP += 8; // Hardcode the double-size used originally. - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -char *ScScript::getString() { - char *ret = (char *)(_buffer + _iP); - while (*(char *)(_buffer + _iP) != '\0') { - _iP++; - } - _iP++; // string terminator - _scriptStream->seek(_iP); - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::executeInstruction() { - bool ret = STATUS_OK; - - uint32 dw; - const char *str = NULL; - - //ScValue* op = new ScValue(_gameRef); - _operand->cleanup(); - - ScValue *op1; - ScValue *op2; - - uint32 inst = getDWORD(); - switch (inst) { - - case II_DEF_VAR: - _operand->setNULL(); - dw = getDWORD(); - if (_scopeStack->_sP < 0) { - _globals->setProp(_symbols[dw], _operand); - } else { - _scopeStack->getTop()->setProp(_symbols[dw], _operand); - } - - break; - - case II_DEF_GLOB_VAR: - case II_DEF_CONST_VAR: { - dw = getDWORD(); - /* char *temp = _symbols[dw]; // TODO delete */ - // only create global var if it doesn't exist - if (!_engine->_globals->propExists(_symbols[dw])) { - _operand->setNULL(); - _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); - } - break; - } - - case II_RET: - if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { - _scopeStack->pop(); - _iP = (uint32)_callStack->pop()->getInt(); - } else { - if (_thread) { - _state = SCRIPT_THREAD_FINISHED; - } else { - if (_numEvents == 0 && _numMethods == 0) { - _state = SCRIPT_FINISHED; - } else { - _state = SCRIPT_PERSISTENT; - } - } - } - - break; - - case II_RET_EVENT: - _state = SCRIPT_FINISHED; - break; - - - case II_CALL: - dw = getDWORD(); - - _operand->setInt(_iP); - _callStack->push(_operand); - - _iP = dw; - - break; - - case II_CALL_BY_EXP: { - // push var - // push string - str = _stack->pop()->getString(); - char *methodName = new char[strlen(str) + 1]; - strcpy(methodName, str); - - ScValue *var = _stack->pop(); - if (var->_type == VAL_VARIABLE_REF) { - var = var->_valRef; - } - - bool res = STATUS_FAILED; - bool triedNative = false; - - // we are already calling this method, try native - if (_thread && _methodThread && strcmp(methodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { - triedNative = true; - res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); - } - - if (DID_FAIL(res)) { - if (var->isNative() && var->getNative()->canHandleMethod(methodName)) { - if (!_unbreakable) { - _waitScript = var->getNative()->invokeMethodThread(methodName); - if (!_waitScript) { - _stack->correctParams(0); - runtimeError("Error invoking method '%s'.", methodName); - _stack->pushNULL(); - } else { - _state = SCRIPT_WAITING_SCRIPT; - _waitScript->copyParameters(_stack); - } - } else { - // can call methods in unbreakable mode - _stack->correctParams(0); - runtimeError("Cannot call method '%s'. Ignored.", methodName); - _stack->pushNULL(); - } - delete[] methodName; - break; - } - /* - ScValue* val = var->getProp(MethodName); - if (val){ - dw = GetFuncPos(val->getString()); - if (dw==0){ - TExternalFunction* f = GetExternal(val->getString()); - if (f){ - ExternalCall(_stack, _thisStack, f); - } - else{ - // not an internal nor external, try for native function - _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); - } - } - else{ - _operand->setInt(_iP); - _callStack->Push(_operand); - _iP = dw; - } - } - */ - else { - res = STATUS_FAILED; - if (var->_type == VAL_NATIVE && !triedNative) { - res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); - } - - if (DID_FAIL(res)) { - _stack->correctParams(0); - runtimeError("Call to undefined method '%s'. Ignored.", methodName); - _stack->pushNULL(); - } - } - } - delete[] methodName; - } - break; - - case II_EXTERNAL_CALL: { - uint32 symbolIndex = getDWORD(); - - TExternalFunction *f = getExternal(_symbols[symbolIndex]); - if (f) { - externalCall(_stack, _thisStack, f); - } else { - _gameRef->externalCall(this, _stack, _thisStack, _symbols[symbolIndex]); - } - - break; - } - case II_SCOPE: - _operand->setNULL(); - _scopeStack->push(_operand); - break; - - case II_CORRECT_STACK: - dw = getDWORD(); // params expected - _stack->correctParams(dw); - break; - - case II_CREATE_OBJECT: - _operand->setObject(); - _stack->push(_operand); - break; - - case II_POP_EMPTY: - _stack->pop(); - break; - - case II_PUSH_VAR: { - ScValue *var = getVar(_symbols[getDWORD()]); - if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { - _operand->setReference(var); - _stack->push(_operand); - } else { - _stack->push(var); - } - break; - } - - case II_PUSH_VAR_REF: { - ScValue *var = getVar(_symbols[getDWORD()]); - _operand->setReference(var); - _stack->push(_operand); - break; - } - - case II_POP_VAR: { - char *varName = _symbols[getDWORD()]; - ScValue *var = getVar(varName); - if (var) { - ScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else { - if (val->getType() == VAL_VARIABLE_REF) { - val = val->_valRef; - } - if (val->_type == VAL_NATIVE) { - var->setValue(val); - } else { - var->copy(val); - } - } - } - - break; - } - - case II_PUSH_VAR_THIS: - _stack->push(_thisStack->getTop()); - break; - - case II_PUSH_INT: - _stack->pushInt((int)getDWORD()); - break; - - case II_PUSH_FLOAT: - _stack->pushFloat(getFloat()); - break; - - - case II_PUSH_BOOL: - _stack->pushBool(getDWORD() != 0); - - break; - - case II_PUSH_STRING: - _stack->pushString(getString()); - break; - - case II_PUSH_NULL: - _stack->pushNULL(); - break; - - case II_PUSH_THIS_FROM_STACK: - _operand->setReference(_stack->getTop()); - _thisStack->push(_operand); - break; - - case II_PUSH_THIS: - _operand->setReference(getVar(_symbols[getDWORD()])); - _thisStack->push(_operand); - break; - - case II_POP_THIS: - _thisStack->pop(); - break; - - case II_PUSH_BY_EXP: { - str = _stack->pop()->getString(); - ScValue *val = _stack->pop()->getProp(str); - if (val) { - _stack->push(val); - } else { - _stack->pushNULL(); - } - - break; - } - - case II_POP_BY_EXP: { - str = _stack->pop()->getString(); - ScValue *var = _stack->pop(); - ScValue *val = _stack->pop(); - - if (val == NULL) { - runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); - var->setNULL(); - } else { - var->setProp(str, val); - } - - break; - } - - case II_PUSH_REG1: - _stack->push(_reg1); - break; - - case II_POP_REG1: - _reg1->copy(_stack->pop()); - break; - - case II_JMP: - _iP = getDWORD(); - break; - - case II_JMP_FALSE: { - dw = getDWORD(); - //if (!_stack->pop()->getBool()) _iP = dw; - ScValue *val = _stack->pop(); - if (!val) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - } else { - if (!val->getBool()) { - _iP = dw; - } - } - break; - } - - case II_ADD: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) { - _operand->setNULL(); - } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { - char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; - strcpy(tempStr, op1->getString()); - strcat(tempStr, op2->getString()); - _operand->setString(tempStr); - delete[] tempStr; - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { - _operand->setInt(op1->getInt() + op2->getInt()); - } else { - _operand->setFloat(op1->getFloat() + op2->getFloat()); - } - - _stack->push(_operand); - - break; - - case II_SUB: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) { - _operand->setNULL(); - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { - _operand->setInt(op1->getInt() - op2->getInt()); - } else { - _operand->setFloat(op1->getFloat() - op2->getFloat()); - } - - _stack->push(_operand); - - break; - - case II_MUL: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op1->isNULL() || op2->isNULL()) { - _operand->setNULL(); - } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { - _operand->setInt(op1->getInt() * op2->getInt()); - } else { - _operand->setFloat(op1->getFloat() * op2->getFloat()); - } - - _stack->push(_operand); - - break; - - case II_DIV: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getFloat() == 0.0f) { - runtimeError("Division by zero."); - } - - if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) { - _operand->setNULL(); - } else { - _operand->setFloat(op1->getFloat() / op2->getFloat()); - } - - _stack->push(_operand); - - break; - - case II_MODULO: - op2 = _stack->pop(); - op1 = _stack->pop(); - - if (op2->getInt() == 0) { - runtimeError("Division by zero."); - } - - if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) { - _operand->setNULL(); - } else { - _operand->setInt(op1->getInt() % op2->getInt()); - } - - _stack->push(_operand); - - break; - - case II_NOT: - op1 = _stack->pop(); - //if (op1->isNULL()) _operand->setNULL(); - if (op1->isNULL()) { - _operand->setBool(true); - } else { - _operand->setBool(!op1->getBool()); - } - _stack->push(_operand); - - break; - - case II_AND: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() && op2->getBool()); - } - _stack->push(_operand); - break; - - case II_OR: - op2 = _stack->pop(); - op1 = _stack->pop(); - if (op1 == NULL || op2 == NULL) { - runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); - _operand->setBool(false); - } else { - _operand->setBool(op1->getBool() || op2->getBool()); - } - _stack->push(_operand); - break; - - case II_CMP_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); - else if (op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() == op2->getNative()); - } - else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); - } - else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() == op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() == op2->getInt()); - } - */ - - _operand->setBool(ScValue::compare(op1, op2) == 0); - _stack->push(_operand); - break; - - case II_CMP_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); - else if (op1->isNative() && op2->isNative()){ - _operand->setBool(op1->getNative() != op2->getNative()); - } - else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ - _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); - } - else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() != op2->getFloat()); - } - else{ - _operand->setBool(op1->getInt() != op2->getInt()); - } - */ - - _operand->setBool(ScValue::compare(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_CMP_L: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() < op2->getFloat()); - } - else _operand->setBool(op1->getInt() < op2->getInt()); - */ - - _operand->setBool(ScValue::compare(op1, op2) < 0); - _stack->push(_operand); - break; - - case II_CMP_G: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() > op2->getFloat()); - } - else _operand->setBool(op1->getInt() > op2->getInt()); - */ - - _operand->setBool(ScValue::compare(op1, op2) > 0); - _stack->push(_operand); - break; - - case II_CMP_LE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() <= op2->getFloat()); - } - else _operand->setBool(op1->getInt() <= op2->getInt()); - */ - - _operand->setBool(ScValue::compare(op1, op2) <= 0); - _stack->push(_operand); - break; - - case II_CMP_GE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - /* - if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ - _operand->setBool(op1->getFloat() >= op2->getFloat()); - } - else _operand->setBool(op1->getInt() >= op2->getInt()); - */ - - _operand->setBool(ScValue::compare(op1, op2) >= 0); - _stack->push(_operand); - break; - - case II_CMP_STRICT_EQ: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); - _operand->setBool(ScValue::compareStrict(op1, op2) == 0); - _stack->push(_operand); - - break; - - case II_CMP_STRICT_NE: - op2 = _stack->pop(); - op1 = _stack->pop(); - - //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); - _operand->setBool(ScValue::compareStrict(op1, op2) != 0); - _stack->push(_operand); - break; - - case II_DBG_LINE: { - int newLine = getDWORD(); - if (newLine != _currentLine) { - _currentLine = newLine; - } - break; - - } - default: - _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); - _state = SCRIPT_FINISHED; - ret = STATUS_FAILED; - } // switch(instruction) - - //delete op; - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getFuncPos(const Common::String &name) { - for (uint32 i = 0; i < _numFunctions; i++) { - if (name == _functions[i].name) { - return _functions[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getMethodPos(const Common::String &name) { - for (uint32 i = 0; i < _numMethods; i++) { - if (name == _methods[i].name) { - return _methods[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScScript::getVar(char *name) { - ScValue *ret = NULL; - - // scope locals - if (_scopeStack->_sP >= 0) { - if (_scopeStack->getTop()->propExists(name)) { - ret = _scopeStack->getTop()->getProp(name); - } - } - - // script globals - if (ret == NULL) { - if (_globals->propExists(name)) { - ret = _globals->getProp(name); - } - } - - // engine globals - if (ret == NULL) { - if (_engine->_globals->propExists(name)) { - ret = _engine->_globals->getProp(name); - } - } - - if (ret == NULL) { - //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); - _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); - ScValue *val = new ScValue(_gameRef); - ScValue *scope = _scopeStack->getTop(); - if (scope) { - scope->setProp(name, val); - ret = _scopeStack->getTop()->getProp(name); - } else { - _globals->setProp(name, val); - ret = _globals->getProp(name); - } - delete val; - } - - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::waitFor(BaseObject *object) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_WAITING; - _waitObject = object; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::waitForExclusive(BaseObject *object) { - _engine->resetObject(object); - return waitFor(object); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::sleep(uint32 duration) { - if (_unbreakable) { - runtimeError("Script cannot be interrupted."); - return STATUS_OK; - } - - _state = SCRIPT_SLEEPING; - if (_gameRef->_state == GAME_FROZEN) { - _waitTime = g_system->getMillis() + duration; - _waitFrozen = true; - } else { - _waitTime = _gameRef->_timer + duration; - _waitFrozen = false; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::finish(bool includingThreads) { - if (_state != SCRIPT_FINISHED && includingThreads) { - _state = SCRIPT_FINISHED; - finishThreads(); - } else { - _state = SCRIPT_FINISHED; - } - - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::run() { - _state = SCRIPT_RUNNING; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////// -void ScScript::runtimeError(const char *fmt, ...) { - char buff[256]; - va_list va; - - va_start(va, fmt); - vsprintf(buff, fmt, va); - va_end(va); - - _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); - _gameRef->LOG(0, " %s", buff); - - if (!_gameRef->_suppressScriptErrors) { - _gameRef->quickMessage("Script runtime error. View log for details."); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - // buffer - if (persistMgr->getIsSaving()) { - if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { - persistMgr->transfer(TMEMBER(_bufferSize)); - persistMgr->putBytes(_buffer, _bufferSize); - } else { - // don't save idle/finished scripts - int bufferSize = 0; - persistMgr->transfer(TMEMBER(bufferSize)); - } - } else { - persistMgr->transfer(TMEMBER(_bufferSize)); - if (_bufferSize > 0) { - _buffer = new byte[_bufferSize]; - persistMgr->getBytes(_buffer, _bufferSize); - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - initTables(); - } else { - _buffer = NULL; - _scriptStream = NULL; - } - } - - persistMgr->transfer(TMEMBER(_callStack)); - persistMgr->transfer(TMEMBER(_currentLine)); - persistMgr->transfer(TMEMBER(_engine)); - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_freezable)); - persistMgr->transfer(TMEMBER(_globals)); - persistMgr->transfer(TMEMBER(_iP)); - persistMgr->transfer(TMEMBER(_scopeStack)); - persistMgr->transfer(TMEMBER(_stack)); - persistMgr->transfer(TMEMBER_INT(_state)); - persistMgr->transfer(TMEMBER(_operand)); - persistMgr->transfer(TMEMBER_INT(_origState)); - persistMgr->transfer(TMEMBER(_owner)); - persistMgr->transfer(TMEMBER(_reg1)); - persistMgr->transfer(TMEMBER(_thread)); - persistMgr->transfer(TMEMBER(_threadEvent)); - persistMgr->transfer(TMEMBER(_thisStack)); - persistMgr->transfer(TMEMBER(_timeSlice)); - persistMgr->transfer(TMEMBER(_waitObject)); - persistMgr->transfer(TMEMBER(_waitScript)); - persistMgr->transfer(TMEMBER(_waitTime)); - persistMgr->transfer(TMEMBER(_waitFrozen)); - - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_methodThread)); - persistMgr->transfer(TMEMBER(_unbreakable)); - persistMgr->transfer(TMEMBER(_parentScript)); - - if (!persistMgr->getIsSaving()) { - _tracingMode = false; - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { - //if (_state!=SCRIPT_PERSISTENT) return NULL; - - uint32 pos = getEventPos(eventName); - if (!pos) { - return NULL; - } - - ScScript *thread = new ScScript(_gameRef, _engine); - if (thread) { - bool ret = thread->createThread(this, pos, eventName); - if (DID_SUCCEED(ret)) { - thread->_unbreakable = unbreakable; - _engine->_scripts.add(thread); - return thread; - } else { - delete thread; - return NULL; - } - } else { - return NULL; - } - -} - - -////////////////////////////////////////////////////////////////////////// -uint32 ScScript::getEventPos(const Common::String &name) { - for (int i = _numEvents - 1; i >= 0; i--) { - if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { - return _events[i].pos; - } - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleEvent(const Common::String &eventName) { - return getEventPos(eventName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::canHandleMethod(const Common::String &methodName) { - return getMethodPos(methodName) != 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::pause() { - if (_state == SCRIPT_PAUSED) { - _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); - return STATUS_FAILED; - } - - if (!_freezable || _state == SCRIPT_PERSISTENT) { - return STATUS_OK; - } - - _origState = _state; - _state = SCRIPT_PAUSED; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::resume() { - if (_state != SCRIPT_PAUSED) { - return STATUS_OK; - } - - _state = _origState; - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -ScScript::TExternalFunction *ScScript::getExternal(char *name) { - for (uint32 i = 0; i < _numExternals; i++) { - if (strcmp(name, _externals[i].name) == 0) { - return &_externals[i]; - } - } - return NULL; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { - - _gameRef->LOG(0, "External functions are not supported on this platform."); - stack->correctParams(0); - stack->pushNULL(); - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::copyParameters(ScStack *stack) { - int i; - int numParams = stack->pop()->getInt(); - for (i = numParams - 1; i >= 0; i--) { - _stack->push(stack->getAt(i)); - } - _stack->pushInt(numParams); - - for (i = 0; i < numParams; i++) { - stack->pop(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScScript::finishThreads() { - for (uint32 i = 0; i < _engine->_scripts.size(); i++) { - ScScript *scr = _engine->_scripts[i]; - if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { - scr->finish(true); - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// IWmeDebugScript interface implementation -int ScScript::dbgGetLine() { - return _currentLine; -} - -////////////////////////////////////////////////////////////////////////// -const char *ScScript::dbgGetFilename() { - return _filename; -} - -////////////////////////////////////////////////////////////////////////// -void ScScript::afterLoad() { - if (_buffer == NULL) { - byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); - if (!buffer) { - _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); - _state = SCRIPT_ERROR; - return; - } - - _buffer = new byte [_bufferSize]; - memcpy(_buffer, buffer, _bufferSize); - - delete _scriptStream; - _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); - - initTables(); - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "common/memstream.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(ScScript, false) + +////////////////////////////////////////////////////////////////////////// +ScScript::ScScript(BaseGame *inGame, ScEngine *engine) : BaseClass(inGame) { + _buffer = NULL; + _bufferSize = _iP = 0; + _scriptStream = NULL; + _filename = NULL; + _currentLine = 0; + + _symbols = NULL; + _numSymbols = 0; + + _engine = engine; + + _globals = NULL; + + _scopeStack = NULL; + _callStack = NULL; + _thisStack = NULL; + _stack = NULL; + + _operand = NULL; + _reg1 = NULL; + + _functions = NULL; + _numFunctions = 0; + + _methods = NULL; + _numMethods = 0; + + _events = NULL; + _numEvents = 0; + + _externals = NULL; + _numExternals = 0; + + _state = SCRIPT_FINISHED; + _origState = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _timeSlice = 0; + + _thread = false; + _methodThread = false; + _threadEvent = NULL; + + _freezable = true; + _owner = NULL; + + _unbreakable = false; + _parentScript = NULL; + + _tracingMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript::~ScScript() { + cleanup(); +} + +void ScScript::readHeader() { + uint32 oldPos = _scriptStream->pos(); + _scriptStream->seek(0); + _header.magic = _scriptStream->readUint32LE(); + _header.version = _scriptStream->readUint32LE(); + _header.codeStart = _scriptStream->readUint32LE(); + _header.funcTable = _scriptStream->readUint32LE(); + _header.symbolTable = _scriptStream->readUint32LE(); + _header.eventTable = _scriptStream->readUint32LE(); + _header.externalsTable = _scriptStream->readUint32LE(); + _header.methodTable = _scriptStream->readUint32LE(); + _scriptStream->seek(oldPos); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::initScript() { + if (!_scriptStream) { + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + } + readHeader(); + + if (_header.magic != SCRIPT_MAGIC) { + _gameRef->LOG(0, "File '%s' is not a valid compiled script", _filename); + cleanup(); + return STATUS_FAILED; + } + + if (_header.version > SCRIPT_VERSION) { + _gameRef->LOG(0, "Script '%s' has a wrong version %d.%d (expected %d.%d)", _filename, _header.version / 256, _header.version % 256, SCRIPT_VERSION / 256, SCRIPT_VERSION % 256); + cleanup(); + return STATUS_FAILED; + } + + initTables(); + + // init stacks + _scopeStack = new ScStack(_gameRef); + _callStack = new ScStack(_gameRef); + _thisStack = new ScStack(_gameRef); + _stack = new ScStack(_gameRef); + + _operand = new ScValue(_gameRef); + _reg1 = new ScValue(_gameRef); + + + // skip to the beginning + _iP = _header.codeStart; + _scriptStream->seek(_iP); + _currentLine = 0; + + // ready to rumble... + _state = SCRIPT_RUNNING; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::initTables() { + uint32 origIP = _iP; + + readHeader(); + // load symbol table + _iP = _header.symbolTable; + + _numSymbols = getDWORD(); + _symbols = new char*[_numSymbols]; + for (uint32 i = 0; i < _numSymbols; i++) { + uint32 index = getDWORD(); + _symbols[index] = getString(); + } + + // load functions table + _iP = _header.funcTable; + + _numFunctions = getDWORD(); + _functions = new TFunctionPos[_numFunctions]; + for (uint32 i = 0; i < _numFunctions; i++) { + _functions[i].pos = getDWORD(); + _functions[i].name = getString(); + } + + + // load events table + _iP = _header.eventTable; + + _numEvents = getDWORD(); + _events = new TEventPos[_numEvents]; + for (uint32 i = 0; i < _numEvents; i++) { + _events[i].pos = getDWORD(); + _events[i].name = getString(); + } + + + // load externals + if (_header.version >= 0x0101) { + _iP = _header.externalsTable; + + _numExternals = getDWORD(); + _externals = new TExternalFunction[_numExternals]; + for (uint32 i = 0; i < _numExternals; i++) { + _externals[i].dll_name = getString(); + _externals[i].name = getString(); + _externals[i].call_type = (TCallType)getDWORD(); + _externals[i].returns = (TExternalType)getDWORD(); + _externals[i].nu_params = getDWORD(); + if (_externals[i].nu_params > 0) { + _externals[i].params = new TExternalType[_externals[i].nu_params]; + for (int j = 0; j < _externals[i].nu_params; j++) { + _externals[i].params[j] = (TExternalType)getDWORD(); + } + } + } + } + + // load method table + _iP = _header.methodTable; + + _numMethods = getDWORD(); + _methods = new TMethodPos[_numMethods]; + for (uint32 i = 0; i < _numMethods; i++) { + _methods[i].pos = getDWORD(); + _methods[i].name = getString(); + } + + + _iP = origIP; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner) { + cleanup(); + + _thread = false; + _methodThread = false; + + delete[] _threadEvent; + _threadEvent = NULL; + + _filename = new char[strlen(filename) + 1]; + if (_filename) { + strcpy(_filename, filename); + } + + _buffer = new byte [size]; + if (!_buffer) { + return STATUS_FAILED; + } + + memcpy(_buffer, buffer, size); + + _bufferSize = size; + + bool res = initScript(); + if (DID_FAIL(res)) { + return res; + } + + // establish global variables table + _globals = new ScValue(_gameRef); + + _owner = owner; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::createThread(ScScript *original, uint32 initIP, const Common::String &eventName) { + cleanup(); + + _thread = true; + _methodThread = false; + _threadEvent = new char[eventName.size() + 1]; + if (_threadEvent) { + strcpy(_threadEvent, eventName.c_str()); + } + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) { + strcpy(_filename, original->_filename); + } + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) { + return STATUS_FAILED; + } + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) { + return res; + } + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = initIP; + _scriptStream->seek(_iP); + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::createMethodThread(ScScript *original, const Common::String &methodName) { + uint32 ip = original->getMethodPos(methodName); + if (ip == 0) { + return STATUS_FAILED; + } + + cleanup(); + + _thread = true; + _methodThread = true; + _threadEvent = new char[methodName.size() + 1]; + if (_threadEvent) { + strcpy(_threadEvent, methodName.c_str()); + } + + // copy filename + _filename = new char[strlen(original->_filename) + 1]; + if (_filename) { + strcpy(_filename, original->_filename); + } + + // copy buffer + _buffer = new byte [original->_bufferSize]; + if (!_buffer) { + return STATUS_FAILED; + } + + memcpy(_buffer, original->_buffer, original->_bufferSize); + _bufferSize = original->_bufferSize; + + // initialize + bool res = initScript(); + if (DID_FAIL(res)) { + return res; + } + + // copy globals + _globals = original->_globals; + + // skip to the beginning of the event + _iP = ip; + + _timeSlice = original->_timeSlice; + _freezable = original->_freezable; + _owner = original->_owner; + + _engine = original->_engine; + _parentScript = original; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void ScScript::cleanup() { + if (_buffer) { + delete[] _buffer; + } + _buffer = NULL; + + if (_filename) { + delete[] _filename; + } + _filename = NULL; + + if (_symbols) { + delete[] _symbols; + } + _symbols = NULL; + _numSymbols = 0; + + if (_globals && !_thread) { + delete _globals; + } + _globals = NULL; + + delete _scopeStack; + _scopeStack = NULL; + + delete _callStack; + _callStack = NULL; + + delete _thisStack; + _thisStack = NULL; + + delete _stack; + _stack = NULL; + + if (_functions) { + delete[] _functions; + } + _functions = NULL; + _numFunctions = 0; + + if (_methods) { + delete[] _methods; + } + _methods = NULL; + _numMethods = 0; + + if (_events) { + delete[] _events; + } + _events = NULL; + _numEvents = 0; + + + if (_externals) { + for (uint32 i = 0; i < _numExternals; i++) { + if (_externals[i].nu_params > 0) { + delete[] _externals[i].params; + } + } + delete[] _externals; + } + _externals = NULL; + _numExternals = 0; + + delete _operand; + delete _reg1; + _operand = NULL; + _reg1 = NULL; + + delete[] _threadEvent; + _threadEvent = NULL; + + _state = SCRIPT_FINISHED; + + _waitObject = NULL; + _waitTime = 0; + _waitFrozen = false; + _waitScript = NULL; + + _parentScript = NULL; // ref only + + delete _scriptStream; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getDWORD() { + _scriptStream->seek((int32)_iP); + uint32 ret = _scriptStream->readUint32LE(); + _iP += sizeof(uint32); +// assert(oldRet == ret); + return ret; +} + +////////////////////////////////////////////////////////////////////////// +double ScScript::getFloat() { + _scriptStream->seek((int32)_iP); + byte buffer[8]; + _scriptStream->read(buffer, 8); + +#ifdef SCUMM_BIG_ENDIAN + // TODO: For lack of a READ_LE_UINT64 + SWAP(buffer[0], buffer[7]); + SWAP(buffer[1], buffer[6]); + SWAP(buffer[2], buffer[5]); + SWAP(buffer[3], buffer[4]); +#endif + + double ret = *(double *)(buffer); + _iP += 8; // Hardcode the double-size used originally. + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +char *ScScript::getString() { + char *ret = (char *)(_buffer + _iP); + while (*(char *)(_buffer + _iP) != '\0') { + _iP++; + } + _iP++; // string terminator + _scriptStream->seek(_iP); + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::executeInstruction() { + bool ret = STATUS_OK; + + uint32 dw; + const char *str = NULL; + + //ScValue* op = new ScValue(_gameRef); + _operand->cleanup(); + + ScValue *op1; + ScValue *op2; + + uint32 inst = getDWORD(); + switch (inst) { + + case II_DEF_VAR: + _operand->setNULL(); + dw = getDWORD(); + if (_scopeStack->_sP < 0) { + _globals->setProp(_symbols[dw], _operand); + } else { + _scopeStack->getTop()->setProp(_symbols[dw], _operand); + } + + break; + + case II_DEF_GLOB_VAR: + case II_DEF_CONST_VAR: { + dw = getDWORD(); + /* char *temp = _symbols[dw]; // TODO delete */ + // only create global var if it doesn't exist + if (!_engine->_globals->propExists(_symbols[dw])) { + _operand->setNULL(); + _engine->_globals->setProp(_symbols[dw], _operand, false, inst == II_DEF_CONST_VAR); + } + break; + } + + case II_RET: + if (_scopeStack->_sP >= 0 && _callStack->_sP >= 0) { + _scopeStack->pop(); + _iP = (uint32)_callStack->pop()->getInt(); + } else { + if (_thread) { + _state = SCRIPT_THREAD_FINISHED; + } else { + if (_numEvents == 0 && _numMethods == 0) { + _state = SCRIPT_FINISHED; + } else { + _state = SCRIPT_PERSISTENT; + } + } + } + + break; + + case II_RET_EVENT: + _state = SCRIPT_FINISHED; + break; + + + case II_CALL: + dw = getDWORD(); + + _operand->setInt(_iP); + _callStack->push(_operand); + + _iP = dw; + + break; + + case II_CALL_BY_EXP: { + // push var + // push string + str = _stack->pop()->getString(); + char *methodName = new char[strlen(str) + 1]; + strcpy(methodName, str); + + ScValue *var = _stack->pop(); + if (var->_type == VAL_VARIABLE_REF) { + var = var->_valRef; + } + + bool res = STATUS_FAILED; + bool triedNative = false; + + // we are already calling this method, try native + if (_thread && _methodThread && strcmp(methodName, _threadEvent) == 0 && var->_type == VAL_NATIVE && _owner == var->getNative()) { + triedNative = true; + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); + } + + if (DID_FAIL(res)) { + if (var->isNative() && var->getNative()->canHandleMethod(methodName)) { + if (!_unbreakable) { + _waitScript = var->getNative()->invokeMethodThread(methodName); + if (!_waitScript) { + _stack->correctParams(0); + runtimeError("Error invoking method '%s'.", methodName); + _stack->pushNULL(); + } else { + _state = SCRIPT_WAITING_SCRIPT; + _waitScript->copyParameters(_stack); + } + } else { + // can call methods in unbreakable mode + _stack->correctParams(0); + runtimeError("Cannot call method '%s'. Ignored.", methodName); + _stack->pushNULL(); + } + delete[] methodName; + break; + } + /* + ScValue* val = var->getProp(MethodName); + if (val){ + dw = GetFuncPos(val->getString()); + if (dw==0){ + TExternalFunction* f = GetExternal(val->getString()); + if (f){ + ExternalCall(_stack, _thisStack, f); + } + else{ + // not an internal nor external, try for native function + _gameRef->ExternalCall(this, _stack, _thisStack, val->getString()); + } + } + else{ + _operand->setInt(_iP); + _callStack->Push(_operand); + _iP = dw; + } + } + */ + else { + res = STATUS_FAILED; + if (var->_type == VAL_NATIVE && !triedNative) { + res = var->_valNative->scCallMethod(this, _stack, _thisStack, methodName); + } + + if (DID_FAIL(res)) { + _stack->correctParams(0); + runtimeError("Call to undefined method '%s'. Ignored.", methodName); + _stack->pushNULL(); + } + } + } + delete[] methodName; + } + break; + + case II_EXTERNAL_CALL: { + uint32 symbolIndex = getDWORD(); + + TExternalFunction *f = getExternal(_symbols[symbolIndex]); + if (f) { + externalCall(_stack, _thisStack, f); + } else { + _gameRef->externalCall(this, _stack, _thisStack, _symbols[symbolIndex]); + } + + break; + } + case II_SCOPE: + _operand->setNULL(); + _scopeStack->push(_operand); + break; + + case II_CORRECT_STACK: + dw = getDWORD(); // params expected + _stack->correctParams(dw); + break; + + case II_CREATE_OBJECT: + _operand->setObject(); + _stack->push(_operand); + break; + + case II_POP_EMPTY: + _stack->pop(); + break; + + case II_PUSH_VAR: { + ScValue *var = getVar(_symbols[getDWORD()]); + if (false && /*var->_type==VAL_OBJECT ||*/ var->_type == VAL_NATIVE) { + _operand->setReference(var); + _stack->push(_operand); + } else { + _stack->push(var); + } + break; + } + + case II_PUSH_VAR_REF: { + ScValue *var = getVar(_symbols[getDWORD()]); + _operand->setReference(var); + _stack->push(_operand); + break; + } + + case II_POP_VAR: { + char *varName = _symbols[getDWORD()]; + ScValue *var = getVar(varName); + if (var) { + ScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + if (val->getType() == VAL_VARIABLE_REF) { + val = val->_valRef; + } + if (val->_type == VAL_NATIVE) { + var->setValue(val); + } else { + var->copy(val); + } + } + } + + break; + } + + case II_PUSH_VAR_THIS: + _stack->push(_thisStack->getTop()); + break; + + case II_PUSH_INT: + _stack->pushInt((int)getDWORD()); + break; + + case II_PUSH_FLOAT: + _stack->pushFloat(getFloat()); + break; + + + case II_PUSH_BOOL: + _stack->pushBool(getDWORD() != 0); + + break; + + case II_PUSH_STRING: + _stack->pushString(getString()); + break; + + case II_PUSH_NULL: + _stack->pushNULL(); + break; + + case II_PUSH_THIS_FROM_STACK: + _operand->setReference(_stack->getTop()); + _thisStack->push(_operand); + break; + + case II_PUSH_THIS: + _operand->setReference(getVar(_symbols[getDWORD()])); + _thisStack->push(_operand); + break; + + case II_POP_THIS: + _thisStack->pop(); + break; + + case II_PUSH_BY_EXP: { + str = _stack->pop()->getString(); + ScValue *val = _stack->pop()->getProp(str); + if (val) { + _stack->push(val); + } else { + _stack->pushNULL(); + } + + break; + } + + case II_POP_BY_EXP: { + str = _stack->pop()->getString(); + ScValue *var = _stack->pop(); + ScValue *val = _stack->pop(); + + if (val == NULL) { + runtimeError("Script stack corruption detected. Please report this script at WME bug reports forum."); + var->setNULL(); + } else { + var->setProp(str, val); + } + + break; + } + + case II_PUSH_REG1: + _stack->push(_reg1); + break; + + case II_POP_REG1: + _reg1->copy(_stack->pop()); + break; + + case II_JMP: + _iP = getDWORD(); + break; + + case II_JMP_FALSE: { + dw = getDWORD(); + //if (!_stack->pop()->getBool()) _iP = dw; + ScValue *val = _stack->pop(); + if (!val) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + } else { + if (!val->getBool()) { + _iP = dw; + } + } + break; + } + + case II_ADD: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) { + _operand->setNULL(); + } else if (op1->getType() == VAL_STRING || op2->getType() == VAL_STRING) { + char *tempStr = new char [strlen(op1->getString()) + strlen(op2->getString()) + 1]; + strcpy(tempStr, op1->getString()); + strcat(tempStr, op2->getString()); + _operand->setString(tempStr); + delete[] tempStr; + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { + _operand->setInt(op1->getInt() + op2->getInt()); + } else { + _operand->setFloat(op1->getFloat() + op2->getFloat()); + } + + _stack->push(_operand); + + break; + + case II_SUB: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) { + _operand->setNULL(); + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { + _operand->setInt(op1->getInt() - op2->getInt()); + } else { + _operand->setFloat(op1->getFloat() - op2->getFloat()); + } + + _stack->push(_operand); + + break; + + case II_MUL: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op1->isNULL() || op2->isNULL()) { + _operand->setNULL(); + } else if (op1->getType() == VAL_INT && op2->getType() == VAL_INT) { + _operand->setInt(op1->getInt() * op2->getInt()); + } else { + _operand->setFloat(op1->getFloat() * op2->getFloat()); + } + + _stack->push(_operand); + + break; + + case II_DIV: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getFloat() == 0.0f) { + runtimeError("Division by zero."); + } + + if (op1->isNULL() || op2->isNULL() || op2->getFloat() == 0.0f) { + _operand->setNULL(); + } else { + _operand->setFloat(op1->getFloat() / op2->getFloat()); + } + + _stack->push(_operand); + + break; + + case II_MODULO: + op2 = _stack->pop(); + op1 = _stack->pop(); + + if (op2->getInt() == 0) { + runtimeError("Division by zero."); + } + + if (op1->isNULL() || op2->isNULL() || op2->getInt() == 0) { + _operand->setNULL(); + } else { + _operand->setInt(op1->getInt() % op2->getInt()); + } + + _stack->push(_operand); + + break; + + case II_NOT: + op1 = _stack->pop(); + //if (op1->isNULL()) _operand->setNULL(); + if (op1->isNULL()) { + _operand->setBool(true); + } else { + _operand->setBool(!op1->getBool()); + } + _stack->push(_operand); + + break; + + case II_AND: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() && op2->getBool()); + } + _stack->push(_operand); + break; + + case II_OR: + op2 = _stack->pop(); + op1 = _stack->pop(); + if (op1 == NULL || op2 == NULL) { + runtimeError("Script corruption detected. Did you use '=' instead of '==' for comparison?"); + _operand->setBool(false); + } else { + _operand->setBool(op1->getBool() || op2->getBool()); + } + _stack->push(_operand); + break; + + case II_CMP_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(false); + else if (op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() == op2->getNative()); + } + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())==0); + } + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() == op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() == op2->getInt()); + } + */ + + _operand->setBool(ScValue::compare(op1, op2) == 0); + _stack->push(_operand); + break; + + case II_CMP_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if ((op1->isNULL() && !op2->isNULL()) || (!op1->isNULL() && op2->isNULL())) _operand->setBool(true); + else if (op1->isNative() && op2->isNative()){ + _operand->setBool(op1->getNative() != op2->getNative()); + } + else if (op1->getType()==VAL_STRING || op2->getType()==VAL_STRING){ + _operand->setBool(scumm_stricmp(op1->getString(), op2->getString())!=0); + } + else if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() != op2->getFloat()); + } + else{ + _operand->setBool(op1->getInt() != op2->getInt()); + } + */ + + _operand->setBool(ScValue::compare(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_CMP_L: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() < op2->getFloat()); + } + else _operand->setBool(op1->getInt() < op2->getInt()); + */ + + _operand->setBool(ScValue::compare(op1, op2) < 0); + _stack->push(_operand); + break; + + case II_CMP_G: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() > op2->getFloat()); + } + else _operand->setBool(op1->getInt() > op2->getInt()); + */ + + _operand->setBool(ScValue::compare(op1, op2) > 0); + _stack->push(_operand); + break; + + case II_CMP_LE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() <= op2->getFloat()); + } + else _operand->setBool(op1->getInt() <= op2->getInt()); + */ + + _operand->setBool(ScValue::compare(op1, op2) <= 0); + _stack->push(_operand); + break; + + case II_CMP_GE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + /* + if (op1->getType()==VAL_FLOAT && op2->getType()==VAL_FLOAT){ + _operand->setBool(op1->getFloat() >= op2->getFloat()); + } + else _operand->setBool(op1->getInt() >= op2->getInt()); + */ + + _operand->setBool(ScValue::compare(op1, op2) >= 0); + _stack->push(_operand); + break; + + case II_CMP_STRICT_EQ: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()==op2->getType() && op1->getFloat()==op2->getFloat()); + _operand->setBool(ScValue::compareStrict(op1, op2) == 0); + _stack->push(_operand); + + break; + + case II_CMP_STRICT_NE: + op2 = _stack->pop(); + op1 = _stack->pop(); + + //_operand->setBool(op1->getType()!=op2->getType() || op1->getFloat()!=op2->getFloat()); + _operand->setBool(ScValue::compareStrict(op1, op2) != 0); + _stack->push(_operand); + break; + + case II_DBG_LINE: { + int newLine = getDWORD(); + if (newLine != _currentLine) { + _currentLine = newLine; + } + break; + + } + default: + _gameRef->LOG(0, "Fatal: Invalid instruction %d ('%s', line %d, IP:0x%x)\n", inst, _filename, _currentLine, _iP - sizeof(uint32)); + _state = SCRIPT_FINISHED; + ret = STATUS_FAILED; + } // switch(instruction) + + //delete op; + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getFuncPos(const Common::String &name) { + for (uint32 i = 0; i < _numFunctions; i++) { + if (name == _functions[i].name) { + return _functions[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getMethodPos(const Common::String &name) { + for (uint32 i = 0; i < _numMethods; i++) { + if (name == _methods[i].name) { + return _methods[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScScript::getVar(char *name) { + ScValue *ret = NULL; + + // scope locals + if (_scopeStack->_sP >= 0) { + if (_scopeStack->getTop()->propExists(name)) { + ret = _scopeStack->getTop()->getProp(name); + } + } + + // script globals + if (ret == NULL) { + if (_globals->propExists(name)) { + ret = _globals->getProp(name); + } + } + + // engine globals + if (ret == NULL) { + if (_engine->_globals->propExists(name)) { + ret = _engine->_globals->getProp(name); + } + } + + if (ret == NULL) { + //RuntimeError("Variable '%s' is inaccessible in the current block. Consider changing the script.", name); + _gameRef->LOG(0, "Warning: variable '%s' is inaccessible in the current block. Consider changing the script (script:%s, line:%d)", name, _filename, _currentLine); + ScValue *val = new ScValue(_gameRef); + ScValue *scope = _scopeStack->getTop(); + if (scope) { + scope->setProp(name, val); + ret = _scopeStack->getTop()->getProp(name); + } else { + _globals->setProp(name, val); + ret = _globals->getProp(name); + } + delete val; + } + + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::waitFor(BaseObject *object) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_WAITING; + _waitObject = object; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::waitForExclusive(BaseObject *object) { + _engine->resetObject(object); + return waitFor(object); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::sleep(uint32 duration) { + if (_unbreakable) { + runtimeError("Script cannot be interrupted."); + return STATUS_OK; + } + + _state = SCRIPT_SLEEPING; + if (_gameRef->_state == GAME_FROZEN) { + _waitTime = g_system->getMillis() + duration; + _waitFrozen = true; + } else { + _waitTime = _gameRef->_timer + duration; + _waitFrozen = false; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::finish(bool includingThreads) { + if (_state != SCRIPT_FINISHED && includingThreads) { + _state = SCRIPT_FINISHED; + finishThreads(); + } else { + _state = SCRIPT_FINISHED; + } + + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::run() { + _state = SCRIPT_RUNNING; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////// +void ScScript::runtimeError(const char *fmt, ...) { + char buff[256]; + va_list va; + + va_start(va, fmt); + vsprintf(buff, fmt, va); + va_end(va); + + _gameRef->LOG(0, "Runtime error. Script '%s', line %d", _filename, _currentLine); + _gameRef->LOG(0, " %s", buff); + + if (!_gameRef->_suppressScriptErrors) { + _gameRef->quickMessage("Script runtime error. View log for details."); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::persist(BasePersistenceManager *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + // buffer + if (persistMgr->getIsSaving()) { + if (_state != SCRIPT_PERSISTENT && _state != SCRIPT_FINISHED && _state != SCRIPT_THREAD_FINISHED) { + persistMgr->transfer(TMEMBER(_bufferSize)); + persistMgr->putBytes(_buffer, _bufferSize); + } else { + // don't save idle/finished scripts + int bufferSize = 0; + persistMgr->transfer(TMEMBER(bufferSize)); + } + } else { + persistMgr->transfer(TMEMBER(_bufferSize)); + if (_bufferSize > 0) { + _buffer = new byte[_bufferSize]; + persistMgr->getBytes(_buffer, _bufferSize); + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + initTables(); + } else { + _buffer = NULL; + _scriptStream = NULL; + } + } + + persistMgr->transfer(TMEMBER(_callStack)); + persistMgr->transfer(TMEMBER(_currentLine)); + persistMgr->transfer(TMEMBER(_engine)); + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_freezable)); + persistMgr->transfer(TMEMBER(_globals)); + persistMgr->transfer(TMEMBER(_iP)); + persistMgr->transfer(TMEMBER(_scopeStack)); + persistMgr->transfer(TMEMBER(_stack)); + persistMgr->transfer(TMEMBER_INT(_state)); + persistMgr->transfer(TMEMBER(_operand)); + persistMgr->transfer(TMEMBER_INT(_origState)); + persistMgr->transfer(TMEMBER(_owner)); + persistMgr->transfer(TMEMBER(_reg1)); + persistMgr->transfer(TMEMBER(_thread)); + persistMgr->transfer(TMEMBER(_threadEvent)); + persistMgr->transfer(TMEMBER(_thisStack)); + persistMgr->transfer(TMEMBER(_timeSlice)); + persistMgr->transfer(TMEMBER(_waitObject)); + persistMgr->transfer(TMEMBER(_waitScript)); + persistMgr->transfer(TMEMBER(_waitTime)); + persistMgr->transfer(TMEMBER(_waitFrozen)); + + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_methodThread)); + persistMgr->transfer(TMEMBER(_unbreakable)); + persistMgr->transfer(TMEMBER(_parentScript)); + + if (!persistMgr->getIsSaving()) { + _tracingMode = false; + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *ScScript::invokeEventHandler(const Common::String &eventName, bool unbreakable) { + //if (_state!=SCRIPT_PERSISTENT) return NULL; + + uint32 pos = getEventPos(eventName); + if (!pos) { + return NULL; + } + + ScScript *thread = new ScScript(_gameRef, _engine); + if (thread) { + bool ret = thread->createThread(this, pos, eventName); + if (DID_SUCCEED(ret)) { + thread->_unbreakable = unbreakable; + _engine->_scripts.add(thread); + return thread; + } else { + delete thread; + return NULL; + } + } else { + return NULL; + } + +} + + +////////////////////////////////////////////////////////////////////////// +uint32 ScScript::getEventPos(const Common::String &name) { + for (int i = _numEvents - 1; i >= 0; i--) { + if (scumm_stricmp(name.c_str(), _events[i].name) == 0) { + return _events[i].pos; + } + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::canHandleEvent(const Common::String &eventName) { + return getEventPos(eventName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::canHandleMethod(const Common::String &methodName) { + return getMethodPos(methodName) != 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::pause() { + if (_state == SCRIPT_PAUSED) { + _gameRef->LOG(0, "Attempting to pause a paused script ('%s', line %d)", _filename, _currentLine); + return STATUS_FAILED; + } + + if (!_freezable || _state == SCRIPT_PERSISTENT) { + return STATUS_OK; + } + + _origState = _state; + _state = SCRIPT_PAUSED; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::resume() { + if (_state != SCRIPT_PAUSED) { + return STATUS_OK; + } + + _state = _origState; + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +ScScript::TExternalFunction *ScScript::getExternal(char *name) { + for (uint32 i = 0; i < _numExternals; i++) { + if (strcmp(name, _externals[i].name) == 0) { + return &_externals[i]; + } + } + return NULL; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function) { + + _gameRef->LOG(0, "External functions are not supported on this platform."); + stack->correctParams(0); + stack->pushNULL(); + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::copyParameters(ScStack *stack) { + int i; + int numParams = stack->pop()->getInt(); + for (i = numParams - 1; i >= 0; i--) { + _stack->push(stack->getAt(i)); + } + _stack->pushInt(numParams); + + for (i = 0; i < numParams; i++) { + stack->pop(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScScript::finishThreads() { + for (uint32 i = 0; i < _engine->_scripts.size(); i++) { + ScScript *scr = _engine->_scripts[i]; + if (scr->_thread && scr->_state != SCRIPT_FINISHED && scr->_owner == _owner && scumm_stricmp(scr->_filename, _filename) == 0) { + scr->finish(true); + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// IWmeDebugScript interface implementation +int ScScript::dbgGetLine() { + return _currentLine; +} + +////////////////////////////////////////////////////////////////////////// +const char *ScScript::dbgGetFilename() { + return _filename; +} + +////////////////////////////////////////////////////////////////////////// +void ScScript::afterLoad() { + if (_buffer == NULL) { + byte *buffer = _engine->getCompiledScript(_filename, &_bufferSize); + if (!buffer) { + _gameRef->LOG(0, "Error reinitializing script '%s' after load. Script will be terminated.", _filename); + _state = SCRIPT_ERROR; + return; + } + + _buffer = new byte [_bufferSize]; + memcpy(_buffer, buffer, _bufferSize); + + delete _scriptStream; + _scriptStream = new Common::MemoryReadStream(_buffer, _bufferSize); + + initTables(); + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script.h b/engines/wintermute/base/scriptables/script.h index 4daeacd026..0616bce58a 100644 --- a/engines/wintermute/base/scriptables/script.h +++ b/engines/wintermute/base/scriptables/script.h @@ -1,174 +1,174 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSCRIPT_H -#define WINTERMUTE_SCSCRIPT_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView -#include "engines/wintermute/coll_templ.h" - -namespace Wintermute { -class BaseScriptHolder; -class BaseObject; -class ScEngine; -class ScStack; -class ScScript : public BaseClass { -public: - BaseArray _breakpoints; - bool _tracingMode; - - ScScript *_parentScript; - bool _unbreakable; - bool finishThreads(); - bool copyParameters(ScStack *stack); - - void afterLoad(); -private: - ScValue *_operand; - ScValue *_reg1; -public: - bool _freezable; - bool resume(); - bool pause(); - bool canHandleEvent(const Common::String &eventName); - bool canHandleMethod(const Common::String &methodName); - bool createThread(ScScript *original, uint32 initIP, const Common::String &eventName); - bool createMethodThread(ScScript *original, const Common::String &methodName); - ScScript *invokeEventHandler(const Common::String &eventName, bool unbreakable = false); - uint32 _timeSlice; - DECLARE_PERSISTENT(ScScript, BaseClass) - void runtimeError(const char *fmt, ...); - bool run(); - bool finish(bool includingThreads = false); - bool sleep(uint32 duration); - bool waitForExclusive(BaseObject *object); - bool waitFor(BaseObject *object); - uint32 _waitTime; - bool _waitFrozen; - BaseObject *_waitObject; - ScScript *_waitScript; - TScriptState _state; - TScriptState _origState; - ScValue *getVar(char *name); - uint32 getFuncPos(const Common::String &name); - uint32 getEventPos(const Common::String &name); - uint32 getMethodPos(const Common::String &name); - typedef struct { - uint32 magic; - uint32 version; - uint32 codeStart; - uint32 funcTable; - uint32 symbolTable; - uint32 eventTable; - uint32 externalsTable; - uint32 methodTable; - } TScriptHeader; - - TScriptHeader _header; - - typedef struct { - char *name; - uint32 pos; - } TFunctionPos; - - typedef struct { - char *name; - uint32 pos; - } TMethodPos; - - typedef struct { - char *name; - uint32 pos; - } TEventPos; - - typedef struct { - char *name; - char *dll_name; - TCallType call_type; - TExternalType returns; - int nu_params; - TExternalType *params; - } TExternalFunction; - - - ScStack *_callStack; - ScStack *_thisStack; - ScStack *_scopeStack; - ScStack *_stack; - ScValue *_globals; - ScEngine *_engine; - int _currentLine; - bool executeInstruction(); - char *getString(); - uint32 getDWORD(); - double getFloat(); - void cleanup(); - bool create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner); - uint32 _iP; -private: - void readHeader(); - uint32 _bufferSize; - byte *_buffer; -public: - Common::SeekableReadStream *_scriptStream; - ScScript(BaseGame *inGame, ScEngine *engine); - virtual ~ScScript(); - char *_filename; - bool _thread; - bool _methodThread; - char *_threadEvent; - BaseScriptHolder *_owner; - ScScript::TExternalFunction *getExternal(char *name); - bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); -private: - char **_symbols; - uint32 _numSymbols; - TFunctionPos *_functions; - TMethodPos *_methods; - TEventPos *_events; - uint32 _numExternals; - TExternalFunction *_externals; - uint32 _numFunctions; - uint32 _numMethods; - uint32 _numEvents; - - bool initScript(); - bool initTables(); - - -// IWmeDebugScript interface implementation -public: - virtual int dbgGetLine(); - virtual const char *dbgGetFilename(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSCRIPT_H +#define WINTERMUTE_SCSCRIPT_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView +#include "engines/wintermute/coll_templ.h" + +namespace Wintermute { +class BaseScriptHolder; +class BaseObject; +class ScEngine; +class ScStack; +class ScScript : public BaseClass { +public: + BaseArray _breakpoints; + bool _tracingMode; + + ScScript *_parentScript; + bool _unbreakable; + bool finishThreads(); + bool copyParameters(ScStack *stack); + + void afterLoad(); +private: + ScValue *_operand; + ScValue *_reg1; +public: + bool _freezable; + bool resume(); + bool pause(); + bool canHandleEvent(const Common::String &eventName); + bool canHandleMethod(const Common::String &methodName); + bool createThread(ScScript *original, uint32 initIP, const Common::String &eventName); + bool createMethodThread(ScScript *original, const Common::String &methodName); + ScScript *invokeEventHandler(const Common::String &eventName, bool unbreakable = false); + uint32 _timeSlice; + DECLARE_PERSISTENT(ScScript, BaseClass) + void runtimeError(const char *fmt, ...); + bool run(); + bool finish(bool includingThreads = false); + bool sleep(uint32 duration); + bool waitForExclusive(BaseObject *object); + bool waitFor(BaseObject *object); + uint32 _waitTime; + bool _waitFrozen; + BaseObject *_waitObject; + ScScript *_waitScript; + TScriptState _state; + TScriptState _origState; + ScValue *getVar(char *name); + uint32 getFuncPos(const Common::String &name); + uint32 getEventPos(const Common::String &name); + uint32 getMethodPos(const Common::String &name); + typedef struct { + uint32 magic; + uint32 version; + uint32 codeStart; + uint32 funcTable; + uint32 symbolTable; + uint32 eventTable; + uint32 externalsTable; + uint32 methodTable; + } TScriptHeader; + + TScriptHeader _header; + + typedef struct { + char *name; + uint32 pos; + } TFunctionPos; + + typedef struct { + char *name; + uint32 pos; + } TMethodPos; + + typedef struct { + char *name; + uint32 pos; + } TEventPos; + + typedef struct { + char *name; + char *dll_name; + TCallType call_type; + TExternalType returns; + int nu_params; + TExternalType *params; + } TExternalFunction; + + + ScStack *_callStack; + ScStack *_thisStack; + ScStack *_scopeStack; + ScStack *_stack; + ScValue *_globals; + ScEngine *_engine; + int _currentLine; + bool executeInstruction(); + char *getString(); + uint32 getDWORD(); + double getFloat(); + void cleanup(); + bool create(const char *filename, byte *buffer, uint32 size, BaseScriptHolder *owner); + uint32 _iP; +private: + void readHeader(); + uint32 _bufferSize; + byte *_buffer; +public: + Common::SeekableReadStream *_scriptStream; + ScScript(BaseGame *inGame, ScEngine *engine); + virtual ~ScScript(); + char *_filename; + bool _thread; + bool _methodThread; + char *_threadEvent; + BaseScriptHolder *_owner; + ScScript::TExternalFunction *getExternal(char *name); + bool externalCall(ScStack *stack, ScStack *thisStack, ScScript::TExternalFunction *function); +private: + char **_symbols; + uint32 _numSymbols; + TFunctionPos *_functions; + TMethodPos *_methods; + TEventPos *_events; + uint32 _numExternals; + TExternalFunction *_externals; + uint32 _numFunctions; + uint32 _numMethods; + uint32 _numEvents; + + bool initScript(); + bool initTables(); + + +// IWmeDebugScript interface implementation +public: + virtual int dbgGetLine(); + virtual const char *dbgGetFilename(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 02f6080958..20e2ccadd1 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -1,610 +1,610 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_engine.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_ext_math.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/utils.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(ScEngine, true) - -#define COMPILER_DLL "dcscomp.dll" -////////////////////////////////////////////////////////////////////////// -ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { - _gameRef->LOG(0, "Initializing scripting engine..."); - - if (_compilerAvailable) { - _gameRef->LOG(0, " Script compiler bound successfuly"); - } else { - _gameRef->LOG(0, " Script compiler is NOT available"); - } - - _globals = new ScValue(_gameRef); - - - // register 'Game' as global variable - if (!_globals->propExists("Game")) { - ScValue val(_gameRef); - val.setNative(_gameRef, true); - _globals->setProp("Game", &val); - } - - // register 'Math' as global variable - if (!_globals->propExists("Math")) { - ScValue val(_gameRef); - val.setNative(_gameRef->_mathClass, true); - _globals->setProp("Math", &val); - } - - // prepare script cache - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - _cachedScripts[i] = NULL; - } - - _currentScript = NULL; - - _isProfiling = false; - _profilingStartTime = 0; - - //EnableProfiling(); -} - - -////////////////////////////////////////////////////////////////////////// -ScEngine::~ScEngine() { - _gameRef->LOG(0, "Shutting down scripting engine"); - - disableProfiling(); - - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::cleanup() { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) { - _scripts[i]->_owner->removeScript(_scripts[i]); - } - delete _scripts[i]; - _scripts.remove_at(i); - i--; - } - - _scripts.clear(); - - delete _globals; - _globals = NULL; - - emptyScriptCache(); - - _currentScript = NULL; // ref only - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { - return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::closeFile(void *data, byte *buffer) { - delete[] buffer; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::parseElement(void *data, int line, int type, void *elementData) { -} - - -////////////////////////////////////////////////////////////////////////// -ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { - byte *compBuffer; - uint32 compSize; - - // get script from cache - compBuffer = getCompiledScript(filename, &compSize); - if (!compBuffer) { - return NULL; - } - - // add new script - ScScript *script = new ScScript(_gameRef, this); - bool ret = script->create(filename, compBuffer, compSize, owner); - if (DID_FAIL(ret)) { - _gameRef->LOG(ret, "Error running script '%s'...", filename); - delete script; - return NULL; - } else { - // publish the "self" pseudo-variable - ScValue val(_gameRef); - if (owner) { - val.setNative(owner, true); - } else { - val.setNULL(); - } - - script->_globals->setProp("self", &val); - script->_globals->setProp("this", &val); - - _scripts.add(script); - - return script; - } -} - - -////////////////////////////////////////////////////////////////////////// -byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { - // is script in cache? - if (!ignoreCache) { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { - _cachedScripts[i]->_timestamp = g_system->getMillis(); - *outSize = _cachedScripts[i]->_size; - return _cachedScripts[i]->_buffer; - } - } - } - - // nope, load it - byte *compBuffer; - uint32 compSize; - - uint32 size; - - byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); - if (!buffer) { - _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); - return NULL; - } - - // needs to be compiled? - if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { - compBuffer = buffer; - compSize = size; - } else { - if (!_compilerAvailable) { - _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); - delete[] buffer; - return NULL; - } - // This code will never be called, since _compilerAvailable is const false. - // It's only here in the event someone would want to reinclude the compiler. - error("Script needs compilation, ScummVM does not contain a WME compiler"); - } - - byte *ret = NULL; - - // add script to cache - CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); - if (cachedScript) { - int index = 0; - uint32 minTime = g_system->getMillis(); - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i] == NULL) { - index = i; - break; - } else if (_cachedScripts[i]->_timestamp <= minTime) { - minTime = _cachedScripts[i]->_timestamp; - index = i; - } - } - - if (_cachedScripts[index] != NULL) { - delete _cachedScripts[index]; - } - _cachedScripts[index] = cachedScript; - - ret = cachedScript->_buffer; - *outSize = cachedScript->_size; - } - - - // cleanup - delete[] buffer; - - return ret; -} - - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::tick() { - if (_scripts.size() == 0) { - return STATUS_OK; - } - - - // resolve waiting scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - - switch (_scripts[i]->_state) { - case SCRIPT_WAITING: { - /* - bool obj_found=false; - for(int j=0; j<_gameRef->_regObjects.size(); j++) - { - if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) - { - if (_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); - obj_found = true; - break; - } - } - if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists - */ - if (_gameRef->validObject(_scripts[i]->_waitObject)) { - if (_scripts[i]->_waitObject->isReady()) { - _scripts[i]->run(); - } - } else { - _scripts[i]->finish(); - } - break; - } - - case SCRIPT_SLEEPING: { - if (_scripts[i]->_waitFrozen) { - if (_scripts[i]->_waitTime <= g_system->getMillis()) { - _scripts[i]->run(); - } - } else { - if (_scripts[i]->_waitTime <= _gameRef->_timer) { - _scripts[i]->run(); - } - } - break; - } - - case SCRIPT_WAITING_SCRIPT: { - if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { - // fake return value - _scripts[i]->_stack->pushNULL(); - _scripts[i]->_waitScript = NULL; - _scripts[i]->run(); - } else { - if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { - // copy return value - _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); - _scripts[i]->run(); - _scripts[i]->_waitScript->finish(); - _scripts[i]->_waitScript = NULL; - } - } - break; - } - default: - break; - } // switch - } // for each script - - - // execute scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - - // skip paused scripts - if (_scripts[i]->_state == SCRIPT_PAUSED) { - continue; - } - - // time sliced script - if (_scripts[i]->_timeSlice > 0) { - uint32 startTime = g_system->getMillis(); - while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - startTime < _scripts[i]->_timeSlice) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (_isProfiling && _scripts[i]->_filename) { - addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); - } - } - - // normal script - else { - uint32 startTime = 0; - bool isProfiling = _isProfiling; - if (isProfiling) { - startTime = g_system->getMillis(); - } - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - if (isProfiling && _scripts[i]->_filename) { - addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); - } - } - _currentScript = NULL; - } - - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::tickUnbreakable() { - // execute unbreakable scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - if (!_scripts[i]->_unbreakable) { - continue; - } - - while (_scripts[i]->_state == SCRIPT_RUNNING) { - _currentScript = _scripts[i]; - _scripts[i]->executeInstruction(); - } - _scripts[i]->finish(); - _currentScript = NULL; - } - removeFinishedScripts(); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::removeFinishedScripts() { - // remove finished scripts - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { - if (!_scripts[i]->_thread && _scripts[i]->_owner) { - _scripts[i]->_owner->removeScript(_scripts[i]); - } - - delete _scripts[i]; - _scripts.remove_at(i); - i--; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { - int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; - - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_state == SCRIPT_FINISHED) { - continue; - } - switch (_scripts[i]->_state) { - case SCRIPT_RUNNING: - case SCRIPT_SLEEPING: - case SCRIPT_PAUSED: - numRunning++; - break; - case SCRIPT_WAITING: - numWaiting++; - break; - case SCRIPT_PERSISTENT: - numPersistent++; - break; - default: - warning("ScEngine::GetNumScripts - unhandled enum"); - break; - } - numTotal++; - } - if (running) { - *running = numRunning; - } - if (waiting) { - *waiting = numWaiting; - } - if (persistent) { - *persistent = numPersistent; - } - - return numTotal; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::emptyScriptCache() { - for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { - if (_cachedScripts[i]) { - delete _cachedScripts[i]; - _cachedScripts[i] = NULL; - } - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::resetObject(BaseObject *Object) { - // terminate all scripts waiting for this object - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { - if (!_gameRef->_compatKillMethodThreads) { - resetScript(_scripts[i]); - } - - bool isThread = _scripts[i]->_methodThread || _scripts[i]->_thread; - _scripts[i]->finish(!isThread); // 1.9b1 - top-level script kills its threads as well - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::resetScript(ScScript *script) { - // terminate all scripts waiting for this script - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { - _scripts[i]->finish(); - } - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::persist(BasePersistenceManager *persistMgr) { - if (!persistMgr->getIsSaving()) { - cleanup(); - } - - persistMgr->transfer(TMEMBER(_gameRef)); - persistMgr->transfer(TMEMBER(_currentScript)); - persistMgr->transfer(TMEMBER(_globals)); - _scripts.persist(persistMgr); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::editorCleanup() { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { - delete _scripts[i]; - _scripts.remove_at(i); - i--; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::pauseAll() { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] != _currentScript) { - _scripts[i]->pause(); - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::resumeAll() { - for (uint32 i = 0; i < _scripts.size(); i++) { - _scripts[i]->resume(); - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::isValidScript(ScScript *script) { - for (uint32 i = 0; i < _scripts.size(); i++) { - if (_scripts[i] == script) { - return true; - } - } - return false; -} - -////////////////////////////////////////////////////////////////////////// -bool ScEngine::clearGlobals(bool includingNatives) { - _globals->CleanProps(includingNatives); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void ScEngine::addScriptTime(const char *filename, uint32 time) { - if (!_isProfiling) { - return; - } - - AnsiString fileName = filename; - fileName.toLowercase(); - _scriptTimes[fileName] += time; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::enableProfiling() { - if (_isProfiling) { - return; - } - - // destroy old data, if any - _scriptTimes.clear(); - - _profilingStartTime = g_system->getMillis(); - _isProfiling = true; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::disableProfiling() { - if (!_isProfiling) { - return; - } - - dumpStats(); - _isProfiling = false; -} - - -////////////////////////////////////////////////////////////////////////// -void ScEngine::dumpStats() { - error("DumpStats not ported to ScummVM yet"); - /* uint32 totalTime = g_system->getMillis() - _profilingStartTime; - - typedef std::vector > TimeVector; - TimeVector times; - - ScriptTimes::iterator it; - for (it = _scriptTimes.begin(); it != _scriptTimes.end(); ++it) { - times.push_back(std::pair (it->_value, it->_key)); - } - std::sort(times.begin(), times.end()); - - - TimeVector::reverse_iterator tit; - - _gameRef->LOG(0, "***** Script profiling information: *****"); - _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); - - for (tit = times.rbegin(); tit != times.rend(); ++tit) { - _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); - }*/ -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_engine.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(ScEngine, true) + +#define COMPILER_DLL "dcscomp.dll" +////////////////////////////////////////////////////////////////////////// +ScEngine::ScEngine(BaseGame *inGame) : BaseClass(inGame) { + _gameRef->LOG(0, "Initializing scripting engine..."); + + if (_compilerAvailable) { + _gameRef->LOG(0, " Script compiler bound successfuly"); + } else { + _gameRef->LOG(0, " Script compiler is NOT available"); + } + + _globals = new ScValue(_gameRef); + + + // register 'Game' as global variable + if (!_globals->propExists("Game")) { + ScValue val(_gameRef); + val.setNative(_gameRef, true); + _globals->setProp("Game", &val); + } + + // register 'Math' as global variable + if (!_globals->propExists("Math")) { + ScValue val(_gameRef); + val.setNative(_gameRef->_mathClass, true); + _globals->setProp("Math", &val); + } + + // prepare script cache + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + _cachedScripts[i] = NULL; + } + + _currentScript = NULL; + + _isProfiling = false; + _profilingStartTime = 0; + + //EnableProfiling(); +} + + +////////////////////////////////////////////////////////////////////////// +ScEngine::~ScEngine() { + _gameRef->LOG(0, "Shutting down scripting engine"); + + disableProfiling(); + + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::cleanup() { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } + delete _scripts[i]; + _scripts.remove_at(i); + i--; + } + + _scripts.clear(); + + delete _globals; + _globals = NULL; + + emptyScriptCache(); + + _currentScript = NULL; // ref only + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte *ScEngine::loadFile(void *data, char *filename, uint32 *size) { + return BaseFileManager::getEngineInstance()->readWholeFile(filename, size); +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::closeFile(void *data, byte *buffer) { + delete[] buffer; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::parseElement(void *data, int line, int type, void *elementData) { +} + + +////////////////////////////////////////////////////////////////////////// +ScScript *ScEngine::runScript(const char *filename, BaseScriptHolder *owner) { + byte *compBuffer; + uint32 compSize; + + // get script from cache + compBuffer = getCompiledScript(filename, &compSize); + if (!compBuffer) { + return NULL; + } + + // add new script + ScScript *script = new ScScript(_gameRef, this); + bool ret = script->create(filename, compBuffer, compSize, owner); + if (DID_FAIL(ret)) { + _gameRef->LOG(ret, "Error running script '%s'...", filename); + delete script; + return NULL; + } else { + // publish the "self" pseudo-variable + ScValue val(_gameRef); + if (owner) { + val.setNative(owner, true); + } else { + val.setNULL(); + } + + script->_globals->setProp("self", &val); + script->_globals->setProp("this", &val); + + _scripts.add(script); + + return script; + } +} + + +////////////////////////////////////////////////////////////////////////// +byte *ScEngine::getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache) { + // is script in cache? + if (!ignoreCache) { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), filename) == 0) { + _cachedScripts[i]->_timestamp = g_system->getMillis(); + *outSize = _cachedScripts[i]->_size; + return _cachedScripts[i]->_buffer; + } + } + } + + // nope, load it + byte *compBuffer; + uint32 compSize; + + uint32 size; + + byte *buffer = BaseEngine::instance().getFileManager()->readWholeFile(filename, &size); + if (!buffer) { + _gameRef->LOG(0, "ScEngine::GetCompiledScript - error opening script '%s'", filename); + return NULL; + } + + // needs to be compiled? + if (FROM_LE_32(*(uint32 *)buffer) == SCRIPT_MAGIC) { + compBuffer = buffer; + compSize = size; + } else { + if (!_compilerAvailable) { + _gameRef->LOG(0, "ScEngine::GetCompiledScript - script '%s' needs to be compiled but compiler is not available", filename); + delete[] buffer; + return NULL; + } + // This code will never be called, since _compilerAvailable is const false. + // It's only here in the event someone would want to reinclude the compiler. + error("Script needs compilation, ScummVM does not contain a WME compiler"); + } + + byte *ret = NULL; + + // add script to cache + CScCachedScript *cachedScript = new CScCachedScript(filename, compBuffer, compSize); + if (cachedScript) { + int index = 0; + uint32 minTime = g_system->getMillis(); + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i] == NULL) { + index = i; + break; + } else if (_cachedScripts[i]->_timestamp <= minTime) { + minTime = _cachedScripts[i]->_timestamp; + index = i; + } + } + + if (_cachedScripts[index] != NULL) { + delete _cachedScripts[index]; + } + _cachedScripts[index] = cachedScript; + + ret = cachedScript->_buffer; + *outSize = cachedScript->_size; + } + + + // cleanup + delete[] buffer; + + return ret; +} + + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::tick() { + if (_scripts.size() == 0) { + return STATUS_OK; + } + + + // resolve waiting scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + + switch (_scripts[i]->_state) { + case SCRIPT_WAITING: { + /* + bool obj_found=false; + for(int j=0; j<_gameRef->_regObjects.size(); j++) + { + if (_gameRef->_regObjects[j] == _scripts[i]->_waitObject) + { + if (_gameRef->_regObjects[j]->IsReady()) _scripts[i]->Run(); + obj_found = true; + break; + } + } + if (!obj_found) _scripts[i]->finish(); // _waitObject no longer exists + */ + if (_gameRef->validObject(_scripts[i]->_waitObject)) { + if (_scripts[i]->_waitObject->isReady()) { + _scripts[i]->run(); + } + } else { + _scripts[i]->finish(); + } + break; + } + + case SCRIPT_SLEEPING: { + if (_scripts[i]->_waitFrozen) { + if (_scripts[i]->_waitTime <= g_system->getMillis()) { + _scripts[i]->run(); + } + } else { + if (_scripts[i]->_waitTime <= _gameRef->_timer) { + _scripts[i]->run(); + } + } + break; + } + + case SCRIPT_WAITING_SCRIPT: { + if (!isValidScript(_scripts[i]->_waitScript) || _scripts[i]->_waitScript->_state == SCRIPT_ERROR) { + // fake return value + _scripts[i]->_stack->pushNULL(); + _scripts[i]->_waitScript = NULL; + _scripts[i]->run(); + } else { + if (_scripts[i]->_waitScript->_state == SCRIPT_THREAD_FINISHED) { + // copy return value + _scripts[i]->_stack->push(_scripts[i]->_waitScript->_stack->pop()); + _scripts[i]->run(); + _scripts[i]->_waitScript->finish(); + _scripts[i]->_waitScript = NULL; + } + } + break; + } + default: + break; + } // switch + } // for each script + + + // execute scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + + // skip paused scripts + if (_scripts[i]->_state == SCRIPT_PAUSED) { + continue; + } + + // time sliced script + if (_scripts[i]->_timeSlice > 0) { + uint32 startTime = g_system->getMillis(); + while (_scripts[i]->_state == SCRIPT_RUNNING && g_system->getMillis() - startTime < _scripts[i]->_timeSlice) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (_isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + } + } + + // normal script + else { + uint32 startTime = 0; + bool isProfiling = _isProfiling; + if (isProfiling) { + startTime = g_system->getMillis(); + } + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + if (isProfiling && _scripts[i]->_filename) { + addScriptTime(_scripts[i]->_filename, g_system->getMillis() - startTime); + } + } + _currentScript = NULL; + } + + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::tickUnbreakable() { + // execute unbreakable scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + if (!_scripts[i]->_unbreakable) { + continue; + } + + while (_scripts[i]->_state == SCRIPT_RUNNING) { + _currentScript = _scripts[i]; + _scripts[i]->executeInstruction(); + } + _scripts[i]->finish(); + _currentScript = NULL; + } + removeFinishedScripts(); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::removeFinishedScripts() { + // remove finished scripts + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR) { + if (!_scripts[i]->_thread && _scripts[i]->_owner) { + _scripts[i]->_owner->removeScript(_scripts[i]); + } + + delete _scripts[i]; + _scripts.remove_at(i); + i--; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int ScEngine::getNumScripts(int *running, int *waiting, int *persistent) { + int numRunning = 0, numWaiting = 0, numPersistent = 0, numTotal = 0; + + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_state == SCRIPT_FINISHED) { + continue; + } + switch (_scripts[i]->_state) { + case SCRIPT_RUNNING: + case SCRIPT_SLEEPING: + case SCRIPT_PAUSED: + numRunning++; + break; + case SCRIPT_WAITING: + numWaiting++; + break; + case SCRIPT_PERSISTENT: + numPersistent++; + break; + default: + warning("ScEngine::GetNumScripts - unhandled enum"); + break; + } + numTotal++; + } + if (running) { + *running = numRunning; + } + if (waiting) { + *waiting = numWaiting; + } + if (persistent) { + *persistent = numPersistent; + } + + return numTotal; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::emptyScriptCache() { + for (int i = 0; i < MAX_CACHED_SCRIPTS; i++) { + if (_cachedScripts[i]) { + delete _cachedScripts[i]; + _cachedScripts[i] = NULL; + } + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::resetObject(BaseObject *Object) { + // terminate all scripts waiting for this object + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING && _scripts[i]->_waitObject == Object) { + if (!_gameRef->_compatKillMethodThreads) { + resetScript(_scripts[i]); + } + + bool isThread = _scripts[i]->_methodThread || _scripts[i]->_thread; + _scripts[i]->finish(!isThread); // 1.9b1 - top-level script kills its threads as well + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::resetScript(ScScript *script) { + // terminate all scripts waiting for this script + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_state == SCRIPT_WAITING_SCRIPT && _scripts[i]->_waitScript == script) { + _scripts[i]->finish(); + } + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::persist(BasePersistenceManager *persistMgr) { + if (!persistMgr->getIsSaving()) { + cleanup(); + } + + persistMgr->transfer(TMEMBER(_gameRef)); + persistMgr->transfer(TMEMBER(_currentScript)); + persistMgr->transfer(TMEMBER(_globals)); + _scripts.persist(persistMgr); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::editorCleanup() { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i]->_owner == NULL && (_scripts[i]->_state == SCRIPT_FINISHED || _scripts[i]->_state == SCRIPT_ERROR)) { + delete _scripts[i]; + _scripts.remove_at(i); + i--; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::pauseAll() { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] != _currentScript) { + _scripts[i]->pause(); + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::resumeAll() { + for (uint32 i = 0; i < _scripts.size(); i++) { + _scripts[i]->resume(); + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::isValidScript(ScScript *script) { + for (uint32 i = 0; i < _scripts.size(); i++) { + if (_scripts[i] == script) { + return true; + } + } + return false; +} + +////////////////////////////////////////////////////////////////////////// +bool ScEngine::clearGlobals(bool includingNatives) { + _globals->CleanProps(includingNatives); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void ScEngine::addScriptTime(const char *filename, uint32 time) { + if (!_isProfiling) { + return; + } + + AnsiString fileName = filename; + fileName.toLowercase(); + _scriptTimes[fileName] += time; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::enableProfiling() { + if (_isProfiling) { + return; + } + + // destroy old data, if any + _scriptTimes.clear(); + + _profilingStartTime = g_system->getMillis(); + _isProfiling = true; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::disableProfiling() { + if (!_isProfiling) { + return; + } + + dumpStats(); + _isProfiling = false; +} + + +////////////////////////////////////////////////////////////////////////// +void ScEngine::dumpStats() { + error("DumpStats not ported to ScummVM yet"); + /* uint32 totalTime = g_system->getMillis() - _profilingStartTime; + + typedef std::vector > TimeVector; + TimeVector times; + + ScriptTimes::iterator it; + for (it = _scriptTimes.begin(); it != _scriptTimes.end(); ++it) { + times.push_back(std::pair (it->_value, it->_key)); + } + std::sort(times.begin(), times.end()); + + + TimeVector::reverse_iterator tit; + + _gameRef->LOG(0, "***** Script profiling information: *****"); + _gameRef->LOG(0, " %-40s %fs", "Total execution time", (float)totalTime / 1000); + + for (tit = times.rbegin(); tit != times.rend(); ++tit) { + _gameRef->LOG(0, " %-40s %fs (%f%%)", tit->second.c_str(), (float)tit->first / 1000, (float)tit->first / (float)totalTime * 100); + }*/ +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_engine.h b/engines/wintermute/base/scriptables/script_engine.h index f526353368..1a023326eb 100644 --- a/engines/wintermute/base/scriptables/script_engine.h +++ b/engines/wintermute/base/scriptables/script_engine.h @@ -1,135 +1,135 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCENGINE_H -#define WINTERMUTE_SCENGINE_H - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/base.h" - -namespace Wintermute { - -#define MAX_CACHED_SCRIPTS 20 -class ScScript; -class ScValue; -class BaseObject; -class BaseScriptHolder; -class ScEngine : public BaseClass { -public: - class CScCachedScript { - public: - CScCachedScript(const char *filename, byte *buffer, uint32 size) { - _timestamp = g_system->getMillis(); - _buffer = new byte[size]; - if (_buffer) { - memcpy(_buffer, buffer, size); - } - _size = size; - _filename = filename; - }; - - ~CScCachedScript() { - if (_buffer) { - delete[] _buffer; - } - }; - - uint32 _timestamp; - byte *_buffer; - uint32 _size; - Common::String _filename; - }; - - class CScBreakpoint { - public: - CScBreakpoint(const char *filename) { - _filename = filename; - } - - ~CScBreakpoint() { - _lines.clear(); - } - - Common::String _filename; - BaseArray _lines; - }; - -public: - bool clearGlobals(bool includingNatives = false); - bool tickUnbreakable(); - bool removeFinishedScripts(); - bool isValidScript(ScScript *script); - - ScScript *_currentScript; - bool resumeAll(); - bool pauseAll(); - void editorCleanup(); - bool resetObject(BaseObject *Object); - bool resetScript(ScScript *script); - bool emptyScriptCache(); - byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); - DECLARE_PERSISTENT(ScEngine, BaseClass) - bool cleanup(); - int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); - bool tick(); - ScValue *_globals; - ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); - static const bool _compilerAvailable = false; - - ScEngine(BaseGame *inGame); - virtual ~ScEngine(); - static byte *loadFile(void *data, char *filename, uint32 *size); - static void closeFile(void *data, byte *buffer); - static void parseElement(void *data, int line, int type, void *elementData); - - BaseArray _scripts; - - void enableProfiling(); - void disableProfiling(); - bool getIsProfiling() { - return _isProfiling; - } - - void addScriptTime(const char *filename, uint32 Time); - void dumpStats(); - -private: - - CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; - bool _isProfiling; - uint32 _profilingStartTime; - - typedef Common::HashMap ScriptTimes; - ScriptTimes _scriptTimes; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCENGINE_H +#define WINTERMUTE_SCENGINE_H + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" + +namespace Wintermute { + +#define MAX_CACHED_SCRIPTS 20 +class ScScript; +class ScValue; +class BaseObject; +class BaseScriptHolder; +class ScEngine : public BaseClass { +public: + class CScCachedScript { + public: + CScCachedScript(const char *filename, byte *buffer, uint32 size) { + _timestamp = g_system->getMillis(); + _buffer = new byte[size]; + if (_buffer) { + memcpy(_buffer, buffer, size); + } + _size = size; + _filename = filename; + }; + + ~CScCachedScript() { + if (_buffer) { + delete[] _buffer; + } + }; + + uint32 _timestamp; + byte *_buffer; + uint32 _size; + Common::String _filename; + }; + + class CScBreakpoint { + public: + CScBreakpoint(const char *filename) { + _filename = filename; + } + + ~CScBreakpoint() { + _lines.clear(); + } + + Common::String _filename; + BaseArray _lines; + }; + +public: + bool clearGlobals(bool includingNatives = false); + bool tickUnbreakable(); + bool removeFinishedScripts(); + bool isValidScript(ScScript *script); + + ScScript *_currentScript; + bool resumeAll(); + bool pauseAll(); + void editorCleanup(); + bool resetObject(BaseObject *Object); + bool resetScript(ScScript *script); + bool emptyScriptCache(); + byte *getCompiledScript(const char *filename, uint32 *outSize, bool ignoreCache = false); + DECLARE_PERSISTENT(ScEngine, BaseClass) + bool cleanup(); + int getNumScripts(int *running = NULL, int *waiting = NULL, int *persistent = NULL); + bool tick(); + ScValue *_globals; + ScScript *runScript(const char *filename, BaseScriptHolder *owner = NULL); + static const bool _compilerAvailable = false; + + ScEngine(BaseGame *inGame); + virtual ~ScEngine(); + static byte *loadFile(void *data, char *filename, uint32 *size); + static void closeFile(void *data, byte *buffer); + static void parseElement(void *data, int line, int type, void *elementData); + + BaseArray _scripts; + + void enableProfiling(); + void disableProfiling(); + bool getIsProfiling() { + return _isProfiling; + } + + void addScriptTime(const char *filename, uint32 Time); + void dumpStats(); + +private: + + CScCachedScript *_cachedScripts[MAX_CACHED_SCRIPTS]; + bool _isProfiling; + uint32 _profilingStartTime; + + typedef Common::HashMap ScriptTimes; + ScriptTimes _scriptTimes; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index c8d4f64ae9..5ed07f0da6 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -1,252 +1,252 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/system/sys_instance.h" -#include "engines/wintermute/base/scriptables/script_ext_array.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(SXArray, false) - -BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { - return new SXArray(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - _length = 0; - _values = new ScValue(_gameRef); - - int numParams = stack->pop()->getInt(0); - - if (numParams == 1) { - _length = stack->pop()->getInt(0); - } else if (numParams > 1) { - _length = numParams; - char paramName[20]; - for (int i = 0; i < numParams; i++) { - sprintf(paramName, "%d", i); - _values->setProp(paramName, stack->pop()); - } - } -} - -////////////////////////////////////////////////////////////////////////// -SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { - _length = 0; - _values = new ScValue(_gameRef); -} - - -////////////////////////////////////////////////////////////////////////// -SXArray::~SXArray() { - delete _values; - _values = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -const char *SXArray::scToString() { - char dummy[32768]; - strcpy(dummy, ""); - char propName[20]; - for (int i = 0; i < _length; i++) { - sprintf(propName, "%d", i); - ScValue *val = _values->getProp(propName); - if (val) { - if (strlen(dummy) + strlen(val->getString()) < 32768) { - strcat(dummy, val->getString()); - } - } - - if (i < _length - 1 && strlen(dummy) + 1 < 32768) { - strcat(dummy, ","); - } - } - _strRep = dummy; - return _strRep.c_str(); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Push - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Push") == 0) { - int numParams = stack->pop()->getInt(0); - char paramName[20]; - - for (int i = 0; i < numParams; i++) { - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, stack->pop(), true); - } - stack->pushInt(_length); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pop - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Pop") == 0) { - - stack->correctParams(0); - - if (_length > 0) { - char paramName[20]; - sprintf(paramName, "%d", _length - 1); - stack->push(_values->getProp(paramName)); - _values->deleteProp(paramName); - _length--; - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXArray::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("array"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(_length); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char paramName[20]; - if (validNumber(name, paramName)) { - return _values->getProp(paramName); - } else { - return _scValue; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXArray::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length") == 0) { - int origLength = _length; - _length = MAX(value->getInt(0), 0); - - char propName[20]; - if (_length < origLength) { - for (int i = _length; i < origLength; i++) { - sprintf(propName, "%d", i); - _values->deleteProp(propName); - } - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // [number] - ////////////////////////////////////////////////////////////////////////// - else { - char paramName[20]; - if (validNumber(name, paramName)) { - int index = atoi(paramName); - if (index >= _length) { - _length = index + 1; - } - return _values->setProp(paramName, value); - } else { - return STATUS_FAILED; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXArray::persist(BasePersistenceManager *persistMgr) { - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_length)); - persistMgr->transfer(TMEMBER(_values)); - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool SXArray::validNumber(const char *origStr, char *outStr) { - bool isNumber = true; - for (uint32 i = 0; i < strlen(origStr); i++) { - if (!(origStr[i] >= '0' && origStr[i] <= '9')) { - isNumber = false; - break; - } - } - - if (isNumber) { - int index = atoi(origStr); - sprintf(outStr, "%d", index); - return true; - } else { - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SXArray::push(ScValue *val) { - char paramName[20]; - _length++; - sprintf(paramName, "%d", _length - 1); - _values->setProp(paramName, val, true); - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/system/sys_instance.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(SXArray, false) + +BaseScriptable *makeSXArray(BaseGame *inGame, ScStack *stack) { + return new SXArray(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXArray::SXArray(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + _length = 0; + _values = new ScValue(_gameRef); + + int numParams = stack->pop()->getInt(0); + + if (numParams == 1) { + _length = stack->pop()->getInt(0); + } else if (numParams > 1) { + _length = numParams; + char paramName[20]; + for (int i = 0; i < numParams; i++) { + sprintf(paramName, "%d", i); + _values->setProp(paramName, stack->pop()); + } + } +} + +////////////////////////////////////////////////////////////////////////// +SXArray::SXArray(BaseGame *inGame) : BaseScriptable(inGame) { + _length = 0; + _values = new ScValue(_gameRef); +} + + +////////////////////////////////////////////////////////////////////////// +SXArray::~SXArray() { + delete _values; + _values = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +const char *SXArray::scToString() { + char dummy[32768]; + strcpy(dummy, ""); + char propName[20]; + for (int i = 0; i < _length; i++) { + sprintf(propName, "%d", i); + ScValue *val = _values->getProp(propName); + if (val) { + if (strlen(dummy) + strlen(val->getString()) < 32768) { + strcat(dummy, val->getString()); + } + } + + if (i < _length - 1 && strlen(dummy) + 1 < 32768) { + strcat(dummy, ","); + } + } + _strRep = dummy; + return _strRep.c_str(); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Push + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Push") == 0) { + int numParams = stack->pop()->getInt(0); + char paramName[20]; + + for (int i = 0; i < numParams; i++) { + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, stack->pop(), true); + } + stack->pushInt(_length); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pop + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Pop") == 0) { + + stack->correctParams(0); + + if (_length > 0) { + char paramName[20]; + sprintf(paramName, "%d", _length - 1); + stack->push(_values->getProp(paramName)); + _values->deleteProp(paramName); + _length--; + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXArray::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("array"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(_length); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + return _values->getProp(paramName); + } else { + return _scValue; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXArray::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length") == 0) { + int origLength = _length; + _length = MAX(value->getInt(0), 0); + + char propName[20]; + if (_length < origLength) { + for (int i = _length; i < origLength; i++) { + sprintf(propName, "%d", i); + _values->deleteProp(propName); + } + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // [number] + ////////////////////////////////////////////////////////////////////////// + else { + char paramName[20]; + if (validNumber(name, paramName)) { + int index = atoi(paramName); + if (index >= _length) { + _length = index + 1; + } + return _values->setProp(paramName, value); + } else { + return STATUS_FAILED; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXArray::persist(BasePersistenceManager *persistMgr) { + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_length)); + persistMgr->transfer(TMEMBER(_values)); + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool SXArray::validNumber(const char *origStr, char *outStr) { + bool isNumber = true; + for (uint32 i = 0; i < strlen(origStr); i++) { + if (!(origStr[i] >= '0' && origStr[i] <= '9')) { + isNumber = false; + break; + } + } + + if (isNumber) { + int index = atoi(origStr); + sprintf(outStr, "%d", index); + return true; + } else { + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SXArray::push(ScValue *val) { + char paramName[20]; + _length++; + sprintf(paramName, "%d", _length - 1); + _values->setProp(paramName, val, true); + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index 614f829950..d9805ef94f 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -1,56 +1,56 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXARRAY_H -#define WINTERMUTE_SXARRAY_H - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXArray : public BaseScriptable { -public: - bool push(ScValue *val); - bool validNumber(const char *origStr, char *outStr); - DECLARE_PERSISTENT(SXArray, BaseScriptable) - SXArray(BaseGame *inGame, ScStack *stack); - SXArray(BaseGame *inGame); - virtual ~SXArray(); - ScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, ScValue *value); - bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - const char *scToString(); -private: - int _length; - ScValue *_values; - Common::String _strRep; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXARRAY_H +#define WINTERMUTE_SXARRAY_H + +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class SXArray : public BaseScriptable { +public: + bool push(ScValue *val); + bool validNumber(const char *origStr, char *outStr); + DECLARE_PERSISTENT(SXArray, BaseScriptable) + SXArray(BaseGame *inGame, ScStack *stack); + SXArray(BaseGame *inGame); + virtual ~SXArray(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + const char *scToString(); +private: + int _length; + ScValue *_values; + Common::String _strRep; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 7726015081..11eead3b9c 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -1,293 +1,293 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_ext_date.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(SXDate, false) - -BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { - return new SXDate(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(6); - - memset(&_tm, 0, sizeof(_tm)); - - ScValue *valYear = stack->pop(); - _tm.tm_year = valYear->getInt() - 1900; - _tm.tm_mon = stack->pop()->getInt() - 1; - _tm.tm_mday = stack->pop()->getInt(); - _tm.tm_hour = stack->pop()->getInt(); - _tm.tm_min = stack->pop()->getInt(); - _tm.tm_sec = stack->pop()->getInt(); - - if (valYear->isNULL()) { - g_system->getTimeAndDate(_tm); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXDate::~SXDate() { - -} - -////////////////////////////////////////////////////////////////////////// -const char *SXDate::scToString() { - // TODO: Make this more stringy, and less ISO 8601-like - _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); - return _strRep.c_str(); - //return asctime(&_tm); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // GetYear - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "GetYear") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_year + 1900); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMonth") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mon + 1); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDate") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_mday); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetHours") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_hour); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetMinutes") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_min); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetSeconds") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_sec); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // GetWeekday - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetWeekday") == 0) { - stack->correctParams(0); - stack->pushInt(_tm.tm_wday); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetYear - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetYear") == 0) { - stack->correctParams(1); - _tm.tm_year = stack->pop()->getInt() - 1900; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMonth - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMonth") == 0) { - stack->correctParams(1); - _tm.tm_mon = stack->pop()->getInt() - 1; - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetDate - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDate") == 0) { - stack->correctParams(1); - _tm.tm_mday = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetHours - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetHours") == 0) { - stack->correctParams(1); - _tm.tm_hour = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetMinutes - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetMinutes") == 0) { - stack->correctParams(1); - _tm.tm_min = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - ////////////////////////////////////////////////////////////////////////// - // SetSeconds - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetSeconds") == 0) { - stack->correctParams(1); - _tm.tm_sec = stack->pop()->getInt(); - stack->pushNULL(); - return STATUS_OK; - } - - - ////////////////////////////////////////////////////////////////////////// - // SetCurrentTime - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetCurrentTime") == 0) { - stack->correctParams(0); - g_system->getTimeAndDate(_tm); - stack->pushNULL(); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXDate::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("date"); - return _scValue; - } else { - return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Name - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name")==0){ - setName(value->getString()); - return STATUS_OK; - } - - else*/ return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool SXDate::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - persistMgr->transfer(TMEMBER(_tm.tm_year)); - persistMgr->transfer(TMEMBER(_tm.tm_mon)); - persistMgr->transfer(TMEMBER(_tm.tm_mday)); - persistMgr->transfer(TMEMBER(_tm.tm_hour)); - persistMgr->transfer(TMEMBER(_tm.tm_min)); - persistMgr->transfer(TMEMBER(_tm.tm_sec)); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -int SXDate::scCompare(BaseScriptable *Value) { - TimeDate time1 = _tm; - TimeDate time2 = ((SXDate *)Value)->_tm; - - if (time1.tm_year < time2.tm_year) { - return -1; - } else if (time1.tm_year == time2.tm_year) { - if (time1.tm_mon < time2.tm_mon) { - return -1; - } else if (time1.tm_mon == time2.tm_mon) { - if (time1.tm_mday < time2.tm_mday) { - return -1; - } else if (time1.tm_mday == time2.tm_mday) { - if (time1.tm_hour < time2.tm_hour) { - return -1; - } else if (time1.tm_hour == time2.tm_hour) { - if (time1.tm_min < time2.tm_min) { - return -1; - } else if (time1.tm_min == time2.tm_min) { - if (time1.tm_sec < time2.tm_sec) { - return -1; - } else if (time1.tm_sec == time2.tm_sec) { - return 0; // Equal - } else { - return 1; // Sec - } - } else { - return 1; // Minute - } - } else { - return 1; // Hour - } - } else { - return 1; // Day - } - } else { - return 1; // Month - } - } else { - return 1; // Year - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_date.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(SXDate, false) + +BaseScriptable *makeSXDate(BaseGame *inGame, ScStack *stack) { + return new SXDate(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXDate::SXDate(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(6); + + memset(&_tm, 0, sizeof(_tm)); + + ScValue *valYear = stack->pop(); + _tm.tm_year = valYear->getInt() - 1900; + _tm.tm_mon = stack->pop()->getInt() - 1; + _tm.tm_mday = stack->pop()->getInt(); + _tm.tm_hour = stack->pop()->getInt(); + _tm.tm_min = stack->pop()->getInt(); + _tm.tm_sec = stack->pop()->getInt(); + + if (valYear->isNULL()) { + g_system->getTimeAndDate(_tm); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXDate::~SXDate() { + +} + +////////////////////////////////////////////////////////////////////////// +const char *SXDate::scToString() { + // TODO: Make this more stringy, and less ISO 8601-like + _strRep.format("%04d-%02d-%02d - %02d:%02d:%02d", _tm.tm_year, _tm.tm_mon, _tm.tm_mday, _tm.tm_hour, _tm.tm_min, _tm.tm_sec); + return _strRep.c_str(); + //return asctime(&_tm); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // GetYear + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "GetYear") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_year + 1900); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMonth") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mon + 1); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDate") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_mday); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetHours") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_hour); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetMinutes") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_min); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetSeconds") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_sec); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // GetWeekday + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetWeekday") == 0) { + stack->correctParams(0); + stack->pushInt(_tm.tm_wday); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetYear + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetYear") == 0) { + stack->correctParams(1); + _tm.tm_year = stack->pop()->getInt() - 1900; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMonth + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMonth") == 0) { + stack->correctParams(1); + _tm.tm_mon = stack->pop()->getInt() - 1; + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetDate + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDate") == 0) { + stack->correctParams(1); + _tm.tm_mday = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetHours + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetHours") == 0) { + stack->correctParams(1); + _tm.tm_hour = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetMinutes + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetMinutes") == 0) { + stack->correctParams(1); + _tm.tm_min = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + ////////////////////////////////////////////////////////////////////////// + // SetSeconds + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetSeconds") == 0) { + stack->correctParams(1); + _tm.tm_sec = stack->pop()->getInt(); + stack->pushNULL(); + return STATUS_OK; + } + + + ////////////////////////////////////////////////////////////////////////// + // SetCurrentTime + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetCurrentTime") == 0) { + stack->correctParams(0); + g_system->getTimeAndDate(_tm); + stack->pushNULL(); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXDate::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("date"); + return _scValue; + } else { + return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Name + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Name")==0){ + setName(value->getString()); + return STATUS_OK; + } + + else*/ return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool SXDate::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + persistMgr->transfer(TMEMBER(_tm.tm_year)); + persistMgr->transfer(TMEMBER(_tm.tm_mon)); + persistMgr->transfer(TMEMBER(_tm.tm_mday)); + persistMgr->transfer(TMEMBER(_tm.tm_hour)); + persistMgr->transfer(TMEMBER(_tm.tm_min)); + persistMgr->transfer(TMEMBER(_tm.tm_sec)); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +int SXDate::scCompare(BaseScriptable *Value) { + TimeDate time1 = _tm; + TimeDate time2 = ((SXDate *)Value)->_tm; + + if (time1.tm_year < time2.tm_year) { + return -1; + } else if (time1.tm_year == time2.tm_year) { + if (time1.tm_mon < time2.tm_mon) { + return -1; + } else if (time1.tm_mon == time2.tm_mon) { + if (time1.tm_mday < time2.tm_mday) { + return -1; + } else if (time1.tm_mday == time2.tm_mday) { + if (time1.tm_hour < time2.tm_hour) { + return -1; + } else if (time1.tm_hour == time2.tm_hour) { + if (time1.tm_min < time2.tm_min) { + return -1; + } else if (time1.tm_min == time2.tm_min) { + if (time1.tm_sec < time2.tm_sec) { + return -1; + } else if (time1.tm_sec == time2.tm_sec) { + return 0; // Equal + } else { + return 1; // Sec + } + } else { + return 1; // Minute + } + } else { + return 1; // Hour + } + } else { + return 1; // Day + } + } else { + return 1; // Month + } + } else { + return 1; // Year + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index 7cdf57e689..f6f04dd7e6 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -1,54 +1,54 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXDATE_H -#define WINTERMUTE_SXDATE_H - -#include "common/system.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXDate : public BaseScriptable { -public: - int scCompare(BaseScriptable *Value); - DECLARE_PERSISTENT(SXDate, BaseScriptable) - SXDate(BaseGame *inGame, ScStack *Stack); - virtual ~SXDate(); - ScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, ScValue *value); - bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - const char *scToString(); -private: - TimeDate _tm; - Common::String _strRep; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXDATE_H +#define WINTERMUTE_SXDATE_H + +#include "common/system.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class SXDate : public BaseScriptable { +public: + int scCompare(BaseScriptable *Value); + DECLARE_PERSISTENT(SXDate, BaseScriptable) + SXDate(BaseGame *inGame, ScStack *Stack); + virtual ~SXDate(); + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + const char *scToString(); +private: + TimeDate _tm; + Common::String _strRep; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 53d551119d..ab574d464b 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -1,829 +1,829 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/system/sys_class_registry.h" -#include "engines/wintermute/system/sys_class.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/file/base_file.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/scriptables/script_ext_file.h" - -// Note: This code is completely untested, as I have yet to find a game that uses SXFile. - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(SXFile, false) - -BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { - return new SXFile(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(1); - ScValue *val = stack->pop(); - - _filename = NULL; - if (!val->isNULL()) { - BaseUtils::setString(&_filename, val->getString()); - } - - _readFile = NULL; - _writeFile = NULL; - - _mode = 0; - _textMode = false; -} - - -////////////////////////////////////////////////////////////////////////// -SXFile::~SXFile() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void SXFile::cleanup() { - delete[] _filename; - _filename = NULL; - close(); -} - - -////////////////////////////////////////////////////////////////////////// -void SXFile::close() { - if (_readFile) { - BaseFileManager::getEngineInstance()->closeFile(_readFile); - _readFile = NULL; - } - if (_writeFile) { - _writeFile->finalize(); - delete _writeFile; - _writeFile = NULL; - } - _mode = 0; - _textMode = false; -} - -////////////////////////////////////////////////////////////////////////// -const char *SXFile::scToString() { - if (_filename) { - return _filename; - } else { - return "[file object]"; - } -} - -#define FILE_BUFFER_SIZE 32768 -////////////////////////////////////////////////////////////////////////// -bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetFilename - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetFilename") == 0) { - stack->correctParams(1); - const char *filename = stack->pop()->getString(); - cleanup(); - BaseUtils::setString(&_filename, filename); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // OpenAsText / OpenAsBinary - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { - stack->correctParams(1); - close(); - _mode = stack->pop()->getInt(1); - if (_mode < 1 || _mode > 3) { - script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); - _mode = 1; - } - if (_mode == 1) { - _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); - if (!_readFile) { - //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); - close(); - } else { - _textMode = strcmp(name, "OpenAsText") == 0; - } - } else { - if (strcmp(name, "OpenAsText") == 0) { - if (_mode == 2) { - _writeFile = openForWrite(_filename, false); - } else { - _writeFile = openForAppend(_filename, false); - } - } else { - if (_mode == 2) { - _writeFile = openForWrite(_filename, true); - } else { - _writeFile = openForAppend(_filename, true); - } - } - - if (!_writeFile) { - //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); - close(); - } else { - _textMode = strcmp(name, "OpenAsText") == 0; - } - } - - if (_readFile || _writeFile) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Close - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Close") == 0) { - stack->correctParams(0); - close(); - stack->pushNULL(); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPosition - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPosition") == 0) { - stack->correctParams(1); - if (_mode == 0) { - script->runtimeError("File.%s: File is not open", name); - stack->pushBool(false); - } else { - int pos = stack->pop()->getInt(); - stack->pushBool(setPos(pos)); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Delete - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delete") == 0) { - stack->correctParams(0); - close(); - error("SXFile-Method: \"Delete\" not supported"); - //stack->pushBool(BasePlatform::deleteFile(_filename) != false); - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Copy - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Copy") == 0) { - stack->correctParams(2); - /* const char *dest = */ stack->pop()->getString(); - /* bool overwrite = */ stack->pop()->getBool(true); - - close(); - error("SXFile-Method: Copy not supported"); - //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); - stack->pushBool(false); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadLine - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadLine") == 0) { - stack->correctParams(0); - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - bool foundNewLine = false; - bool ret = STATUS_FAILED; - do { - ret = _readFile->read(&b, 1); - if (ret != 1) { - break; - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == '\n') { - buf[counter] = '\0'; - foundNewLine = true; - break; - } else if (b == 0x0D) { - continue; - } else { - buf[counter] = b; - counter++; - } - } while (DID_SUCCEED(ret)); - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (!foundNewLine && counter == 0) { - stack->pushNULL(); - } else { - stack->pushString((char *)buf); - } - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadText") == 0) { - stack->correctParams(1); - int textLen = stack->pop()->getInt(); - - if (!_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open in text mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 bufSize = FILE_BUFFER_SIZE; - byte *buf = (byte *)malloc(bufSize); - uint32 counter = 0; - byte b; - - bool ret = STATUS_FAILED; - while (counter < (uint32)textLen) { - ret = _readFile->read(&b, 1); - if (ret != 1) { - break; - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - if (b == 0x0D) { - continue; - } else { - buf[counter] = b; - counter++; - } - } - - if (counter > bufSize) { - buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); - bufSize += FILE_BUFFER_SIZE; - } - buf[counter] = '\0'; - - if (textLen > 0 && counter == 0) { - stack->pushNULL(); - } else { - stack->pushString((char *)buf); - } - - free(buf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteLine / WriteText - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { - stack->correctParams(1); - const char *line = stack->pop()->getString(); - if (!_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in text mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - Common::String writeLine; - if (strcmp(name, "WriteLine") == 0) { - writeLine = Common::String::format("%s\n", line); - } else { - writeLine = Common::String::format("%s", line); - } - _writeFile->writeString(writeLine); - _writeFile->writeByte(0); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // ReadBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadBool") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - bool val; - if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) { - stack->pushBool(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadByte") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - byte val = _readFile->readByte(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadShort") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int16 val = _readFile->readSint16LE(); - if (!_readFile->err()) { - stack->pushInt(65536 + val); - } else { - stack->pushNULL(); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadInt / ReadLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - int32 val = _readFile->readSint32LE(); - if (!_readFile->err()) { - stack->pushInt(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadFloat") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - float val; - (*(uint32 *)&val) = _readFile->readUint32LE(); - if (!_readFile->err()) { - stack->pushFloat(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. - error("SXFile::ReadDouble - Not endian safe yet"); - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - double val; - if (_readFile->read(&val, sizeof(double)) == sizeof(double)) { - stack->pushFloat(val); - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ReadString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ReadString") == 0) { - stack->correctParams(0); - if (_textMode || !_readFile) { - script->runtimeError("File.%s: File must be open for reading in binary mode.", name); - stack->pushNULL(); - return STATUS_OK; - } - uint32 size = _readFile->readUint32LE(); - if (!_readFile->err()) { - byte *str = new byte[size + 1]; - if (str) { - if (_readFile->read(str, size) == size) { - str[size] = '\0'; - stack->pushString((char *)str); - } - delete[] str; - } else { - stack->pushNULL(); - } - } else { - stack->pushNULL(); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteBool") == 0) { - stack->correctParams(1); - bool val = stack->pop()->getBool(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteByte") == 0) { - stack->correctParams(1); - byte val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeByte(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteShort") == 0) { - stack->correctParams(1); - int16 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint16LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteInt / WriteLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { - stack->correctParams(1); - int32 val = stack->pop()->getInt(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - _writeFile->writeSint32LE(val); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteFloat") == 0) { - stack->correctParams(1); - float val = stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - uint32 *ptr = (uint32 *)&val; - _writeFile->writeUint32LE(*ptr); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteDouble") == 0) { - error("SXFile::WriteDouble - Not endian safe yet"); - stack->correctParams(1); - /* double val = */ stack->pop()->getFloat(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); - stack->pushBool(true); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // WriteString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WriteString") == 0) { - stack->correctParams(1); - const char *val = stack->pop()->getString(); - - if (_textMode || !_writeFile) { - script->runtimeError("File.%s: File must be open for writing in binary mode.", name); - stack->pushBool(false); - return STATUS_OK; - } - - uint32 size = strlen(val); - _writeFile->writeUint32LE(size); - _writeFile->writeString(val); - - stack->pushBool(true); - - return STATUS_OK; - } else { - return BaseScriptable::scCallMethod(script, stack, thisStack, name); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXFile::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("file"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Filename (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { - _scValue->setString(_filename); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Position (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { - _scValue->setInt(getPos()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - _scValue->setInt(getLength()); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // TextMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { - _scValue->setBool(_textMode); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // AccessMode (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { - _scValue->setInt(_mode); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXFile::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length")==0){ - int origLength = _length; - _length = max(value->getInt(0), 0); - - char propName[20]; - if (_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return BaseScriptable::scSetProperty(name, value); -} - -////////////////////////////////////////////////////////////////////////// -uint32 SXFile::getPos() { - if (_mode == 1 && _readFile) { - return _readFile->pos(); - } else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - getPos for WriteFile not supported"); - return 0; -// return ftell((FILE *)_writeFile); - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SXFile::setPos(uint32 pos, int whence) { - if (_mode == 1 && _readFile) { - return _readFile->seek(pos, whence); - } else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - seeking in WriteFile not supported"); - return false; -// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; - } else { - return false; - } -} - -////////////////////////////////////////////////////////////////////////// -uint32 SXFile::getLength() { - if (_mode == 1 && _readFile) { - return _readFile->size(); - } else if ((_mode == 2 || _mode == 3) && _writeFile) { - error("SXFile - reading length for WriteFile not supported"); - return 0; - /* - uint32 currentPos = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, 0, SEEK_END); - int ret = ftell((FILE *)_writeFile); - fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); - return Ret;*/ - } else { - return 0; - } -} - -////////////////////////////////////////////////////////////////////////// -bool SXFile::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_filename)); - persistMgr->transfer(TMEMBER(_mode)); - persistMgr->transfer(TMEMBER(_textMode)); - - uint32 pos = 0; - if (persistMgr->getIsSaving()) { - pos = getPos(); - persistMgr->transfer(TMEMBER(pos)); - } else { - persistMgr->transfer(TMEMBER(pos)); - - // try to re-open file if needed - _writeFile = NULL; - _readFile = NULL; - - if (_mode != 0) { - // open for reading - if (_mode == 1) { - _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); - if (!_readFile) { - close(); - } - } - // open for writing / appending - else { - if (_textMode) { - if (_mode == 2) { - _writeFile = openForWrite(_filename, false); - } else { - _writeFile = openForAppend(_filename, false); - } - } else { - if (_mode == 2) { - _writeFile = openForWrite(_filename, true); - } else { - _writeFile = openForAppend(_filename, true); - } - } - if (_writeFile) { - close(); - } - } - setPos(pos); - } - } - - return STATUS_OK; -} - -// Should replace fopen(..., "wb+") and fopen(..., "w+") -Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool binary) { - error("SXFile::openForWrite - WriteFiles not supported"); -} - -// Should replace fopen(..., "ab+") and fopen(..., "a+") -Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { - error("SXFile::openForAppend - WriteFiles not supported"); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/system/sys_class_registry.h" +#include "engines/wintermute/system/sys_class.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/scriptables/script_ext_file.h" + +// Note: This code is completely untested, as I have yet to find a game that uses SXFile. + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(SXFile, false) + +BaseScriptable *makeSXFile(BaseGame *inGame, ScStack *stack) { + return new SXFile(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXFile::SXFile(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(1); + ScValue *val = stack->pop(); + + _filename = NULL; + if (!val->isNULL()) { + BaseUtils::setString(&_filename, val->getString()); + } + + _readFile = NULL; + _writeFile = NULL; + + _mode = 0; + _textMode = false; +} + + +////////////////////////////////////////////////////////////////////////// +SXFile::~SXFile() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void SXFile::cleanup() { + delete[] _filename; + _filename = NULL; + close(); +} + + +////////////////////////////////////////////////////////////////////////// +void SXFile::close() { + if (_readFile) { + BaseFileManager::getEngineInstance()->closeFile(_readFile); + _readFile = NULL; + } + if (_writeFile) { + _writeFile->finalize(); + delete _writeFile; + _writeFile = NULL; + } + _mode = 0; + _textMode = false; +} + +////////////////////////////////////////////////////////////////////////// +const char *SXFile::scToString() { + if (_filename) { + return _filename; + } else { + return "[file object]"; + } +} + +#define FILE_BUFFER_SIZE 32768 +////////////////////////////////////////////////////////////////////////// +bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetFilename + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetFilename") == 0) { + stack->correctParams(1); + const char *filename = stack->pop()->getString(); + cleanup(); + BaseUtils::setString(&_filename, filename); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // OpenAsText / OpenAsBinary + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "OpenAsText") == 0 || strcmp(name, "OpenAsBinary") == 0) { + stack->correctParams(1); + close(); + _mode = stack->pop()->getInt(1); + if (_mode < 1 || _mode > 3) { + script->runtimeError("File.%s: invalid access mode. Setting read mode.", name); + _mode = 1; + } + if (_mode == 1) { + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); + if (!_readFile) { + //script->runtimeError("File.%s: Error opening file '%s' for reading.", Name, _filename); + close(); + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } + } else { + if (strcmp(name, "OpenAsText") == 0) { + if (_mode == 2) { + _writeFile = openForWrite(_filename, false); + } else { + _writeFile = openForAppend(_filename, false); + } + } else { + if (_mode == 2) { + _writeFile = openForWrite(_filename, true); + } else { + _writeFile = openForAppend(_filename, true); + } + } + + if (!_writeFile) { + //script->runtimeError("File.%s: Error opening file '%s' for writing.", Name, _filename); + close(); + } else { + _textMode = strcmp(name, "OpenAsText") == 0; + } + } + + if (_readFile || _writeFile) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Close + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Close") == 0) { + stack->correctParams(0); + close(); + stack->pushNULL(); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPosition + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPosition") == 0) { + stack->correctParams(1); + if (_mode == 0) { + script->runtimeError("File.%s: File is not open", name); + stack->pushBool(false); + } else { + int pos = stack->pop()->getInt(); + stack->pushBool(setPos(pos)); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Delete + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Delete") == 0) { + stack->correctParams(0); + close(); + error("SXFile-Method: \"Delete\" not supported"); + //stack->pushBool(BasePlatform::deleteFile(_filename) != false); + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Copy + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Copy") == 0) { + stack->correctParams(2); + /* const char *dest = */ stack->pop()->getString(); + /* bool overwrite = */ stack->pop()->getBool(true); + + close(); + error("SXFile-Method: Copy not supported"); + //stack->pushBool(BasePlatform::copyFile(_filename, Dest, !Overwrite) != false); + stack->pushBool(false); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadLine + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadLine") == 0) { + stack->correctParams(0); + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + bool foundNewLine = false; + bool ret = STATUS_FAILED; + do { + ret = _readFile->read(&b, 1); + if (ret != 1) { + break; + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == '\n') { + buf[counter] = '\0'; + foundNewLine = true; + break; + } else if (b == 0x0D) { + continue; + } else { + buf[counter] = b; + counter++; + } + } while (DID_SUCCEED(ret)); + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (!foundNewLine && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadText") == 0) { + stack->correctParams(1); + int textLen = stack->pop()->getInt(); + + if (!_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open in text mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 bufSize = FILE_BUFFER_SIZE; + byte *buf = (byte *)malloc(bufSize); + uint32 counter = 0; + byte b; + + bool ret = STATUS_FAILED; + while (counter < (uint32)textLen) { + ret = _readFile->read(&b, 1); + if (ret != 1) { + break; + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + if (b == 0x0D) { + continue; + } else { + buf[counter] = b; + counter++; + } + } + + if (counter > bufSize) { + buf = (byte *)realloc(buf, bufSize + FILE_BUFFER_SIZE); + bufSize += FILE_BUFFER_SIZE; + } + buf[counter] = '\0'; + + if (textLen > 0 && counter == 0) { + stack->pushNULL(); + } else { + stack->pushString((char *)buf); + } + + free(buf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteLine / WriteText + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteLine") == 0 || strcmp(name, "WriteText") == 0) { + stack->correctParams(1); + const char *line = stack->pop()->getString(); + if (!_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in text mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + Common::String writeLine; + if (strcmp(name, "WriteLine") == 0) { + writeLine = Common::String::format("%s\n", line); + } else { + writeLine = Common::String::format("%s", line); + } + _writeFile->writeString(writeLine); + _writeFile->writeByte(0); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + ////////////////////////////////////////////////////////////////////////// + // ReadBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadBool") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + bool val; + if (_readFile->read(&val, sizeof(bool)) == sizeof(bool)) { + stack->pushBool(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadByte") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + byte val = _readFile->readByte(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadShort") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int16 val = _readFile->readSint16LE(); + if (!_readFile->err()) { + stack->pushInt(65536 + val); + } else { + stack->pushNULL(); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadInt / ReadLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadInt") == 0 || strcmp(name, "ReadLong") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + int32 val = _readFile->readSint32LE(); + if (!_readFile->err()) { + stack->pushInt(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadFloat") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + float val; + (*(uint32 *)&val) = _readFile->readUint32LE(); + if (!_readFile->err()) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadDouble") == 0) { // TODO: Solve reading a 8 byte double. + error("SXFile::ReadDouble - Not endian safe yet"); + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + double val; + if (_readFile->read(&val, sizeof(double)) == sizeof(double)) { + stack->pushFloat(val); + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ReadString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ReadString") == 0) { + stack->correctParams(0); + if (_textMode || !_readFile) { + script->runtimeError("File.%s: File must be open for reading in binary mode.", name); + stack->pushNULL(); + return STATUS_OK; + } + uint32 size = _readFile->readUint32LE(); + if (!_readFile->err()) { + byte *str = new byte[size + 1]; + if (str) { + if (_readFile->read(str, size) == size) { + str[size] = '\0'; + stack->pushString((char *)str); + } + delete[] str; + } else { + stack->pushNULL(); + } + } else { + stack->pushNULL(); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteBool") == 0) { + stack->correctParams(1); + bool val = stack->pop()->getBool(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteByte") == 0) { + stack->correctParams(1); + byte val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeByte(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteShort") == 0) { + stack->correctParams(1); + int16 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint16LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteInt / WriteLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteInt") == 0 || strcmp(name, "WriteLong") == 0) { + stack->correctParams(1); + int32 val = stack->pop()->getInt(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + _writeFile->writeSint32LE(val); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteFloat") == 0) { + stack->correctParams(1); + float val = stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + uint32 *ptr = (uint32 *)&val; + _writeFile->writeUint32LE(*ptr); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteDouble") == 0) { + error("SXFile::WriteDouble - Not endian safe yet"); + stack->correctParams(1); + /* double val = */ stack->pop()->getFloat(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + //fwrite(&val, sizeof(val), 1, (FILE *)_writeFile); + stack->pushBool(true); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // WriteString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "WriteString") == 0) { + stack->correctParams(1); + const char *val = stack->pop()->getString(); + + if (_textMode || !_writeFile) { + script->runtimeError("File.%s: File must be open for writing in binary mode.", name); + stack->pushBool(false); + return STATUS_OK; + } + + uint32 size = strlen(val); + _writeFile->writeUint32LE(size); + _writeFile->writeString(val); + + stack->pushBool(true); + + return STATUS_OK; + } else { + return BaseScriptable::scCallMethod(script, stack, thisStack, name); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXFile::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("file"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Filename (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Filename") == 0) { + _scValue->setString(_filename); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Position (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Position") == 0) { + _scValue->setInt(getPos()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + _scValue->setInt(getLength()); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // TextMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "TextMode") == 0) { + _scValue->setBool(_textMode); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // AccessMode (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "AccessMode") == 0) { + _scValue->setInt(_mode); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXFile::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length")==0){ + int origLength = _length; + _length = max(value->getInt(0), 0); + + char propName[20]; + if (_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return BaseScriptable::scSetProperty(name, value); +} + +////////////////////////////////////////////////////////////////////////// +uint32 SXFile::getPos() { + if (_mode == 1 && _readFile) { + return _readFile->pos(); + } else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - getPos for WriteFile not supported"); + return 0; +// return ftell((FILE *)_writeFile); + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SXFile::setPos(uint32 pos, int whence) { + if (_mode == 1 && _readFile) { + return _readFile->seek(pos, whence); + } else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - seeking in WriteFile not supported"); + return false; +// return fseek((FILE *)_writeFile, pos, (int)origin) == 0; + } else { + return false; + } +} + +////////////////////////////////////////////////////////////////////////// +uint32 SXFile::getLength() { + if (_mode == 1 && _readFile) { + return _readFile->size(); + } else if ((_mode == 2 || _mode == 3) && _writeFile) { + error("SXFile - reading length for WriteFile not supported"); + return 0; + /* + uint32 currentPos = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, 0, SEEK_END); + int ret = ftell((FILE *)_writeFile); + fseek((FILE *)_writeFile, CurrentPos, SEEK_SET); + return Ret;*/ + } else { + return 0; + } +} + +////////////////////////////////////////////////////////////////////////// +bool SXFile::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_filename)); + persistMgr->transfer(TMEMBER(_mode)); + persistMgr->transfer(TMEMBER(_textMode)); + + uint32 pos = 0; + if (persistMgr->getIsSaving()) { + pos = getPos(); + persistMgr->transfer(TMEMBER(pos)); + } else { + persistMgr->transfer(TMEMBER(pos)); + + // try to re-open file if needed + _writeFile = NULL; + _readFile = NULL; + + if (_mode != 0) { + // open for reading + if (_mode == 1) { + _readFile = BaseFileManager::getEngineInstance()->openFile(_filename); + if (!_readFile) { + close(); + } + } + // open for writing / appending + else { + if (_textMode) { + if (_mode == 2) { + _writeFile = openForWrite(_filename, false); + } else { + _writeFile = openForAppend(_filename, false); + } + } else { + if (_mode == 2) { + _writeFile = openForWrite(_filename, true); + } else { + _writeFile = openForAppend(_filename, true); + } + } + if (_writeFile) { + close(); + } + } + setPos(pos); + } + } + + return STATUS_OK; +} + +// Should replace fopen(..., "wb+") and fopen(..., "w+") +Common::WriteStream *SXFile::openForWrite(const Common::String &filename, bool binary) { + error("SXFile::openForWrite - WriteFiles not supported"); +} + +// Should replace fopen(..., "ab+") and fopen(..., "a+") +Common::WriteStream *SXFile::openForAppend(const Common::String &filename, bool binary) { + error("SXFile::openForAppend - WriteFiles not supported"); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index 389974a48e..b91a53e695 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -1,66 +1,66 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTES_SXFILE_H -#define WINTERMUTES_SXFILE_H - - -#include "engines/wintermute/base/base_scriptable.h" -#include "common/stream.h" - -namespace Wintermute { - -class BaseFile; - -class SXFile : public BaseScriptable { -public: - DECLARE_PERSISTENT(SXFile, BaseScriptable) - ScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, ScValue *value); - bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - const char *scToString(); - SXFile(BaseGame *inGame, ScStack *Stack); - virtual ~SXFile(); -private: - Common::SeekableReadStream *_readFile; - Common::WriteStream *_writeFile; - int _mode; // 0..none, 1..read, 2..write, 3..append - bool _textMode; - void close(); - void cleanup(); - uint32 getPos(); - uint32 getLength(); - bool setPos(uint32 pos, int whence = SEEK_SET); - char *_filename; - Common::WriteStream *openForWrite(const Common::String &filename, bool binary); - Common::WriteStream *openForAppend(const Common::String &filename, bool binary); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTES_SXFILE_H +#define WINTERMUTES_SXFILE_H + + +#include "engines/wintermute/base/base_scriptable.h" +#include "common/stream.h" + +namespace Wintermute { + +class BaseFile; + +class SXFile : public BaseScriptable { +public: + DECLARE_PERSISTENT(SXFile, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + const char *scToString(); + SXFile(BaseGame *inGame, ScStack *Stack); + virtual ~SXFile(); +private: + Common::SeekableReadStream *_readFile; + Common::WriteStream *_writeFile; + int _mode; // 0..none, 1..read, 2..write, 3..append + bool _textMode; + void close(); + void cleanup(); + uint32 getPos(); + uint32 getLength(); + bool setPos(uint32 pos, int whence = SEEK_SET); + char *_filename; + Common::WriteStream *openForWrite(const Common::String &filename, bool binary); + Common::WriteStream *openForAppend(const Common::String &filename, bool binary); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index f7d0ba20b9..598b80cff3 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -1,295 +1,295 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_ext_math.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/persistent.h" -#include "common/math.h" -#include - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - - -IMPLEMENT_PERSISTENT(SXMath, true) - -BaseScriptable *makeSXMath(BaseGame *inGame) { - return new SXMath(inGame); -} - -////////////////////////////////////////////////////////////////////////// -SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { - -} - - -////////////////////////////////////////////////////////////////////////// -SXMath::~SXMath() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Abs - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Abs") == 0) { - stack->correctParams(1); - stack->pushFloat(fabs(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Acos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Acos") == 0) { - stack->correctParams(1); - stack->pushFloat(acos(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Asin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Asin") == 0) { - stack->correctParams(1); - stack->pushFloat(asin(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan") == 0) { - stack->correctParams(1); - stack->pushFloat(atan(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Atan2 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Atan2") == 0) { - stack->correctParams(2); - double y = stack->pop()->getFloat(); - double x = stack->pop()->getFloat(); - stack->pushFloat(atan2(y, x)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Ceil - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ceil") == 0) { - stack->correctParams(1); - stack->pushFloat(ceil(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cos - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cos") == 0) { - stack->correctParams(1); - stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Cosh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Cosh") == 0) { - stack->correctParams(1); - stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Exp - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Exp") == 0) { - stack->correctParams(1); - stack->pushFloat(exp(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Floor - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Floor") == 0) { - stack->correctParams(1); - stack->pushFloat(floor(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log") == 0) { - stack->correctParams(1); - stack->pushFloat(log(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Log10 - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Log10") == 0) { - stack->correctParams(1); - stack->pushFloat(log10(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Pow - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Pow") == 0) { - stack->correctParams(2); - double x = stack->pop()->getFloat(); - double y = stack->pop()->getFloat(); - - stack->pushFloat(pow(x, y)); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sin - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sin") == 0) { - stack->correctParams(1); - stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sinh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sinh") == 0) { - stack->correctParams(1); - stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tan - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tan") == 0) { - stack->correctParams(1); - stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Tanh - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Tanh") == 0) { - stack->correctParams(1); - stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Sqrt - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Sqrt") == 0) { - stack->correctParams(1); - stack->pushFloat(sqrt(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DegToRad - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DegToRad") == 0) { - stack->correctParams(1); - stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // RadToDeg - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RadToDeg") == 0) { - stack->correctParams(1); - stack->pushFloat(radianToDegree(stack->pop()->getFloat())); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXMath::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("math"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // PI - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { - _scValue->setFloat(M_PI); - return _scValue; - } else { - return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -double SXMath::degreeToRadian(double value) { - return value * (M_PI / 180.0f); -} - - -////////////////////////////////////////////////////////////////////////// -double SXMath::radianToDegree(double value) { - return value * (180.0f / M_PI); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMath::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_math.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/persistent.h" +#include "common/math.h" +#include + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + + +IMPLEMENT_PERSISTENT(SXMath, true) + +BaseScriptable *makeSXMath(BaseGame *inGame) { + return new SXMath(inGame); +} + +////////////////////////////////////////////////////////////////////////// +SXMath::SXMath(BaseGame *inGame) : BaseScriptable(inGame) { + +} + + +////////////////////////////////////////////////////////////////////////// +SXMath::~SXMath() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Abs + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Abs") == 0) { + stack->correctParams(1); + stack->pushFloat(fabs(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Acos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Acos") == 0) { + stack->correctParams(1); + stack->pushFloat(acos(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Asin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Asin") == 0) { + stack->correctParams(1); + stack->pushFloat(asin(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan") == 0) { + stack->correctParams(1); + stack->pushFloat(atan(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Atan2 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Atan2") == 0) { + stack->correctParams(2); + double y = stack->pop()->getFloat(); + double x = stack->pop()->getFloat(); + stack->pushFloat(atan2(y, x)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Ceil + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Ceil") == 0) { + stack->correctParams(1); + stack->pushFloat(ceil(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cos + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cos") == 0) { + stack->correctParams(1); + stack->pushFloat(cos(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Cosh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Cosh") == 0) { + stack->correctParams(1); + stack->pushFloat(cosh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Exp + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Exp") == 0) { + stack->correctParams(1); + stack->pushFloat(exp(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Floor + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Floor") == 0) { + stack->correctParams(1); + stack->pushFloat(floor(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log") == 0) { + stack->correctParams(1); + stack->pushFloat(log(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Log10 + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Log10") == 0) { + stack->correctParams(1); + stack->pushFloat(log10(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Pow + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Pow") == 0) { + stack->correctParams(2); + double x = stack->pop()->getFloat(); + double y = stack->pop()->getFloat(); + + stack->pushFloat(pow(x, y)); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sin + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sin") == 0) { + stack->correctParams(1); + stack->pushFloat(sin(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sinh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sinh") == 0) { + stack->correctParams(1); + stack->pushFloat(sinh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tan + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tan") == 0) { + stack->correctParams(1); + stack->pushFloat(tan(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Tanh + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Tanh") == 0) { + stack->correctParams(1); + stack->pushFloat(tanh(degreeToRadian(stack->pop()->getFloat()))); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Sqrt + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Sqrt") == 0) { + stack->correctParams(1); + stack->pushFloat(sqrt(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DegToRad + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DegToRad") == 0) { + stack->correctParams(1); + stack->pushFloat(degreeToRadian(stack->pop()->getFloat())); + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // RadToDeg + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "RadToDeg") == 0) { + stack->correctParams(1); + stack->pushFloat(radianToDegree(stack->pop()->getFloat())); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXMath::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("math"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // PI + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "PI") == 0) { + _scValue->setFloat(M_PI); + return _scValue; + } else { + return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +double SXMath::degreeToRadian(double value) { + return value * (M_PI / 180.0f); +} + + +////////////////////////////////////////////////////////////////////////// +double SXMath::radianToDegree(double value) { + return value * (180.0f / M_PI); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMath::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index b195c0785d..f86d59fe7b 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -1,53 +1,53 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMATH_H -#define WINTERMUTE_SXMATH_H - - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXMath : public BaseScriptable { -public: - DECLARE_PERSISTENT(SXMath, BaseScriptable) - SXMath(BaseGame *inGame); - virtual ~SXMath(); - virtual ScValue *scGetProperty(const char *name); - virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - -private: - double degreeToRadian(double value); - double radianToDegree(double value); - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMATH_H +#define WINTERMUTE_SXMATH_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class SXMath : public BaseScriptable { +public: + DECLARE_PERSISTENT(SXMath, BaseScriptable) + SXMath(BaseGame *inGame); + virtual ~SXMath(); + virtual ScValue *scGetProperty(const char *name); + virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + +private: + double degreeToRadian(double value); + double radianToDegree(double value); + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index eef1931d8b..5ed9bd5313 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -1,529 +1,529 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_scriptable.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" -#include "common/file.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(SXMemBuffer, false) - -BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { - return new SXMemBuffer(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - stack->correctParams(1); - _buffer = NULL; - _size = 0; - - int newSize = stack->pop()->getInt(); - resize(MAX(0, newSize)); -} - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { - _size = 0; - _buffer = buffer; -} - - -////////////////////////////////////////////////////////////////////////// -SXMemBuffer::~SXMemBuffer() { - cleanup(); -} - -////////////////////////////////////////////////////////////////////////// -void *SXMemBuffer::scToMemBuffer() { - return _buffer; -} - -////////////////////////////////////////////////////////////////////////// -void SXMemBuffer::cleanup() { - if (_size) { - free(_buffer); - } - _buffer = NULL; - _size = 0; -} - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::resize(int newSize) { - int oldSize = _size; - - if (_size == 0) { - _buffer = malloc(newSize); - if (_buffer) { - _size = newSize; - } - } else { - void *newBuf = realloc(_buffer, newSize); - if (!newBuf) { - if (newSize == 0) { - _buffer = newBuf; - _size = newSize; - } else { - return STATUS_FAILED; - } - } else { - _buffer = newBuf; - _size = newSize; - } - } - - if (_buffer && _size > oldSize) { - memset((byte *)_buffer + oldSize, 0, _size - oldSize); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { - if (_buffer == NULL) { - script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); - return false; - } - if (_size == 0) { - return true; - } - - if (start < 0 || length == 0 || start + length > _size) { - script->runtimeError("Set/Get method call is out of bounds"); - return false; - } else { - return true; - } -} - -////////////////////////////////////////////////////////////////////////// -const char *SXMemBuffer::scToString() { - return "[membuffer object]"; -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // SetSize - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "SetSize") == 0) { - stack->correctParams(1); - int newSize = stack->pop()->getInt(); - newSize = MAX(0, newSize); - if (DID_SUCCEED(resize(newSize))) { - stack->pushBool(true); - } else { - stack->pushBool(false); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetBool") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(bool))) { - stack->pushNULL(); - } else { - stack->pushBool(*(bool *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetByte") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(byte))) { - stack->pushNULL(); - } else { - stack->pushInt(*(byte *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetShort") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(short))) { - stack->pushNULL(); - } else { - stack->pushInt(65536 + * (short *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetInt / GetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(int))) { - stack->pushNULL(); - } else { - stack->pushInt(*(int *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetFloat") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(float))) { - stack->pushNULL(); - } else { - stack->pushFloat(*(float *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetDouble") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(double))) { - stack->pushNULL(); - } else { - stack->pushFloat(*(double *)((byte *)_buffer + start)); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int length = stack->pop()->getInt(); - - // find end of string - if (length == 0 && start >= 0 && start < _size) { - for (int i = start; i < _size; i++) { - if (((char *)_buffer)[i] == '\0') { - length = i - start; - break; - } - } - } - - if (!checkBounds(script, start, length)) { - stack->pushNULL(); - } else { - char *str = new char[length + 1]; - Common::strlcpy(str, (const char *)_buffer + start, length + 1); - stack->pushString(str); - delete[] str; - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // GetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GetPointer") == 0) { - stack->correctParams(1); - int start = stack->pop()->getInt(); - if (!checkBounds(script, start, sizeof(void *))) { - stack->pushNULL(); - } else { - void *pointer = *(void **)((byte *)_buffer + start); - SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); - stack->pushNative(buf, false); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetBool - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetBool") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - bool val = stack->pop()->getBool(); - - if (!checkBounds(script, start, sizeof(bool))) { - stack->pushBool(false); - } else { - *(bool *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetByte - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetByte") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - byte val = (byte)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(byte))) { - stack->pushBool(false); - } else { - *(byte *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetShort - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetShort") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - short val = (short)stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(short))) { - stack->pushBool(false); - } else { - *(short *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetInt / SetLong - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int val = stack->pop()->getInt(); - - if (!checkBounds(script, start, sizeof(int))) { - stack->pushBool(false); - } else { - *(int *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetFloat - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetFloat") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - float val = (float)stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(float))) { - stack->pushBool(false); - } else { - *(float *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetDouble - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetDouble") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - double val = stack->pop()->getFloat(); - - if (!checkBounds(script, start, sizeof(double))) { - stack->pushBool(false); - } else { - *(double *)((byte *)_buffer + start) = val; - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetString - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetString") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - const char *val = stack->pop()->getString(); - - if (!checkBounds(script, start, strlen(val) + 1)) { - stack->pushBool(false); - } else { - memcpy((byte *)_buffer + start, val, strlen(val) + 1); - stack->pushBool(true); - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // SetPointer - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SetPointer") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - /* ScValue *val = */ stack->pop(); - - if (!checkBounds(script, start, sizeof(void *))) { - stack->pushBool(false); - } else { - /* - int pointer = (int)Val->getMemBuffer(); - memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); - stack->pushBool(true); - */ - // TODO fix - stack->pushBool(false); - - } - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // DEBUG_Dump - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DEBUG_Dump") == 0) { - stack->correctParams(0); - if (_buffer && _size) { - warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); - Common::DumpFile f; - f.open("buffer.bin"); - f.write(_buffer, _size); - f.close(); - } - stack->pushNULL(); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXMemBuffer::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("membuffer"); - return _scValue; - } - - ////////////////////////////////////////////////////////////////////////// - // Size (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { - _scValue->setInt(_size); - return _scValue; - } else { - return BaseScriptable::scGetProperty(name); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { - /* - ////////////////////////////////////////////////////////////////////////// - // Length - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Length")==0){ - int origLength = _length; - _length = max(value->getInt(0), 0); - - char propName[20]; - if (_length < OrigLength){ - for(int i=_length; iDeleteProp(PropName); - } - } - return STATUS_OK; - } - else*/ return BaseScriptable::scSetProperty(name, value); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_size)); - - if (persistMgr->getIsSaving()) { - if (_size > 0) { - persistMgr->putBytes((byte *)_buffer, _size); - } - } else { - if (_size > 0) { - _buffer = malloc(_size); - persistMgr->getBytes((byte *)_buffer, _size); - } else { - _buffer = NULL; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int SXMemBuffer::scCompare(BaseScriptable *val) { - if (_buffer == val->scToMemBuffer()) { - return 0; - } else { - return 1; - } -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_scriptable.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_ext_mem_buffer.h" +#include "common/file.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(SXMemBuffer, false) + +BaseScriptable *makeSXMemBuffer(BaseGame *inGame, ScStack *stack) { + return new SXMemBuffer(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::SXMemBuffer(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + stack->correctParams(1); + _buffer = NULL; + _size = 0; + + int newSize = stack->pop()->getInt(); + resize(MAX(0, newSize)); +} + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::SXMemBuffer(BaseGame *inGame, void *buffer) : BaseScriptable(inGame) { + _size = 0; + _buffer = buffer; +} + + +////////////////////////////////////////////////////////////////////////// +SXMemBuffer::~SXMemBuffer() { + cleanup(); +} + +////////////////////////////////////////////////////////////////////////// +void *SXMemBuffer::scToMemBuffer() { + return _buffer; +} + +////////////////////////////////////////////////////////////////////////// +void SXMemBuffer::cleanup() { + if (_size) { + free(_buffer); + } + _buffer = NULL; + _size = 0; +} + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::resize(int newSize) { + int oldSize = _size; + + if (_size == 0) { + _buffer = malloc(newSize); + if (_buffer) { + _size = newSize; + } + } else { + void *newBuf = realloc(_buffer, newSize); + if (!newBuf) { + if (newSize == 0) { + _buffer = newBuf; + _size = newSize; + } else { + return STATUS_FAILED; + } + } else { + _buffer = newBuf; + _size = newSize; + } + } + + if (_buffer && _size > oldSize) { + memset((byte *)_buffer + oldSize, 0, _size - oldSize); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::checkBounds(ScScript *script, int start, int length) { + if (_buffer == NULL) { + script->runtimeError("Cannot use Set/Get methods on an uninitialized memory buffer"); + return false; + } + if (_size == 0) { + return true; + } + + if (start < 0 || length == 0 || start + length > _size) { + script->runtimeError("Set/Get method call is out of bounds"); + return false; + } else { + return true; + } +} + +////////////////////////////////////////////////////////////////////////// +const char *SXMemBuffer::scToString() { + return "[membuffer object]"; +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // SetSize + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "SetSize") == 0) { + stack->correctParams(1); + int newSize = stack->pop()->getInt(); + newSize = MAX(0, newSize); + if (DID_SUCCEED(resize(newSize))) { + stack->pushBool(true); + } else { + stack->pushBool(false); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetBool") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(bool))) { + stack->pushNULL(); + } else { + stack->pushBool(*(bool *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetByte") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(byte))) { + stack->pushNULL(); + } else { + stack->pushInt(*(byte *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetShort") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(short))) { + stack->pushNULL(); + } else { + stack->pushInt(65536 + * (short *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetInt / GetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetInt") == 0 || strcmp(name, "GetLong") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(int))) { + stack->pushNULL(); + } else { + stack->pushInt(*(int *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetFloat") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(float))) { + stack->pushNULL(); + } else { + stack->pushFloat(*(float *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetDouble") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(double))) { + stack->pushNULL(); + } else { + stack->pushFloat(*(double *)((byte *)_buffer + start)); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int length = stack->pop()->getInt(); + + // find end of string + if (length == 0 && start >= 0 && start < _size) { + for (int i = start; i < _size; i++) { + if (((char *)_buffer)[i] == '\0') { + length = i - start; + break; + } + } + } + + if (!checkBounds(script, start, length)) { + stack->pushNULL(); + } else { + char *str = new char[length + 1]; + Common::strlcpy(str, (const char *)_buffer + start, length + 1); + stack->pushString(str); + delete[] str; + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // GetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "GetPointer") == 0) { + stack->correctParams(1); + int start = stack->pop()->getInt(); + if (!checkBounds(script, start, sizeof(void *))) { + stack->pushNULL(); + } else { + void *pointer = *(void **)((byte *)_buffer + start); + SXMemBuffer *buf = new SXMemBuffer(_gameRef, pointer); + stack->pushNative(buf, false); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetBool + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetBool") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + bool val = stack->pop()->getBool(); + + if (!checkBounds(script, start, sizeof(bool))) { + stack->pushBool(false); + } else { + *(bool *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetByte + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetByte") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + byte val = (byte)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(byte))) { + stack->pushBool(false); + } else { + *(byte *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetShort + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetShort") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + short val = (short)stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(short))) { + stack->pushBool(false); + } else { + *(short *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetInt / SetLong + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetInt") == 0 || strcmp(name, "SetLong") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int val = stack->pop()->getInt(); + + if (!checkBounds(script, start, sizeof(int))) { + stack->pushBool(false); + } else { + *(int *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetFloat + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetFloat") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + float val = (float)stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(float))) { + stack->pushBool(false); + } else { + *(float *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetDouble + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetDouble") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + double val = stack->pop()->getFloat(); + + if (!checkBounds(script, start, sizeof(double))) { + stack->pushBool(false); + } else { + *(double *)((byte *)_buffer + start) = val; + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetString + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetString") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + const char *val = stack->pop()->getString(); + + if (!checkBounds(script, start, strlen(val) + 1)) { + stack->pushBool(false); + } else { + memcpy((byte *)_buffer + start, val, strlen(val) + 1); + stack->pushBool(true); + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // SetPointer + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "SetPointer") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + /* ScValue *val = */ stack->pop(); + + if (!checkBounds(script, start, sizeof(void *))) { + stack->pushBool(false); + } else { + /* + int pointer = (int)Val->getMemBuffer(); + memcpy((byte *)_buffer+Start, &Pointer, sizeof(void*)); + stack->pushBool(true); + */ + // TODO fix + stack->pushBool(false); + + } + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // DEBUG_Dump + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "DEBUG_Dump") == 0) { + stack->correctParams(0); + if (_buffer && _size) { + warning("SXMemBuffer::ScCallMethod - DEBUG_Dump"); + Common::DumpFile f; + f.open("buffer.bin"); + f.write(_buffer, _size); + f.close(); + } + stack->pushNULL(); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXMemBuffer::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("membuffer"); + return _scValue; + } + + ////////////////////////////////////////////////////////////////////////// + // Size (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Size") == 0) { + _scValue->setInt(_size); + return _scValue; + } else { + return BaseScriptable::scGetProperty(name); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::scSetProperty(const char *name, ScValue *value) { + /* + ////////////////////////////////////////////////////////////////////////// + // Length + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Length")==0){ + int origLength = _length; + _length = max(value->getInt(0), 0); + + char propName[20]; + if (_length < OrigLength){ + for(int i=_length; iDeleteProp(PropName); + } + } + return STATUS_OK; + } + else*/ return BaseScriptable::scSetProperty(name, value); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXMemBuffer::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_size)); + + if (persistMgr->getIsSaving()) { + if (_size > 0) { + persistMgr->putBytes((byte *)_buffer, _size); + } + } else { + if (_size > 0) { + _buffer = malloc(_size); + persistMgr->getBytes((byte *)_buffer, _size); + } else { + _buffer = NULL; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int SXMemBuffer::scCompare(BaseScriptable *val) { + if (_buffer == val->scToMemBuffer()) { + return 0; + } else { + return 1; + } +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index 0a16167b58..d2662b3036 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -1,60 +1,60 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXMEMBUFFER_H -#define WINTERMUTE_SXMEMBUFFER_H - - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXMemBuffer : public BaseScriptable { -public: - virtual int scCompare(BaseScriptable *Val); - DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) - ScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, ScValue *value); - bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - const char *scToString(); - SXMemBuffer(BaseGame *inGame, ScStack *stack); - SXMemBuffer(BaseGame *inGame, void *buffer); - virtual ~SXMemBuffer(); - virtual void *scToMemBuffer(); -private: - int _size; - - bool resize(int newSize); - void *_buffer; - void cleanup(); - bool checkBounds(ScScript *script, int start, int length); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXMEMBUFFER_H +#define WINTERMUTE_SXMEMBUFFER_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class SXMemBuffer : public BaseScriptable { +public: + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + const char *scToString(); + SXMemBuffer(BaseGame *inGame, ScStack *stack); + SXMemBuffer(BaseGame *inGame, void *buffer); + virtual ~SXMemBuffer(); + virtual void *scToMemBuffer(); +private: + int _size; + + bool resize(int newSize); + void *_buffer; + void cleanup(); + bool checkBounds(ScScript *script, int start, int length); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_object.cpp b/engines/wintermute/base/scriptables/script_ext_object.cpp index 40c9b885cd..b87aac81f9 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.cpp +++ b/engines/wintermute/base/scriptables/script_ext_object.cpp @@ -1,67 +1,67 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_ext_object.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script_stack.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(SXObject, false) - -BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { - return new SXObject(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXObject::SXObject(BaseGame *inGame, ScStack *stack) : BaseObject(inGame) { - int numParams = stack->pop()->getInt(0); - for (int i = 0; i < numParams; i++) { - addScript(stack->pop()->getString()); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXObject::~SXObject() { - -} - - -////////////////////////////////////////////////////////////////////////// -bool SXObject::persist(BasePersistenceManager *persistMgr) { - BaseObject::persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_ext_object.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script_stack.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(SXObject, false) + +BaseScriptable *makeSXObject(BaseGame *inGame, ScStack *stack) { + return new SXObject(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXObject::SXObject(BaseGame *inGame, ScStack *stack) : BaseObject(inGame) { + int numParams = stack->pop()->getInt(0); + for (int i = 0; i < numParams; i++) { + addScript(stack->pop()->getString()); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXObject::~SXObject() { + +} + + +////////////////////////////////////////////////////////////////////////// +bool SXObject::persist(BasePersistenceManager *persistMgr) { + BaseObject::persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_object.h b/engines/wintermute/base/scriptables/script_ext_object.h index 32aa00776e..c85d16d44e 100644 --- a/engines/wintermute/base/scriptables/script_ext_object.h +++ b/engines/wintermute/base/scriptables/script_ext_object.h @@ -1,46 +1,46 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXOBJECT_H -#define WINTERMUTE_SXOBJECT_H - - -#include "engines/wintermute/base/base_object.h" - -namespace Wintermute { - -class SXObject : public BaseObject { -public: - DECLARE_PERSISTENT(SXObject, BaseObject) - SXObject(BaseGame *inGame, ScStack *Stack); - virtual ~SXObject(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXOBJECT_H +#define WINTERMUTE_SXOBJECT_H + + +#include "engines/wintermute/base/base_object.h" + +namespace Wintermute { + +class SXObject : public BaseObject { +public: + DECLARE_PERSISTENT(SXObject, BaseObject) + SXObject(BaseGame *inGame, ScStack *Stack); + virtual ~SXObject(); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 9bcfe28bbf..8d87a92dc1 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -1,436 +1,436 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/base/scriptables/script_ext_string.h" -#include "engines/wintermute/base/scriptables/script_ext_array.h" -#include "engines/wintermute/utils/string_util.h" -#include "common/tokenizer.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(SXString, false) - -BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { - return new SXString(inGame, stack); -} - -////////////////////////////////////////////////////////////////////////// -SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { - _string = NULL; - _capacity = 0; - - stack->correctParams(1); - ScValue *val = stack->pop(); - - if (val->isInt()) { - _capacity = MAX(0, val->getInt()); - if (_capacity > 0) { - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - } else { - setStringVal(val->getString()); - } - - if (_capacity == 0) { - setStringVal(""); - } -} - - -////////////////////////////////////////////////////////////////////////// -SXString::~SXString() { - if (_string) { - delete[] _string; - } -} - - -////////////////////////////////////////////////////////////////////////// -void SXString::setStringVal(const char *val) { - int len = strlen(val); - if (len >= _capacity) { - _capacity = len + 1; - delete[] _string; - _string = NULL; - _string = new char[_capacity]; - memset(_string, 0, _capacity); - } - strcpy(_string, val); -} - - -////////////////////////////////////////////////////////////////////////// -const char *SXString::scToString() { - if (_string) { - return _string; - } else { - return "[null string]"; - } -} - - -////////////////////////////////////////////////////////////////////////// -void SXString::scSetString(const char *val) { - setStringVal(val); -} - - -////////////////////////////////////////////////////////////////////////// -bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { - ////////////////////////////////////////////////////////////////////////// - // Substring - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Substring") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - int end = stack->pop()->getInt(); - - if (end < start) { - BaseUtils::swap(&start, &end); - } - - //try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - - //WideString subStr = str.substr(start, end - start + 1); - WideString subStr(str.c_str() + start, end - start + 1); - - if (_gameRef->_textEncoding == TEXT_UTF8) { - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - } else { - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); - } - // } catch (std::exception &) { - // stack->pushNULL(); - // } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Substr - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Substr") == 0) { - stack->correctParams(2); - int start = stack->pop()->getInt(); - - ScValue *val = stack->pop(); - int len = val->getInt(); - - if (!val->isNULL() && len <= 0) { - stack->pushString(""); - return STATUS_OK; - } - - if (val->isNULL()) { - len = strlen(_string) - start; - } - -// try { - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - -// WideString subStr = str.substr(start, len); - WideString subStr(str.c_str() + start, len); - - if (_gameRef->_textEncoding == TEXT_UTF8) { - stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); - } else { - stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); - } -// } catch (std::exception &) { -// stack->pushNULL(); -// } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToUpperCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToUpperCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - - str.toUppercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) { - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - } else { - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // ToLowerCase - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ToLowerCase") == 0) { - stack->correctParams(0); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - - str.toLowercase(); - - if (_gameRef->_textEncoding == TEXT_UTF8) { - stack->pushString(StringUtil::wideToUtf8(str).c_str()); - } else { - stack->pushString(StringUtil::wideToAnsi(str).c_str()); - } - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // IndexOf - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IndexOf") == 0) { - stack->correctParams(2); - - const char *strToFind = stack->pop()->getString(); - int index = stack->pop()->getInt(); - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - - WideString toFind; - if (_gameRef->_textEncoding == TEXT_UTF8) { - toFind = StringUtil::utf8ToWide(strToFind); - } else { - toFind = StringUtil::ansiToWide(strToFind); - } - - int indexOf = StringUtil::indexOf(str, toFind, index); - stack->pushInt(indexOf); - - return STATUS_OK; - } - - ////////////////////////////////////////////////////////////////////////// - // Split - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Split") == 0) { - stack->correctParams(1); - ScValue *val = stack->pop(); - char separators[MAX_PATH_LENGTH] = ","; - if (!val->isNULL()) { - strcpy(separators, val->getString()); - } - - SXArray *array = new SXArray(_gameRef); - if (!array) { - stack->pushNULL(); - return STATUS_OK; - } - - - WideString str; - if (_gameRef->_textEncoding == TEXT_UTF8) { - str = StringUtil::utf8ToWide(_string); - } else { - str = StringUtil::ansiToWide(_string); - } - - WideString delims; - if (_gameRef->_textEncoding == TEXT_UTF8) { - delims = StringUtil::utf8ToWide(separators); - } else { - delims = StringUtil::ansiToWide(separators); - } - - Common::Array parts; - - - - Common::StringTokenizer tokenizer(str, delims); - while (!tokenizer.empty()) { - Common::String str2 = tokenizer.nextToken(); - parts.push_back(str2); - } - // TODO: Clean this up - /*do { - pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); - //pos = str.find_first_of(delims, start); - if (pos == start) { - start = pos + 1; - } else if (pos == str.size()) { - parts.push_back(Common::String(str.c_str() + start)); - break; - } else { - parts.push_back(Common::String(str.c_str() + start, pos - start)); - start = pos + 1; - } - //start = str.find_first_not_of(delims, start); - start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; - - } while (pos != str.size());*/ - - for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { - WideString &part = (*it); - - if (_gameRef->_textEncoding == TEXT_UTF8) { - val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); - } else { - val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); - } - - array->push(val); - delete val; - val = NULL; - } - - stack->pushNative(array, false); - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *SXString::scGetProperty(const char *name) { - _scValue->setNULL(); - - ////////////////////////////////////////////////////////////////////////// - // Type (RO) - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { - _scValue->setString("string"); - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Length (RO) - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { - if (_gameRef->_textEncoding == TEXT_UTF8) { - WideString wstr = StringUtil::utf8ToWide(_string); - _scValue->setInt(wstr.size()); - } else { - _scValue->setInt(strlen(_string)); - } - - return _scValue; - } - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { - _scValue->setInt(_capacity); - return _scValue; - } else { - return _scValue; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXString::scSetProperty(const char *name, ScValue *value) { - ////////////////////////////////////////////////////////////////////////// - // Capacity - ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Capacity") == 0) { - int32 newCap = (uint32)value->getInt(); - if (newCap < (int32)(strlen(_string) + 1)) { - _gameRef->LOG(0, "Warning: cannot lower string capacity"); - } else if (newCap != _capacity) { - char *newStr = new char[newCap]; - if (newStr) { - memset(newStr, 0, newCap); - strcpy(newStr, _string); - delete[] _string; - _string = newStr; - _capacity = newCap; - } - } - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - - -////////////////////////////////////////////////////////////////////////// -bool SXString::persist(BasePersistenceManager *persistMgr) { - - BaseScriptable::persist(persistMgr); - - persistMgr->transfer(TMEMBER(_capacity)); - - if (persistMgr->getIsSaving()) { - if (_capacity > 0) { - persistMgr->putBytes((byte *)_string, _capacity); - } - } else { - if (_capacity > 0) { - _string = new char[_capacity]; - persistMgr->getBytes((byte *)_string, _capacity); - } else { - _string = NULL; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -int SXString::scCompare(BaseScriptable *val) { - return strcmp(_string, ((SXString *)val)->_string); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/base/scriptables/script_ext_string.h" +#include "engines/wintermute/base/scriptables/script_ext_array.h" +#include "engines/wintermute/utils/string_util.h" +#include "common/tokenizer.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(SXString, false) + +BaseScriptable *makeSXString(BaseGame *inGame, ScStack *stack) { + return new SXString(inGame, stack); +} + +////////////////////////////////////////////////////////////////////////// +SXString::SXString(BaseGame *inGame, ScStack *stack) : BaseScriptable(inGame) { + _string = NULL; + _capacity = 0; + + stack->correctParams(1); + ScValue *val = stack->pop(); + + if (val->isInt()) { + _capacity = MAX(0, val->getInt()); + if (_capacity > 0) { + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + } else { + setStringVal(val->getString()); + } + + if (_capacity == 0) { + setStringVal(""); + } +} + + +////////////////////////////////////////////////////////////////////////// +SXString::~SXString() { + if (_string) { + delete[] _string; + } +} + + +////////////////////////////////////////////////////////////////////////// +void SXString::setStringVal(const char *val) { + int len = strlen(val); + if (len >= _capacity) { + _capacity = len + 1; + delete[] _string; + _string = NULL; + _string = new char[_capacity]; + memset(_string, 0, _capacity); + } + strcpy(_string, val); +} + + +////////////////////////////////////////////////////////////////////////// +const char *SXString::scToString() { + if (_string) { + return _string; + } else { + return "[null string]"; + } +} + + +////////////////////////////////////////////////////////////////////////// +void SXString::scSetString(const char *val) { + setStringVal(val); +} + + +////////////////////////////////////////////////////////////////////////// +bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) { + ////////////////////////////////////////////////////////////////////////// + // Substring + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Substring") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + int end = stack->pop()->getInt(); + + if (end < start) { + BaseUtils::swap(&start, &end); + } + + //try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + + //WideString subStr = str.substr(start, end - start + 1); + WideString subStr(str.c_str() + start, end - start + 1); + + if (_gameRef->_textEncoding == TEXT_UTF8) { + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + } else { + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } + // } catch (std::exception &) { + // stack->pushNULL(); + // } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Substr + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Substr") == 0) { + stack->correctParams(2); + int start = stack->pop()->getInt(); + + ScValue *val = stack->pop(); + int len = val->getInt(); + + if (!val->isNULL() && len <= 0) { + stack->pushString(""); + return STATUS_OK; + } + + if (val->isNULL()) { + len = strlen(_string) - start; + } + +// try { + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + +// WideString subStr = str.substr(start, len); + WideString subStr(str.c_str() + start, len); + + if (_gameRef->_textEncoding == TEXT_UTF8) { + stack->pushString(StringUtil::wideToUtf8(subStr).c_str()); + } else { + stack->pushString(StringUtil::wideToAnsi(subStr).c_str()); + } +// } catch (std::exception &) { +// stack->pushNULL(); +// } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToUpperCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToUpperCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + + str.toUppercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) { + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + } else { + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // ToLowerCase + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "ToLowerCase") == 0) { + stack->correctParams(0); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + + str.toLowercase(); + + if (_gameRef->_textEncoding == TEXT_UTF8) { + stack->pushString(StringUtil::wideToUtf8(str).c_str()); + } else { + stack->pushString(StringUtil::wideToAnsi(str).c_str()); + } + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // IndexOf + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "IndexOf") == 0) { + stack->correctParams(2); + + const char *strToFind = stack->pop()->getString(); + int index = stack->pop()->getInt(); + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + + WideString toFind; + if (_gameRef->_textEncoding == TEXT_UTF8) { + toFind = StringUtil::utf8ToWide(strToFind); + } else { + toFind = StringUtil::ansiToWide(strToFind); + } + + int indexOf = StringUtil::indexOf(str, toFind, index); + stack->pushInt(indexOf); + + return STATUS_OK; + } + + ////////////////////////////////////////////////////////////////////////// + // Split + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Split") == 0) { + stack->correctParams(1); + ScValue *val = stack->pop(); + char separators[MAX_PATH_LENGTH] = ","; + if (!val->isNULL()) { + strcpy(separators, val->getString()); + } + + SXArray *array = new SXArray(_gameRef); + if (!array) { + stack->pushNULL(); + return STATUS_OK; + } + + + WideString str; + if (_gameRef->_textEncoding == TEXT_UTF8) { + str = StringUtil::utf8ToWide(_string); + } else { + str = StringUtil::ansiToWide(_string); + } + + WideString delims; + if (_gameRef->_textEncoding == TEXT_UTF8) { + delims = StringUtil::utf8ToWide(separators); + } else { + delims = StringUtil::ansiToWide(separators); + } + + Common::Array parts; + + + + Common::StringTokenizer tokenizer(str, delims); + while (!tokenizer.empty()) { + Common::String str2 = tokenizer.nextToken(); + parts.push_back(str2); + } + // TODO: Clean this up + /*do { + pos = StringUtil::IndexOf(Common::String(str.c_str() + start), delims, start); + //pos = str.find_first_of(delims, start); + if (pos == start) { + start = pos + 1; + } else if (pos == str.size()) { + parts.push_back(Common::String(str.c_str() + start)); + break; + } else { + parts.push_back(Common::String(str.c_str() + start, pos - start)); + start = pos + 1; + } + //start = str.find_first_not_of(delims, start); + start = StringUtil::LastIndexOf(Common::String(str.c_str() + start), delims, start) + 1; + + } while (pos != str.size());*/ + + for (Common::Array::iterator it = parts.begin(); it != parts.end(); ++it) { + WideString &part = (*it); + + if (_gameRef->_textEncoding == TEXT_UTF8) { + val = new ScValue(_gameRef, StringUtil::wideToUtf8(part).c_str()); + } else { + val = new ScValue(_gameRef, StringUtil::wideToAnsi(part).c_str()); + } + + array->push(val); + delete val; + val = NULL; + } + + stack->pushNative(array, false); + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *SXString::scGetProperty(const char *name) { + _scValue->setNULL(); + + ////////////////////////////////////////////////////////////////////////// + // Type (RO) + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Type") == 0) { + _scValue->setString("string"); + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Length (RO) + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Length") == 0) { + if (_gameRef->_textEncoding == TEXT_UTF8) { + WideString wstr = StringUtil::utf8ToWide(_string); + _scValue->setInt(wstr.size()); + } else { + _scValue->setInt(strlen(_string)); + } + + return _scValue; + } + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + else if (strcmp(name, "Capacity") == 0) { + _scValue->setInt(_capacity); + return _scValue; + } else { + return _scValue; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXString::scSetProperty(const char *name, ScValue *value) { + ////////////////////////////////////////////////////////////////////////// + // Capacity + ////////////////////////////////////////////////////////////////////////// + if (strcmp(name, "Capacity") == 0) { + int32 newCap = (uint32)value->getInt(); + if (newCap < (int32)(strlen(_string) + 1)) { + _gameRef->LOG(0, "Warning: cannot lower string capacity"); + } else if (newCap != _capacity) { + char *newStr = new char[newCap]; + if (newStr) { + memset(newStr, 0, newCap); + strcpy(newStr, _string); + delete[] _string; + _string = newStr; + _capacity = newCap; + } + } + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + + +////////////////////////////////////////////////////////////////////////// +bool SXString::persist(BasePersistenceManager *persistMgr) { + + BaseScriptable::persist(persistMgr); + + persistMgr->transfer(TMEMBER(_capacity)); + + if (persistMgr->getIsSaving()) { + if (_capacity > 0) { + persistMgr->putBytes((byte *)_string, _capacity); + } + } else { + if (_capacity > 0) { + _string = new char[_capacity]; + persistMgr->getBytes((byte *)_string, _capacity); + } else { + _string = NULL; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +int SXString::scCompare(BaseScriptable *val) { + return strcmp(_string, ((SXString *)val)->_string); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index c2de3860ed..255b9c57eb 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -1,58 +1,58 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SXSTRING_H -#define WINTERMUTE_SXSTRING_H - - -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -class SXString : public BaseScriptable { -public: - virtual int scCompare(BaseScriptable *Val); - DECLARE_PERSISTENT(SXString, BaseScriptable) - ScValue *scGetProperty(const char *name); - bool scSetProperty(const char *name, ScValue *value); - bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); - void scSetString(const char *val); - const char *scToString(); - void setStringVal(const char *val); - - SXString(BaseGame *inGame, ScStack *Stack); - virtual ~SXString(); - -private: - char *_string; - int _capacity; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SXSTRING_H +#define WINTERMUTE_SXSTRING_H + + +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +class SXString : public BaseScriptable { +public: + virtual int scCompare(BaseScriptable *Val); + DECLARE_PERSISTENT(SXString, BaseScriptable) + ScValue *scGetProperty(const char *name); + bool scSetProperty(const char *name, ScValue *value); + bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); + void scSetString(const char *val); + const char *scToString(); + void setStringVal(const char *val); + + SXString(BaseGame *inGame, ScStack *Stack); + virtual ~SXString(); + +private: + char *_string; + int _capacity; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_stack.cpp b/engines/wintermute/base/scriptables/script_stack.cpp index d27748abe6..77367045c2 100644 --- a/engines/wintermute/base/scriptables/script_stack.cpp +++ b/engines/wintermute/base/scriptables/script_stack.cpp @@ -1,232 +1,232 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/scriptables/script_stack.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/base_game.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(ScStack, false) - -////////////////////////////////////////////////////////////////////////// -ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { - _sP = -1; -} - - -////////////////////////////////////////////////////////////////////////// -ScStack::~ScStack() { - -#if _DEBUG - //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); -#endif - - for (uint32 i = 0; i < _values.size(); i++) { - delete _values[i]; - } - _values.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::pop() { - if (_sP < 0) { - _gameRef->LOG(0, "Fatal: Stack underflow"); - return NULL; - } - - return _values[_sP--]; -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::push(ScValue *val) { - _sP++; - - if (_sP < (int32)_values.size()) { - _values[_sP]->cleanup(); - _values[_sP]->copy(val); - } else { - ScValue *copyVal = new ScValue(_gameRef); - copyVal->copy(val); - _values.add(copyVal); - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getPushValue() { - _sP++; - - if (_sP >= (int32)_values.size()) { - ScValue *val = new ScValue(_gameRef); - _values.add(val); - } - _values[_sP]->cleanup(); - return _values[_sP]; -} - - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getTop() { - if (_sP < 0 || _sP >= (int32)_values.size()) { - return NULL; - } else { - return _values[_sP]; - } -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScStack::getAt(int index) { - index = _sP - index; - if (index < 0 || index >= (int32)_values.size()) { - return NULL; - } else { - return _values[index]; - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::correctParams(uint32 expectedParams) { - uint32 nuParams = (uint32)pop()->getInt(); - - if (expectedParams < nuParams) { // too many params - while (expectedParams < nuParams) { - //Pop(); - delete _values[_sP - expectedParams]; - _values.remove_at(_sP - expectedParams); - nuParams--; - _sP--; - } - } else if (expectedParams > nuParams) { // need more params - while (expectedParams > nuParams) { - //Push(null_val); - ScValue *nullVal = new ScValue(_gameRef); - nullVal->setNULL(); - _values.insert_at(_sP - nuParams + 1, nullVal); - nuParams++; - _sP++; - - if ((int32)_values.size() > _sP + 1) { - delete _values[_values.size() - 1]; - _values.remove_at(_values.size() - 1); - } - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushNULL() { - /* - ScValue* val = new ScValue(_gameRef); - val->setNULL(); - Push(val); - delete val; - */ - getPushValue()->setNULL(); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushInt(int val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setInt(Val); - Push(val); - delete val; - */ - getPushValue()->setInt(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushFloat(double val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setFloat(Val); - Push(val); - delete val; - */ - getPushValue()->setFloat(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushBool(bool val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setBool(Val); - Push(val); - delete val; - */ - getPushValue()->setBool(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushString(const char *val) { - /* - ScValue* val = new ScValue(_gameRef); - val->setString(Val); - Push(val); - delete val; - */ - getPushValue()->setString(val); -} - - -////////////////////////////////////////////////////////////////////////// -void ScStack::pushNative(BaseScriptable *val, bool persistent) { - /* - ScValue* val = new ScValue(_gameRef); - val->setNative(Val, Persistent); - Push(val); - delete val; - */ - - getPushValue()->setNative(val, persistent); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScStack::persist(BasePersistenceManager *persistMgr) { - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_sP)); - _values.persist(persistMgr); - - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/scriptables/script_stack.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/base_game.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(ScStack, false) + +////////////////////////////////////////////////////////////////////////// +ScStack::ScStack(BaseGame *inGame) : BaseClass(inGame) { + _sP = -1; +} + + +////////////////////////////////////////////////////////////////////////// +ScStack::~ScStack() { + +#if _DEBUG + //_gameRef->LOG(0, "STAT: Stack size: %d, SP=%d", _values.size(), _sP); +#endif + + for (uint32 i = 0; i < _values.size(); i++) { + delete _values[i]; + } + _values.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::pop() { + if (_sP < 0) { + _gameRef->LOG(0, "Fatal: Stack underflow"); + return NULL; + } + + return _values[_sP--]; +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::push(ScValue *val) { + _sP++; + + if (_sP < (int32)_values.size()) { + _values[_sP]->cleanup(); + _values[_sP]->copy(val); + } else { + ScValue *copyVal = new ScValue(_gameRef); + copyVal->copy(val); + _values.add(copyVal); + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getPushValue() { + _sP++; + + if (_sP >= (int32)_values.size()) { + ScValue *val = new ScValue(_gameRef); + _values.add(val); + } + _values[_sP]->cleanup(); + return _values[_sP]; +} + + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getTop() { + if (_sP < 0 || _sP >= (int32)_values.size()) { + return NULL; + } else { + return _values[_sP]; + } +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScStack::getAt(int index) { + index = _sP - index; + if (index < 0 || index >= (int32)_values.size()) { + return NULL; + } else { + return _values[index]; + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::correctParams(uint32 expectedParams) { + uint32 nuParams = (uint32)pop()->getInt(); + + if (expectedParams < nuParams) { // too many params + while (expectedParams < nuParams) { + //Pop(); + delete _values[_sP - expectedParams]; + _values.remove_at(_sP - expectedParams); + nuParams--; + _sP--; + } + } else if (expectedParams > nuParams) { // need more params + while (expectedParams > nuParams) { + //Push(null_val); + ScValue *nullVal = new ScValue(_gameRef); + nullVal->setNULL(); + _values.insert_at(_sP - nuParams + 1, nullVal); + nuParams++; + _sP++; + + if ((int32)_values.size() > _sP + 1) { + delete _values[_values.size() - 1]; + _values.remove_at(_values.size() - 1); + } + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushNULL() { + /* + ScValue* val = new ScValue(_gameRef); + val->setNULL(); + Push(val); + delete val; + */ + getPushValue()->setNULL(); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushInt(int val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setInt(Val); + Push(val); + delete val; + */ + getPushValue()->setInt(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushFloat(double val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setFloat(Val); + Push(val); + delete val; + */ + getPushValue()->setFloat(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushBool(bool val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setBool(Val); + Push(val); + delete val; + */ + getPushValue()->setBool(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushString(const char *val) { + /* + ScValue* val = new ScValue(_gameRef); + val->setString(Val); + Push(val); + delete val; + */ + getPushValue()->setString(val); +} + + +////////////////////////////////////////////////////////////////////////// +void ScStack::pushNative(BaseScriptable *val, bool persistent) { + /* + ScValue* val = new ScValue(_gameRef); + val->setNative(Val, Persistent); + Push(val); + delete val; + */ + + getPushValue()->setNative(val, persistent); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScStack::persist(BasePersistenceManager *persistMgr) { + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_sP)); + _values.persist(persistMgr); + + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_stack.h b/engines/wintermute/base/scriptables/script_stack.h index 0e2adae518..86d246cf34 100644 --- a/engines/wintermute/base/scriptables/script_stack.h +++ b/engines/wintermute/base/scriptables/script_stack.h @@ -1,66 +1,66 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCSTACK_H -#define WINTERMUTE_SCSTACK_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/persistent.h" - -namespace Wintermute { - -class ScValue; -class BaseScriptable; - -class ScStack : public BaseClass { -public: - ScValue *getAt(int Index); - ScValue *getPushValue(); - DECLARE_PERSISTENT(ScStack, BaseClass) - void pushNative(BaseScriptable *val, bool persistent); - void pushString(const char *val); - void pushBool(bool val); - void pushInt(int val); - void pushFloat(double val); - void pushNULL(); - void correctParams(uint32 expectedParams); - ScValue *getTop(); - void push(ScValue *val); - ScValue *pop(); - ScStack(BaseGame *inGame); - virtual ~ScStack(); - BaseArray _values; - int _sP; - -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCSTACK_H +#define WINTERMUTE_SCSTACK_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/persistent.h" + +namespace Wintermute { + +class ScValue; +class BaseScriptable; + +class ScStack : public BaseClass { +public: + ScValue *getAt(int Index); + ScValue *getPushValue(); + DECLARE_PERSISTENT(ScStack, BaseClass) + void pushNative(BaseScriptable *val, bool persistent); + void pushString(const char *val); + void pushBool(bool val); + void pushInt(int val); + void pushFloat(double val); + void pushNULL(); + void correctParams(uint32 expectedParams); + ScValue *getTop(); + void push(ScValue *val); + ScValue *pop(); + ScStack(BaseGame *inGame); + virtual ~ScStack(); + BaseArray _values; + int _sP; + +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/scriptables/script_value.cpp b/engines/wintermute/base/scriptables/script_value.cpp index 03ca69ac7e..0bc7ab5807 100644 --- a/engines/wintermute/base/scriptables/script_value.cpp +++ b/engines/wintermute/base/scriptables/script_value.cpp @@ -1,995 +1,995 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/platform_osystem.h" -#include "engines/wintermute/base/base_dynamic_buffer.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/scriptables/script_value.h" -#include "engines/wintermute/base/scriptables/script.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/base/base_scriptable.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -IMPLEMENT_PERSISTENT(ScValue, false) - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { - _type = VAL_BOOL; - _valBool = val; - - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { - _type = VAL_INT; - _valInt = val; - - _valFloat = 0.0f; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { - _type = VAL_FLOAT; - _valFloat = val; - - _valInt = 0; - _valBool = false; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { - _type = VAL_STRING; - _valString = NULL; - setStringVal(val); - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::cleanup(bool ignoreNatives) { - deleteProps(); - - if (_valString) { - delete[] _valString; - } - - if (!ignoreNatives) { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - _valNative = NULL; - } - } - } - - - _type = VAL_NULL; - - _valBool = false; - _valInt = 0; - _valFloat = 0.0f; - _valNative = NULL; - _valString = NULL; - _valRef = NULL; - _persistent = false; - _isConstVar = false; -} - - - -////////////////////////////////////////////////////////////////////////// -ScValue::~ScValue() { - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -ScValue *ScValue::getProp(const char *name) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getProp(name); - } - - if (_type == VAL_STRING && strcmp(name, "Length") == 0) { - _gameRef->_scValue->_type = VAL_INT; - - if (_gameRef->_textEncoding == TEXT_ANSI) { - _gameRef->_scValue->setInt(strlen(_valString)); - } else { - WideString wstr = StringUtil::utf8ToWide(_valString); - _gameRef->_scValue->setInt(wstr.size()); - } - - return _gameRef->_scValue; - } - - ScValue *ret = NULL; - - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scGetProperty(name); - } - - if (ret == NULL) { - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - ret = _valIter->_value; - } - } - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::deleteProp(const char *name) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->deleteProp(name); - } - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - delete _valIter->_value; - _valIter->_value = NULL; - } - - return STATUS_OK; -} - - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->setProp(name, val); - } - - bool ret = STATUS_FAILED; - if (_type == VAL_NATIVE && _valNative) { - ret = _valNative->scSetProperty(name, val); - } - - if (DID_FAIL(ret)) { - ScValue *newVal = NULL; - - _valIter = _valObject.find(name); - if (_valIter != _valObject.end()) { - newVal = _valIter->_value; - } - if (!newVal) { - newVal = new ScValue(_gameRef); - } else { - newVal->cleanup(); - } - - newVal->copy(val, copyWhole); - newVal->_isConstVar = setAsConst; - _valObject[name] = newVal; - - if (_type != VAL_NATIVE) { - _type = VAL_OBJECT; - } - - /* - _valIter = _valObject.find(Name); - if (_valIter != _valObject.end()){ - delete _valIter->_value; - _valIter->_value = NULL; - } - ScValue* val = new ScValue(_gameRef); - val->Copy(Val, CopyWhole); - val->_isConstVar = SetAsConst; - _valObject[Name] = val; - - if (_type!=VAL_NATIVE) _type = VAL_OBJECT; - */ - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::propExists(const char *name) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->propExists(name); - } - _valIter = _valObject.find(name); - - return (_valIter != _valObject.end()); -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::deleteProps() { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - delete(ScValue *)_valIter->_value; - _valIter++; - } - _valObject.clear(); -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::CleanProps(bool includingNatives) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { - _valIter->_value->setNULL(); - } - _valIter++; - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isNULL() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isNULL(); - } - - return (_type == VAL_NULL); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isNative() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isNative(); - } - - return (_type == VAL_NATIVE); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isString() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isString(); - } - - return (_type == VAL_STRING); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isFloat() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isFloat(); - } - - return (_type == VAL_FLOAT); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isInt() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isInt(); - } - - return (_type == VAL_INT); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isBool() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isBool(); - } - - return (_type == VAL_BOOL); -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::isObject() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->isObject(); - } - - return (_type == VAL_OBJECT); -} - - -////////////////////////////////////////////////////////////////////////// -TValType ScValue::getTypeTolerant() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getType(); - } - - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setBool(bool val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setBool(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetBool(val); - return; - } - - _valBool = val; - _type = VAL_BOOL; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setInt(int val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setInt(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetInt(val); - return; - } - - _valInt = val; - _type = VAL_INT; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setFloat(double val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setFloat(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetFloat(val); - return; - } - - _valFloat = val; - _type = VAL_FLOAT; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setString(const char *val) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setString(val); - return; - } - - if (_type == VAL_NATIVE) { - _valNative->scSetString(val); - return; - } - - setStringVal(val); - if (_valString) { - _type = VAL_STRING; - } else { - _type = VAL_NULL; - } -} - -void ScValue::setString(const Common::String &val) { - setString(val.c_str()); -} - -////////////////////////////////////////////////////////////////////////// -void ScValue::setStringVal(const char *val) { - if (_valString) { - delete[] _valString; - _valString = NULL; - } - - if (val == NULL) { - _valString = NULL; - return; - } - - _valString = new char [strlen(val) + 1]; - if (_valString) { - strcpy(_valString, val); - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setNULL() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNULL(); - return; - } - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - delete _valNative; - } - } - _valNative = NULL; - deleteProps(); - - _type = VAL_NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setNative(BaseScriptable *val, bool persistent) { - if (_type == VAL_VARIABLE_REF) { - _valRef->setNative(val, persistent); - return; - } - - if (val == NULL) { - setNULL(); - } else { - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != val) { - delete _valNative; - } - _valNative = NULL; - } - } - - _type = VAL_NATIVE; - _persistent = persistent; - - _valNative = val; - if (_valNative && !_persistent) { - _valNative->_refCount++; - } - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setObject() { - if (_type == VAL_VARIABLE_REF) { - _valRef->setObject(); - return; - } - - deleteProps(); - _type = VAL_OBJECT; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setReference(ScValue *val) { - _valRef = val; - _type = VAL_VARIABLE_REF; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::getBool(bool defaultVal) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getBool(); - } - - switch (_type) { - case VAL_BOOL: - return _valBool; - - case VAL_NATIVE: - return _valNative->scToBool(); - - case VAL_INT: - return (_valInt != 0); - - case VAL_FLOAT: - return (_valFloat != 0.0f); - - case VAL_STRING: - return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -int ScValue::getInt(int defaultVal) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getInt(); - } - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1 : 0; - - case VAL_NATIVE: - return _valNative->scToInt(); - - case VAL_INT: - return _valInt; - - case VAL_FLOAT: - return (int)_valFloat; - - case VAL_STRING: - return atoi(_valString); - - default: - return defaultVal; - } -} - - -////////////////////////////////////////////////////////////////////////// -double ScValue::getFloat(double defaultVal) { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getFloat(); - } - - switch (_type) { - case VAL_BOOL: - return _valBool ? 1.0f : 0.0f; - - case VAL_NATIVE: - return _valNative->scToFloat(); - - case VAL_INT: - return (double)_valInt; - - case VAL_FLOAT: - return _valFloat; - - case VAL_STRING: - return atof(_valString); - - default: - return defaultVal; - } -} - -////////////////////////////////////////////////////////////////////////// -void *ScValue::getMemBuffer() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getMemBuffer(); - } - - if (_type == VAL_NATIVE) { - return _valNative->scToMemBuffer(); - } else { - return (void *)NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -const char *ScValue::getString() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getString(); - } - - switch (_type) { - case VAL_OBJECT: - setStringVal("[object]"); - break; - - case VAL_NULL: - setStringVal("[null]"); - break; - - case VAL_NATIVE: { - const char *strVal = _valNative->scToString(); - setStringVal(strVal); - return strVal; - break; - } - - case VAL_BOOL: - setStringVal(_valBool ? "yes" : "no"); - break; - - case VAL_INT: { - char dummy[50]; - sprintf(dummy, "%d", _valInt); - setStringVal(dummy); - break; - } - - case VAL_FLOAT: { - char dummy[50]; - sprintf(dummy, "%f", _valFloat); - setStringVal(dummy); - break; - } - - case VAL_STRING: - break; - - default: - setStringVal(""); - } - - return _valString; -} - - -////////////////////////////////////////////////////////////////////////// -BaseScriptable *ScValue::getNative() { - if (_type == VAL_VARIABLE_REF) { - return _valRef->getNative(); - } - - if (_type == VAL_NATIVE) { - return _valNative; - } else { - return NULL; - } -} - - -////////////////////////////////////////////////////////////////////////// -TValType ScValue::getType() { - return _type; -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::copy(ScValue *orig, bool copyWhole) { - _gameRef = orig->_gameRef; - - if (_valNative && !_persistent) { - _valNative->_refCount--; - if (_valNative->_refCount <= 0) { - if (_valNative != orig->_valNative) { - delete _valNative; - } - _valNative = NULL; - } - } - - if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) { - orig = orig->_valRef; - } - - cleanup(true); - - _type = orig->_type; - _valBool = orig->_valBool; - _valInt = orig->_valInt; - _valFloat = orig->_valFloat; - setStringVal(orig->_valString); - - _valRef = orig->_valRef; - _persistent = orig->_persistent; - - _valNative = orig->_valNative; - if (_valNative && !_persistent) { - _valNative->_refCount++; - } -//!!!! ref->native++ - - // copy properties - if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { - orig->_valIter = orig->_valObject.begin(); - while (orig->_valIter != orig->_valObject.end()) { - _valObject[orig->_valIter->_key] = new ScValue(_gameRef); - _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); - orig->_valIter++; - } - } else { - _valObject.clear(); - } -} - - -////////////////////////////////////////////////////////////////////////// -void ScValue::setValue(ScValue *val) { - if (val->_type == VAL_VARIABLE_REF) { - setValue(val->_valRef); - return; - } - - // if being assigned a simple type, preserve native state - if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { - switch (val->_type) { - case VAL_INT: - _valNative->scSetInt(val->getInt()); - break; - case VAL_FLOAT: - _valNative->scSetFloat(val->getFloat()); - break; - case VAL_BOOL: - _valNative->scSetBool(val->getBool()); - break; - case VAL_STRING: - _valNative->scSetString(val->getString()); - break; - default: - warning("ScValue::setValue - unhandled enum"); - break; - } - } - // otherwise just copy everything - else { - copy(val); - } -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::persist(BasePersistenceManager *persistMgr) { - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_persistent)); - persistMgr->transfer(TMEMBER(_isConstVar)); - persistMgr->transfer(TMEMBER_INT(_type)); - persistMgr->transfer(TMEMBER(_valBool)); - persistMgr->transfer(TMEMBER(_valFloat)); - persistMgr->transfer(TMEMBER(_valInt)); - persistMgr->transfer(TMEMBER(_valNative)); - - int size; - const char *str; - if (persistMgr->getIsSaving()) { - size = _valObject.size(); - persistMgr->transfer("", &size); - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - str = _valIter->_key.c_str(); - persistMgr->transfer("", &str); - persistMgr->transfer("", &_valIter->_value); - - _valIter++; - } - } else { - ScValue *val; - persistMgr->transfer("", &size); - for (int i = 0; i < size; i++) { - persistMgr->transfer("", &str); - persistMgr->transfer("", &val); - - _valObject[str] = val; - delete[] str; - } - } - - persistMgr->transfer(TMEMBER(_valRef)); - persistMgr->transfer(TMEMBER(_valString)); - - /* - FILE* f = fopen("c:\\val.log", "a+"); - switch(_type) - { - case VAL_STRING: - fprintf(f, "str %s\n", _valString); - break; - - case VAL_INT: - fprintf(f, "int %d\n", _valInt); - break; - - case VAL_BOOL: - fprintf(f, "bool %d\n", _valBool); - break; - - case VAL_NULL: - fprintf(f, "null\n"); - break; - - case VAL_NATIVE: - fprintf(f, "native\n"); - break; - - case VAL_VARIABLE_REF: - fprintf(f, "ref\n"); - break; - - case VAL_OBJECT: - fprintf(f, "obj\n"); - break; - - case VAL_FLOAT: - fprintf(f, "float\n"); - break; - - } - fclose(f); - */ - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::saveAsText(BaseDynamicBuffer *buffer, int indent) { - _valIter = _valObject.begin(); - while (_valIter != _valObject.end()) { - buffer->putTextIndent(indent, "PROPERTY {\n"); - buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); - buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); - buffer->putTextIndent(indent, "}\n\n"); - - _valIter++; - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -// -1 ... left is less, 0 ... equals, 1 ... left is greater -int ScValue::compare(ScValue *val1, ScValue *val2) { - // both natives? - if (val1->isNative() && val2->isNative()) { - // same class? - if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { - return val1->getNative()->scCompare(val2->getNative()); - } else { - return strcmp(val1->getString(), val2->getString()); - } - } - - // both objects? - if (val1->isObject() && val2->isObject()) { - return -1; - } - - - // null states - if (val1->isNULL() && !val2->isNULL()) { - return -1; - } else if (!val1->isNULL() && val2->isNULL()) { - return 1; - } else if (val1->isNULL() && val2->isNULL()) { - return 0; - } - - // one of them is string? convert both to string - if (val1->isString() || val2->isString()) { - return strcmp(val1->getString(), val2->getString()); - } - - // one of them is float? - if (val1->isFloat() || val2->isFloat()) { - if (val1->getFloat() < val2->getFloat()) { - return -1; - } else if (val1->getFloat() > val2->getFloat()) { - return 1; - } else { - return 0; - } - } - - // otherwise compare as int's - if (val1->getInt() < val2->getInt()) { - return -1; - } else if (val1->getInt() > val2->getInt()) { - return 1; - } else { - return 0; - } -} - - -////////////////////////////////////////////////////////////////////////// -int ScValue::compareStrict(ScValue *val1, ScValue *val2) { - if (val1->getTypeTolerant() != val2->getTypeTolerant()) { - return -1; - } else { - return ScValue::compare(val1, val2); - } -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName, int value) { - ScValue *val = new ScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName, const char *value) { - ScValue *val = new ScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName, double value) { - ScValue *val = new ScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName, bool value) { - ScValue *val = new ScValue(_gameRef, value); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - - -////////////////////////////////////////////////////////////////////////// -bool ScValue::setProperty(const char *propName) { - ScValue *val = new ScValue(_gameRef); - bool ret = DID_SUCCEED(setProp(propName, val)); - delete val; - return ret; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/base_dynamic_buffer.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/scriptables/script_value.h" +#include "engines/wintermute/base/scriptables/script.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_scriptable.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +IMPLEMENT_PERSISTENT(ScValue, false) + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame) : BaseClass(inGame) { + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, bool val) : BaseClass(inGame) { + _type = VAL_BOOL; + _valBool = val; + + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, int val) : BaseClass(inGame) { + _type = VAL_INT; + _valInt = val; + + _valFloat = 0.0f; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, double val) : BaseClass(inGame) { + _type = VAL_FLOAT; + _valFloat = val; + + _valInt = 0; + _valBool = false; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +ScValue::ScValue(BaseGame *inGame, const char *val) : BaseClass(inGame) { + _type = VAL_STRING; + _valString = NULL; + setStringVal(val); + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::cleanup(bool ignoreNatives) { + deleteProps(); + + if (_valString) { + delete[] _valString; + } + + if (!ignoreNatives) { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + _valNative = NULL; + } + } + } + + + _type = VAL_NULL; + + _valBool = false; + _valInt = 0; + _valFloat = 0.0f; + _valNative = NULL; + _valString = NULL; + _valRef = NULL; + _persistent = false; + _isConstVar = false; +} + + + +////////////////////////////////////////////////////////////////////////// +ScValue::~ScValue() { + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +ScValue *ScValue::getProp(const char *name) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getProp(name); + } + + if (_type == VAL_STRING && strcmp(name, "Length") == 0) { + _gameRef->_scValue->_type = VAL_INT; + + if (_gameRef->_textEncoding == TEXT_ANSI) { + _gameRef->_scValue->setInt(strlen(_valString)); + } else { + WideString wstr = StringUtil::utf8ToWide(_valString); + _gameRef->_scValue->setInt(wstr.size()); + } + + return _gameRef->_scValue; + } + + ScValue *ret = NULL; + + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scGetProperty(name); + } + + if (ret == NULL) { + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + ret = _valIter->_value; + } + } + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::deleteProp(const char *name) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->deleteProp(name); + } + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + delete _valIter->_value; + _valIter->_value = NULL; + } + + return STATUS_OK; +} + + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProp(const char *name, ScValue *val, bool copyWhole, bool setAsConst) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->setProp(name, val); + } + + bool ret = STATUS_FAILED; + if (_type == VAL_NATIVE && _valNative) { + ret = _valNative->scSetProperty(name, val); + } + + if (DID_FAIL(ret)) { + ScValue *newVal = NULL; + + _valIter = _valObject.find(name); + if (_valIter != _valObject.end()) { + newVal = _valIter->_value; + } + if (!newVal) { + newVal = new ScValue(_gameRef); + } else { + newVal->cleanup(); + } + + newVal->copy(val, copyWhole); + newVal->_isConstVar = setAsConst; + _valObject[name] = newVal; + + if (_type != VAL_NATIVE) { + _type = VAL_OBJECT; + } + + /* + _valIter = _valObject.find(Name); + if (_valIter != _valObject.end()){ + delete _valIter->_value; + _valIter->_value = NULL; + } + ScValue* val = new ScValue(_gameRef); + val->Copy(Val, CopyWhole); + val->_isConstVar = SetAsConst; + _valObject[Name] = val; + + if (_type!=VAL_NATIVE) _type = VAL_OBJECT; + */ + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::propExists(const char *name) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->propExists(name); + } + _valIter = _valObject.find(name); + + return (_valIter != _valObject.end()); +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::deleteProps() { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + delete(ScValue *)_valIter->_value; + _valIter++; + } + _valObject.clear(); +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::CleanProps(bool includingNatives) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + if (!_valIter->_value->_isConstVar && (!_valIter->_value->isNative() || includingNatives)) { + _valIter->_value->setNULL(); + } + _valIter++; + } +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isNULL() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isNULL(); + } + + return (_type == VAL_NULL); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isNative() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isNative(); + } + + return (_type == VAL_NATIVE); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isString() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isString(); + } + + return (_type == VAL_STRING); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isFloat() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isFloat(); + } + + return (_type == VAL_FLOAT); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isInt() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isInt(); + } + + return (_type == VAL_INT); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isBool() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isBool(); + } + + return (_type == VAL_BOOL); +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::isObject() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->isObject(); + } + + return (_type == VAL_OBJECT); +} + + +////////////////////////////////////////////////////////////////////////// +TValType ScValue::getTypeTolerant() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getType(); + } + + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setBool(bool val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setBool(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetBool(val); + return; + } + + _valBool = val; + _type = VAL_BOOL; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setInt(int val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setInt(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetInt(val); + return; + } + + _valInt = val; + _type = VAL_INT; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setFloat(double val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setFloat(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetFloat(val); + return; + } + + _valFloat = val; + _type = VAL_FLOAT; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setString(const char *val) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setString(val); + return; + } + + if (_type == VAL_NATIVE) { + _valNative->scSetString(val); + return; + } + + setStringVal(val); + if (_valString) { + _type = VAL_STRING; + } else { + _type = VAL_NULL; + } +} + +void ScValue::setString(const Common::String &val) { + setString(val.c_str()); +} + +////////////////////////////////////////////////////////////////////////// +void ScValue::setStringVal(const char *val) { + if (_valString) { + delete[] _valString; + _valString = NULL; + } + + if (val == NULL) { + _valString = NULL; + return; + } + + _valString = new char [strlen(val) + 1]; + if (_valString) { + strcpy(_valString, val); + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setNULL() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNULL(); + return; + } + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + delete _valNative; + } + } + _valNative = NULL; + deleteProps(); + + _type = VAL_NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setNative(BaseScriptable *val, bool persistent) { + if (_type == VAL_VARIABLE_REF) { + _valRef->setNative(val, persistent); + return; + } + + if (val == NULL) { + setNULL(); + } else { + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != val) { + delete _valNative; + } + _valNative = NULL; + } + } + + _type = VAL_NATIVE; + _persistent = persistent; + + _valNative = val; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setObject() { + if (_type == VAL_VARIABLE_REF) { + _valRef->setObject(); + return; + } + + deleteProps(); + _type = VAL_OBJECT; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setReference(ScValue *val) { + _valRef = val; + _type = VAL_VARIABLE_REF; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::getBool(bool defaultVal) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getBool(); + } + + switch (_type) { + case VAL_BOOL: + return _valBool; + + case VAL_NATIVE: + return _valNative->scToBool(); + + case VAL_INT: + return (_valInt != 0); + + case VAL_FLOAT: + return (_valFloat != 0.0f); + + case VAL_STRING: + return (scumm_stricmp(_valString, "1") == 0 || scumm_stricmp(_valString, "yes") == 0 || scumm_stricmp(_valString, "true") == 0); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +int ScValue::getInt(int defaultVal) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getInt(); + } + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1 : 0; + + case VAL_NATIVE: + return _valNative->scToInt(); + + case VAL_INT: + return _valInt; + + case VAL_FLOAT: + return (int)_valFloat; + + case VAL_STRING: + return atoi(_valString); + + default: + return defaultVal; + } +} + + +////////////////////////////////////////////////////////////////////////// +double ScValue::getFloat(double defaultVal) { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getFloat(); + } + + switch (_type) { + case VAL_BOOL: + return _valBool ? 1.0f : 0.0f; + + case VAL_NATIVE: + return _valNative->scToFloat(); + + case VAL_INT: + return (double)_valInt; + + case VAL_FLOAT: + return _valFloat; + + case VAL_STRING: + return atof(_valString); + + default: + return defaultVal; + } +} + +////////////////////////////////////////////////////////////////////////// +void *ScValue::getMemBuffer() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getMemBuffer(); + } + + if (_type == VAL_NATIVE) { + return _valNative->scToMemBuffer(); + } else { + return (void *)NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +const char *ScValue::getString() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getString(); + } + + switch (_type) { + case VAL_OBJECT: + setStringVal("[object]"); + break; + + case VAL_NULL: + setStringVal("[null]"); + break; + + case VAL_NATIVE: { + const char *strVal = _valNative->scToString(); + setStringVal(strVal); + return strVal; + break; + } + + case VAL_BOOL: + setStringVal(_valBool ? "yes" : "no"); + break; + + case VAL_INT: { + char dummy[50]; + sprintf(dummy, "%d", _valInt); + setStringVal(dummy); + break; + } + + case VAL_FLOAT: { + char dummy[50]; + sprintf(dummy, "%f", _valFloat); + setStringVal(dummy); + break; + } + + case VAL_STRING: + break; + + default: + setStringVal(""); + } + + return _valString; +} + + +////////////////////////////////////////////////////////////////////////// +BaseScriptable *ScValue::getNative() { + if (_type == VAL_VARIABLE_REF) { + return _valRef->getNative(); + } + + if (_type == VAL_NATIVE) { + return _valNative; + } else { + return NULL; + } +} + + +////////////////////////////////////////////////////////////////////////// +TValType ScValue::getType() { + return _type; +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::copy(ScValue *orig, bool copyWhole) { + _gameRef = orig->_gameRef; + + if (_valNative && !_persistent) { + _valNative->_refCount--; + if (_valNative->_refCount <= 0) { + if (_valNative != orig->_valNative) { + delete _valNative; + } + _valNative = NULL; + } + } + + if (orig->_type == VAL_VARIABLE_REF && orig->_valRef && copyWhole) { + orig = orig->_valRef; + } + + cleanup(true); + + _type = orig->_type; + _valBool = orig->_valBool; + _valInt = orig->_valInt; + _valFloat = orig->_valFloat; + setStringVal(orig->_valString); + + _valRef = orig->_valRef; + _persistent = orig->_persistent; + + _valNative = orig->_valNative; + if (_valNative && !_persistent) { + _valNative->_refCount++; + } +//!!!! ref->native++ + + // copy properties + if (orig->_type == VAL_OBJECT && orig->_valObject.size() > 0) { + orig->_valIter = orig->_valObject.begin(); + while (orig->_valIter != orig->_valObject.end()) { + _valObject[orig->_valIter->_key] = new ScValue(_gameRef); + _valObject[orig->_valIter->_key]->copy(orig->_valIter->_value); + orig->_valIter++; + } + } else { + _valObject.clear(); + } +} + + +////////////////////////////////////////////////////////////////////////// +void ScValue::setValue(ScValue *val) { + if (val->_type == VAL_VARIABLE_REF) { + setValue(val->_valRef); + return; + } + + // if being assigned a simple type, preserve native state + if (_type == VAL_NATIVE && (val->_type == VAL_INT || val->_type == VAL_STRING || val->_type == VAL_BOOL)) { + switch (val->_type) { + case VAL_INT: + _valNative->scSetInt(val->getInt()); + break; + case VAL_FLOAT: + _valNative->scSetFloat(val->getFloat()); + break; + case VAL_BOOL: + _valNative->scSetBool(val->getBool()); + break; + case VAL_STRING: + _valNative->scSetString(val->getString()); + break; + default: + warning("ScValue::setValue - unhandled enum"); + break; + } + } + // otherwise just copy everything + else { + copy(val); + } +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::persist(BasePersistenceManager *persistMgr) { + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_persistent)); + persistMgr->transfer(TMEMBER(_isConstVar)); + persistMgr->transfer(TMEMBER_INT(_type)); + persistMgr->transfer(TMEMBER(_valBool)); + persistMgr->transfer(TMEMBER(_valFloat)); + persistMgr->transfer(TMEMBER(_valInt)); + persistMgr->transfer(TMEMBER(_valNative)); + + int size; + const char *str; + if (persistMgr->getIsSaving()) { + size = _valObject.size(); + persistMgr->transfer("", &size); + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + str = _valIter->_key.c_str(); + persistMgr->transfer("", &str); + persistMgr->transfer("", &_valIter->_value); + + _valIter++; + } + } else { + ScValue *val; + persistMgr->transfer("", &size); + for (int i = 0; i < size; i++) { + persistMgr->transfer("", &str); + persistMgr->transfer("", &val); + + _valObject[str] = val; + delete[] str; + } + } + + persistMgr->transfer(TMEMBER(_valRef)); + persistMgr->transfer(TMEMBER(_valString)); + + /* + FILE* f = fopen("c:\\val.log", "a+"); + switch(_type) + { + case VAL_STRING: + fprintf(f, "str %s\n", _valString); + break; + + case VAL_INT: + fprintf(f, "int %d\n", _valInt); + break; + + case VAL_BOOL: + fprintf(f, "bool %d\n", _valBool); + break; + + case VAL_NULL: + fprintf(f, "null\n"); + break; + + case VAL_NATIVE: + fprintf(f, "native\n"); + break; + + case VAL_VARIABLE_REF: + fprintf(f, "ref\n"); + break; + + case VAL_OBJECT: + fprintf(f, "obj\n"); + break; + + case VAL_FLOAT: + fprintf(f, "float\n"); + break; + + } + fclose(f); + */ + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::saveAsText(BaseDynamicBuffer *buffer, int indent) { + _valIter = _valObject.begin(); + while (_valIter != _valObject.end()) { + buffer->putTextIndent(indent, "PROPERTY {\n"); + buffer->putTextIndent(indent + 2, "NAME=\"%s\"\n", _valIter->_key.c_str()); + buffer->putTextIndent(indent + 2, "VALUE=\"%s\"\n", _valIter->_value->getString()); + buffer->putTextIndent(indent, "}\n\n"); + + _valIter++; + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +// -1 ... left is less, 0 ... equals, 1 ... left is greater +int ScValue::compare(ScValue *val1, ScValue *val2) { + // both natives? + if (val1->isNative() && val2->isNative()) { + // same class? + if (strcmp(val1->getNative()->getClassName(), val2->getNative()->getClassName()) == 0) { + return val1->getNative()->scCompare(val2->getNative()); + } else { + return strcmp(val1->getString(), val2->getString()); + } + } + + // both objects? + if (val1->isObject() && val2->isObject()) { + return -1; + } + + + // null states + if (val1->isNULL() && !val2->isNULL()) { + return -1; + } else if (!val1->isNULL() && val2->isNULL()) { + return 1; + } else if (val1->isNULL() && val2->isNULL()) { + return 0; + } + + // one of them is string? convert both to string + if (val1->isString() || val2->isString()) { + return strcmp(val1->getString(), val2->getString()); + } + + // one of them is float? + if (val1->isFloat() || val2->isFloat()) { + if (val1->getFloat() < val2->getFloat()) { + return -1; + } else if (val1->getFloat() > val2->getFloat()) { + return 1; + } else { + return 0; + } + } + + // otherwise compare as int's + if (val1->getInt() < val2->getInt()) { + return -1; + } else if (val1->getInt() > val2->getInt()) { + return 1; + } else { + return 0; + } +} + + +////////////////////////////////////////////////////////////////////////// +int ScValue::compareStrict(ScValue *val1, ScValue *val2) { + if (val1->getTypeTolerant() != val2->getTypeTolerant()) { + return -1; + } else { + return ScValue::compare(val1, val2); + } +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName, int value) { + ScValue *val = new ScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName, const char *value) { + ScValue *val = new ScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName, double value) { + ScValue *val = new ScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName, bool value) { + ScValue *val = new ScValue(_gameRef, value); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + + +////////////////////////////////////////////////////////////////////////// +bool ScValue::setProperty(const char *propName) { + ScValue *val = new ScValue(_gameRef); + bool ret = DID_SUCCEED(setProp(propName, val)); + delete val; + return ret; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/scriptables/script_value.h b/engines/wintermute/base/scriptables/script_value.h index af31014bac..bf7d9cd8a1 100644 --- a/engines/wintermute/base/scriptables/script_value.h +++ b/engines/wintermute/base/scriptables/script_value.h @@ -1,113 +1,113 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_SCVALUE_H -#define WINTERMUTE_SCVALUE_H - - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/persistent.h" -#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView -#include "common/str.h" - -namespace Wintermute { - -class ScScript; -class BaseScriptable; - -class ScValue : public BaseClass { -public: - static int compare(ScValue *val1, ScValue *val2); - static int compareStrict(ScValue *val1, ScValue *val2); - TValType getTypeTolerant(); - void cleanup(bool ignoreNatives = false); - DECLARE_PERSISTENT(ScValue, BaseClass) - - bool _isConstVar; - bool saveAsText(BaseDynamicBuffer *buffer, int indent); - void setValue(ScValue *val); - bool _persistent; - bool propExists(const char *name); - void copy(ScValue *orig, bool copyWhole = false); - void setStringVal(const char *val); - TValType getType(); - bool getBool(bool defaultVal = false); - int getInt(int defaultVal = 0); - double getFloat(double defaultVal = 0.0f); - const char *getString(); - void *getMemBuffer(); - BaseScriptable *getNative(); - bool deleteProp(const char *name); - void deleteProps(); - void CleanProps(bool includingNatives); - void setBool(bool val); - void setInt(int val); - void setFloat(double val); - void setString(const char *val); - void setString(const Common::String &val); - void setNULL(); - void setNative(BaseScriptable *val, bool persistent = false); - void setObject(); - void setReference(ScValue *val); - bool isNULL(); - bool isNative(); - bool isString(); - bool isBool(); - bool isFloat(); - bool isInt(); - bool isObject(); - bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); - ScValue *getProp(const char *name); - BaseScriptable *_valNative; - ScValue *_valRef; -private: - bool _valBool; - int _valInt; - double _valFloat; - char *_valString; -public: - TValType _type; - ScValue(BaseGame *inGame); - ScValue(BaseGame *inGame, bool Val); - ScValue(BaseGame *inGame, int Val); - ScValue(BaseGame *inGame, double Val); - ScValue(BaseGame *inGame, const char *Val); - virtual ~ScValue(); - Common::HashMap _valObject; - Common::HashMap::iterator _valIter; - - bool setProperty(const char *propName, int value); - bool setProperty(const char *propName, const char *value); - bool setProperty(const char *propName, double value); - bool setProperty(const char *propName, bool value); - bool setProperty(const char *propName); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_SCVALUE_H +#define WINTERMUTE_SCVALUE_H + + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/persistent.h" +#include "engines/wintermute/base/scriptables/dcscript.h" // Added by ClassView +#include "common/str.h" + +namespace Wintermute { + +class ScScript; +class BaseScriptable; + +class ScValue : public BaseClass { +public: + static int compare(ScValue *val1, ScValue *val2); + static int compareStrict(ScValue *val1, ScValue *val2); + TValType getTypeTolerant(); + void cleanup(bool ignoreNatives = false); + DECLARE_PERSISTENT(ScValue, BaseClass) + + bool _isConstVar; + bool saveAsText(BaseDynamicBuffer *buffer, int indent); + void setValue(ScValue *val); + bool _persistent; + bool propExists(const char *name); + void copy(ScValue *orig, bool copyWhole = false); + void setStringVal(const char *val); + TValType getType(); + bool getBool(bool defaultVal = false); + int getInt(int defaultVal = 0); + double getFloat(double defaultVal = 0.0f); + const char *getString(); + void *getMemBuffer(); + BaseScriptable *getNative(); + bool deleteProp(const char *name); + void deleteProps(); + void CleanProps(bool includingNatives); + void setBool(bool val); + void setInt(int val); + void setFloat(double val); + void setString(const char *val); + void setString(const Common::String &val); + void setNULL(); + void setNative(BaseScriptable *val, bool persistent = false); + void setObject(); + void setReference(ScValue *val); + bool isNULL(); + bool isNative(); + bool isString(); + bool isBool(); + bool isFloat(); + bool isInt(); + bool isObject(); + bool setProp(const char *name, ScValue *val, bool copyWhole = false, bool setAsConst = false); + ScValue *getProp(const char *name); + BaseScriptable *_valNative; + ScValue *_valRef; +private: + bool _valBool; + int _valInt; + double _valFloat; + char *_valString; +public: + TValType _type; + ScValue(BaseGame *inGame); + ScValue(BaseGame *inGame, bool Val); + ScValue(BaseGame *inGame, int Val); + ScValue(BaseGame *inGame, double Val); + ScValue(BaseGame *inGame, const char *Val); + virtual ~ScValue(); + Common::HashMap _valObject; + Common::HashMap::iterator _valIter; + + bool setProperty(const char *propName, int value); + bool setProperty(const char *propName, const char *value); + bool setProperty(const char *propName, double value); + bool setProperty(const char *propName, bool value); + bool setProperty(const char *propName); +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/sound/base_sound.cpp b/engines/wintermute/base/sound/base_sound.cpp index aac68baccd..00d07cd3c2 100644 --- a/engines/wintermute/base/sound/base_sound.cpp +++ b/engines/wintermute/base/sound/base_sound.cpp @@ -1,292 +1,292 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/sound/base_sound.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/sound/base_sound_buffer.h" - -namespace Wintermute { - -IMPLEMENT_PERSISTENT(BaseSound, false) - -BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { - _sound = NULL; - _soundFilename = ""; - - _soundType = Audio::Mixer::kSFXSoundType; - _soundStreamed = false; - _soundLooping = false; - _soundPlaying = false; - _soundPaused = false; - _soundFreezePaused = false; - _soundPosition = 0; - _soundPrivateVolume = 0; - _soundLoopStart = 0; - - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; -} - -BaseSound::~BaseSound() { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - } - _sound = NULL; -} - -bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { - if (_sound) { - _gameRef->_soundMgr->removeSound(_sound); - _sound = NULL; - } - _soundFilename = Common::String(); // Set empty - - _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); - if (_sound) { - _soundFilename = filename; - - _soundType = type; - _soundStreamed = streamed; - - return STATUS_OK; - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::setSoundSimple() { - _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); - if (_sound) { - if (_soundPosition) { - _sound->setPosition(_soundPosition); - } - _sound->setLooping(_soundLooping); - _sound->setPrivateVolume(_soundPrivateVolume); - _sound->setLoopStart(_soundLoopStart); - _sound->_freezePaused = _soundFreezePaused; - if (_soundPlaying) { - return _sound->resume(); - } else { - return STATUS_OK; - } - } else { - return STATUS_FAILED; - } -} - -uint32 BaseSound::getLength() { - if (_sound) { - return _sound->getLength(); - } else { - return 0; - } -} - -bool BaseSound::play(bool looping) { - if (_sound) { - _soundPaused = false; - return _sound->play(looping, _soundPosition); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::stop() { - if (_sound) { - _soundPaused = false; - return _sound->stop(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::pause(bool freezePaused) { - if (_sound) { - _soundPaused = true; - if (freezePaused) { - _sound->_freezePaused = true; - } - return _sound->pause(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::resume() { - if (_sound && _soundPaused) { - _soundPaused = false; - return _sound->resume(); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::persist(BasePersistenceManager *persistMgr) { - if (persistMgr->getIsSaving() && _sound) { - _soundPlaying = _sound->isPlaying(); - _soundLooping = _sound->_looping; - _soundPrivateVolume = _sound->_privateVolume; - if (_soundPlaying) { - _soundPosition = _sound->getPosition(); - } - _soundLoopStart = _sound->_loopStart; - _soundFreezePaused = _sound->_freezePaused; - } - - if (persistMgr->getIsSaving()) { - _sFXType = SFX_NONE; - _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; - } - - persistMgr->transfer(TMEMBER(_gameRef)); - - persistMgr->transfer(TMEMBER(_soundFilename)); - persistMgr->transfer(TMEMBER(_soundLooping)); - persistMgr->transfer(TMEMBER(_soundPaused)); - persistMgr->transfer(TMEMBER(_soundFreezePaused)); - persistMgr->transfer(TMEMBER(_soundPlaying)); - persistMgr->transfer(TMEMBER(_soundPosition)); - persistMgr->transfer(TMEMBER(_soundPrivateVolume)); - persistMgr->transfer(TMEMBER(_soundStreamed)); - persistMgr->transfer(TMEMBER_INT(_soundType)); - persistMgr->transfer(TMEMBER(_soundLoopStart)); - - return STATUS_OK; -} - -bool BaseSound::isPlaying() { - return _sound && _sound->isPlaying(); -} - -bool BaseSound::isPaused() { - return _sound && _soundPaused; -} - -bool BaseSound::setPositionTime(uint32 time) { - if (!_sound) { - return STATUS_FAILED; - } - _soundPosition = time; - bool ret = _sound->setPosition(_soundPosition); - if (_sound->isPlaying()) { - _soundPosition = 0; - } - return ret; -} - -uint32 BaseSound::getPositionTime() { - if (!_sound) { - return 0; - } - - if (!_sound->isPlaying()) { - return 0; - } else { - return _sound->getPosition(); - } -} - -bool BaseSound::setVolumePercent(int percent) { - if (!_sound) { - return STATUS_FAILED; - } else { - return _sound->setPrivateVolume(percent * 255 / 100); - } -} - -bool BaseSound::setVolume(int volume) { - if (!_sound) { - return STATUS_FAILED; - } else { - return _sound->setPrivateVolume(volume); - } -} - -bool BaseSound::setPrivateVolume(int volume) { - if (!_sound) { - return STATUS_FAILED; - } else { - _sound->_privateVolume = volume; - return STATUS_OK; - } -} - -int BaseSound::getVolumePercent() { - if (!_sound) { - return 0; - } else { - return _sound->_privateVolume * 100 / 255; - } -} - -int BaseSound::getVolume() { - if (!_sound) { - return 0; - } else { - return _sound->_privateVolume; - } -} - -bool BaseSound::setLoopStart(uint32 pos) { - if (!_sound) { - return STATUS_FAILED; - } else { - _sound->setLoopStart(pos); - return STATUS_OK; - } -} - -bool BaseSound::setPan(float pan) { - if (_sound) { - return _sound->setPan(pan); - } else { - return STATUS_FAILED; - } -} - -bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - if (!_sound) { - return STATUS_OK; - } - - if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { - bool ret = _sound->applyFX(type, param1, param2, param3, param4); - - _sFXType = type; - _sFXParam1 = param1; - _sFXParam2 = param2; - _sFXParam3 = param3; - _sFXParam4 = param4; - - return ret; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/sound/base_sound.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" + +namespace Wintermute { + +IMPLEMENT_PERSISTENT(BaseSound, false) + +BaseSound::BaseSound(BaseGame *inGame) : BaseClass(inGame) { + _sound = NULL; + _soundFilename = ""; + + _soundType = Audio::Mixer::kSFXSoundType; + _soundStreamed = false; + _soundLooping = false; + _soundPlaying = false; + _soundPaused = false; + _soundFreezePaused = false; + _soundPosition = 0; + _soundPrivateVolume = 0; + _soundLoopStart = 0; + + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; +} + +BaseSound::~BaseSound() { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + } + _sound = NULL; +} + +bool BaseSound::setSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { + if (_sound) { + _gameRef->_soundMgr->removeSound(_sound); + _sound = NULL; + } + _soundFilename = Common::String(); // Set empty + + _sound = _gameRef->_soundMgr->addSound(filename, type, streamed); + if (_sound) { + _soundFilename = filename; + + _soundType = type; + _soundStreamed = streamed; + + return STATUS_OK; + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::setSoundSimple() { + _sound = _gameRef->_soundMgr->addSound(_soundFilename, _soundType, _soundStreamed); + if (_sound) { + if (_soundPosition) { + _sound->setPosition(_soundPosition); + } + _sound->setLooping(_soundLooping); + _sound->setPrivateVolume(_soundPrivateVolume); + _sound->setLoopStart(_soundLoopStart); + _sound->_freezePaused = _soundFreezePaused; + if (_soundPlaying) { + return _sound->resume(); + } else { + return STATUS_OK; + } + } else { + return STATUS_FAILED; + } +} + +uint32 BaseSound::getLength() { + if (_sound) { + return _sound->getLength(); + } else { + return 0; + } +} + +bool BaseSound::play(bool looping) { + if (_sound) { + _soundPaused = false; + return _sound->play(looping, _soundPosition); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::stop() { + if (_sound) { + _soundPaused = false; + return _sound->stop(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::pause(bool freezePaused) { + if (_sound) { + _soundPaused = true; + if (freezePaused) { + _sound->_freezePaused = true; + } + return _sound->pause(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::resume() { + if (_sound && _soundPaused) { + _soundPaused = false; + return _sound->resume(); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::persist(BasePersistenceManager *persistMgr) { + if (persistMgr->getIsSaving() && _sound) { + _soundPlaying = _sound->isPlaying(); + _soundLooping = _sound->_looping; + _soundPrivateVolume = _sound->_privateVolume; + if (_soundPlaying) { + _soundPosition = _sound->getPosition(); + } + _soundLoopStart = _sound->_loopStart; + _soundFreezePaused = _sound->_freezePaused; + } + + if (persistMgr->getIsSaving()) { + _sFXType = SFX_NONE; + _sFXParam1 = _sFXParam2 = _sFXParam3 = _sFXParam4 = 0; + } + + persistMgr->transfer(TMEMBER(_gameRef)); + + persistMgr->transfer(TMEMBER(_soundFilename)); + persistMgr->transfer(TMEMBER(_soundLooping)); + persistMgr->transfer(TMEMBER(_soundPaused)); + persistMgr->transfer(TMEMBER(_soundFreezePaused)); + persistMgr->transfer(TMEMBER(_soundPlaying)); + persistMgr->transfer(TMEMBER(_soundPosition)); + persistMgr->transfer(TMEMBER(_soundPrivateVolume)); + persistMgr->transfer(TMEMBER(_soundStreamed)); + persistMgr->transfer(TMEMBER_INT(_soundType)); + persistMgr->transfer(TMEMBER(_soundLoopStart)); + + return STATUS_OK; +} + +bool BaseSound::isPlaying() { + return _sound && _sound->isPlaying(); +} + +bool BaseSound::isPaused() { + return _sound && _soundPaused; +} + +bool BaseSound::setPositionTime(uint32 time) { + if (!_sound) { + return STATUS_FAILED; + } + _soundPosition = time; + bool ret = _sound->setPosition(_soundPosition); + if (_sound->isPlaying()) { + _soundPosition = 0; + } + return ret; +} + +uint32 BaseSound::getPositionTime() { + if (!_sound) { + return 0; + } + + if (!_sound->isPlaying()) { + return 0; + } else { + return _sound->getPosition(); + } +} + +bool BaseSound::setVolumePercent(int percent) { + if (!_sound) { + return STATUS_FAILED; + } else { + return _sound->setPrivateVolume(percent * 255 / 100); + } +} + +bool BaseSound::setVolume(int volume) { + if (!_sound) { + return STATUS_FAILED; + } else { + return _sound->setPrivateVolume(volume); + } +} + +bool BaseSound::setPrivateVolume(int volume) { + if (!_sound) { + return STATUS_FAILED; + } else { + _sound->_privateVolume = volume; + return STATUS_OK; + } +} + +int BaseSound::getVolumePercent() { + if (!_sound) { + return 0; + } else { + return _sound->_privateVolume * 100 / 255; + } +} + +int BaseSound::getVolume() { + if (!_sound) { + return 0; + } else { + return _sound->_privateVolume; + } +} + +bool BaseSound::setLoopStart(uint32 pos) { + if (!_sound) { + return STATUS_FAILED; + } else { + _sound->setLoopStart(pos); + return STATUS_OK; + } +} + +bool BaseSound::setPan(float pan) { + if (_sound) { + return _sound->setPan(pan); + } else { + return STATUS_FAILED; + } +} + +bool BaseSound::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + if (!_sound) { + return STATUS_OK; + } + + if (type != _sFXType || param1 != _sFXParam1 || param2 != _sFXParam2 || param3 != _sFXParam3 || param4 != _sFXParam4) { + bool ret = _sound->applyFX(type, param1, param2, param3, param4); + + _sFXType = type; + _sFXParam1 = param1; + _sFXParam2 = param2; + _sFXParam3 = param3; + _sFXParam4 = param4; + + return ret; + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound.h b/engines/wintermute/base/sound/base_sound.h index d65757474a..637061b7cc 100644 --- a/engines/wintermute/base/sound/base_sound.h +++ b/engines/wintermute/base/sound/base_sound.h @@ -1,87 +1,87 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SOUND_H -#define WINTERMUTE_BASE_SOUND_H - -#include "engines/wintermute/base/base.h" -#include "engines/wintermute/dctypes.h" // Added by ClassView -#include "engines/wintermute/persistent.h" -#include "audio/mixer.h" - -namespace Wintermute { - -class BaseSoundBuffer; -class BaseSound : public BaseClass { -public: - bool setPan(float pan); - int getVolume(); - int getVolumePercent(); - bool setVolumePercent(int percent); - bool setVolume(int volume); - bool setPrivateVolume(int volume); - bool setLoopStart(uint32 pos); - uint32 getPositionTime(); - bool setPositionTime(uint32 time); - bool isPlaying(); - bool isPaused(); - DECLARE_PERSISTENT(BaseSound, BaseClass) - bool resume(); - bool pause(bool freezePaused = false); - bool stop(); - bool play(bool looping = false); - uint32 getLength(); - const char *getFilename() { return _soundFilename.c_str(); } - bool setSoundSimple(); - bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - BaseSound(BaseGame *inGame); - virtual ~BaseSound(); - - bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); -private: - Common::String _soundFilename; - bool _soundStreamed; - Audio::Mixer::SoundType _soundType; - int _soundPrivateVolume; - uint32 _soundLoopStart; - uint32 _soundPosition; - bool _soundPlaying; - bool _soundLooping; - bool _soundPaused; - bool _soundFreezePaused; - TSFXType _sFXType; - float _sFXParam1; - float _sFXParam2; - float _sFXParam3; - float _sFXParam4; - BaseSoundBuffer *_sound; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUND_H +#define WINTERMUTE_BASE_SOUND_H + +#include "engines/wintermute/base/base.h" +#include "engines/wintermute/dctypes.h" // Added by ClassView +#include "engines/wintermute/persistent.h" +#include "audio/mixer.h" + +namespace Wintermute { + +class BaseSoundBuffer; +class BaseSound : public BaseClass { +public: + bool setPan(float pan); + int getVolume(); + int getVolumePercent(); + bool setVolumePercent(int percent); + bool setVolume(int volume); + bool setPrivateVolume(int volume); + bool setLoopStart(uint32 pos); + uint32 getPositionTime(); + bool setPositionTime(uint32 time); + bool isPlaying(); + bool isPaused(); + DECLARE_PERSISTENT(BaseSound, BaseClass) + bool resume(); + bool pause(bool freezePaused = false); + bool stop(); + bool play(bool looping = false); + uint32 getLength(); + const char *getFilename() { return _soundFilename.c_str(); } + bool setSoundSimple(); + bool setSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + BaseSound(BaseGame *inGame); + virtual ~BaseSound(); + + bool applyFX(TSFXType type = SFX_NONE, float param1 = 0, float param2 = 0, float param3 = 0, float param4 = 0); +private: + Common::String _soundFilename; + bool _soundStreamed; + Audio::Mixer::SoundType _soundType; + int _soundPrivateVolume; + uint32 _soundLoopStart; + uint32 _soundPosition; + bool _soundPlaying; + bool _soundLooping; + bool _soundPaused; + bool _soundFreezePaused; + TSFXType _sFXType; + float _sFXParam1; + float _sFXParam2; + float _sFXParam3; + float _sFXParam4; + BaseSoundBuffer *_sound; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index e2d9c8c13f..3fd6c4d5f2 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -1,297 +1,297 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/file/base_file.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/sound/base_sound_buffer.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/utils.h" -#include "engines/wintermute/wintermute.h" -#include "audio/audiostream.h" -#include "audio/mixer.h" -#include "audio/decoders/vorbis.h" -#include "audio/decoders/wave.h" -#include "audio/decoders/raw.h" -#include "common/system.h" -#include "common/substream.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 - -////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { - _stream = NULL; - _handle = NULL; -// _sync = NULL; - - _streamed = false; - _filename = ""; - _file = NULL; - _privateVolume = 255; - _volume = 255; - - _looping = false; - _loopStart = 0; - _startPos = 0; - - _type = Audio::Mixer::kSFXSoundType; - - _freezePaused = false; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer::~BaseSoundBuffer() { - stop(); - - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - delete _stream; - _stream = NULL; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 blockSize) { - _streamed = streamed; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { - debugC(kWintermuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); - - // Load a file, but avoid having the File-manager handle the disposal of it. - _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); - if (!_file) { - _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); - return STATUS_FAILED; - } - Common::String strFilename(filename); - strFilename.toLowercase(); - if (strFilename.hasSuffix(".ogg")) { - _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); - } else if (strFilename.hasSuffix(".wav")) { - int waveSize, waveRate; - byte waveFlags; - uint16 waveType; - - if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { - if (waveType == 1) { - // We need to wrap the file in a substream to make sure the size is right. - _file = new Common::SeekableSubReadStream(_file, 0, waveSize); - _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); - } else { - error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType); - } - } - } else { - error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str()); - } - if (!_stream) { - return STATUS_FAILED; - } - _filename = filename; - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::play(bool looping, uint32 startSample) { - if (_handle) { - g_system->getMixer()->stopHandle(*_handle); - delete _handle; - _handle = NULL; - } - // Store the loop-value for save-games. - setLooping(looping); - if (_stream) { - _stream->seek(startSample); - _handle = new Audio::SoundHandle; - if (_looping) { - Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); - g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); - } else { - g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); - } - } - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::setLooping(bool looping) { - if (isPlaying()) { - // This warning is here, to see if this is ever the case. - warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO - } - _looping = looping; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::resume() { - // If the sound was paused while active: - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, false); - } else if (_stream) { // Otherwise we come from a savegame, and thus have no handle - play(_looping, _startPos); - } else { - warning("BaseSoundBuffer::resume - Called without a handle or a stream"); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::stop() { - if (_stream && _handle) { - g_system->getMixer()->stopHandle(*_handle); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::pause() { - if (_stream && _handle) { - g_system->getMixer()->pauseHandle(*_handle, true); - } - return STATUS_OK; - -} - -////////////////////////////////////////////////////////////////////////// -uint32 BaseSoundBuffer::getLength() { - if (_stream) { - uint32 len = _stream->getLength().msecs(); - return len * 1000; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { - _type = type; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSoundBuffer::updateVolume() { - setVolume(_privateVolume); -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setVolume(int volume) { - _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; - if (_stream && _handle) { - byte vol = (byte)(_volume); - g_system->getMixer()->setChannelVolume(*_handle, vol); - } - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setPrivateVolume(int volume) { - _privateVolume = volume; - return setVolume(_privateVolume); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::isPlaying() { - if (_stream && _handle) { - return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); - } else { - return false; - } -} - - -////////////////////////////////////////////////////////////////////////// -uint32 BaseSoundBuffer::getPosition() { - if (_stream && _handle) { - uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); - return pos; - } - return 0; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setPosition(uint32 pos) { - if (isPlaying()) { - warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); - } - _startPos = pos; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setLoopStart(uint32 pos) { - _loopStart = pos; - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::setPan(float pan) { - if (_handle) { - g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { - // This function was already stubbed out in WME Lite, and thus isn't reimplemented here either. - switch (type) { - case SFX_ECHO: - //warning("BaseSoundBuffer::ApplyFX(SFX_ECHO, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); - break; - - case SFX_REVERB: - //warning("BaseSoundBuffer::ApplyFX(SFX_REVERB, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); - break; - - default: - break; - } - return STATUS_OK; -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/file/base_file.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/utils/utils.h" +#include "engines/wintermute/wintermute.h" +#include "audio/audiostream.h" +#include "audio/mixer.h" +#include "audio/decoders/vorbis.h" +#include "audio/decoders/wave.h" +#include "audio/decoders/raw.h" +#include "common/system.h" +#include "common/substream.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +#define MAX_NONSTREAMED_FILE_SIZE 1024*1024 + +////////////////////////////////////////////////////////////////////////// +BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) { + _stream = NULL; + _handle = NULL; +// _sync = NULL; + + _streamed = false; + _filename = ""; + _file = NULL; + _privateVolume = 255; + _volume = 255; + + _looping = false; + _loopStart = 0; + _startPos = 0; + + _type = Audio::Mixer::kSFXSoundType; + + _freezePaused = false; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSoundBuffer::~BaseSoundBuffer() { + stop(); + + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + delete _stream; + _stream = NULL; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::setStreaming(bool streamed, uint32 numBlocks, uint32 blockSize) { + _streamed = streamed; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::loadFromFile(const Common::String &filename, bool forceReload) { + debugC(kWintermuteDebugAudio, "BSoundBuffer::LoadFromFile(%s,%d)", filename.c_str(), forceReload); + + // Load a file, but avoid having the File-manager handle the disposal of it. + _file = BaseFileManager::getEngineInstance()->openFile(filename, true, false); + if (!_file) { + _gameRef->LOG(0, "Error opening sound file '%s'", filename.c_str()); + return STATUS_FAILED; + } + Common::String strFilename(filename); + strFilename.toLowercase(); + if (strFilename.hasSuffix(".ogg")) { + _stream = Audio::makeVorbisStream(_file, DisposeAfterUse::YES); + } else if (strFilename.hasSuffix(".wav")) { + int waveSize, waveRate; + byte waveFlags; + uint16 waveType; + + if (Audio::loadWAVFromStream(*_file, waveSize, waveRate, waveFlags, &waveType)) { + if (waveType == 1) { + // We need to wrap the file in a substream to make sure the size is right. + _file = new Common::SeekableSubReadStream(_file, 0, waveSize); + _stream = Audio::makeRawStream(_file, waveRate, waveFlags, DisposeAfterUse::YES); + } else { + error("BSoundBuffer::LoadFromFile - WAVE not supported yet for %s with type %d", filename.c_str(), waveType); + } + } + } else { + error("BSoundBuffer::LoadFromFile - Unknown filetype for %s", filename.c_str()); + } + if (!_stream) { + return STATUS_FAILED; + } + _filename = filename; + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::play(bool looping, uint32 startSample) { + if (_handle) { + g_system->getMixer()->stopHandle(*_handle); + delete _handle; + _handle = NULL; + } + // Store the loop-value for save-games. + setLooping(looping); + if (_stream) { + _stream->seek(startSample); + _handle = new Audio::SoundHandle; + if (_looping) { + Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO); + g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES); + } else { + g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO); + } + } + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::setLooping(bool looping) { + if (isPlaying()) { + // This warning is here, to see if this is ever the case. + warning("BSoundBuffer::SetLooping(%d) - won't change a playing sound", looping); // TODO + } + _looping = looping; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::resume() { + // If the sound was paused while active: + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, false); + } else if (_stream) { // Otherwise we come from a savegame, and thus have no handle + play(_looping, _startPos); + } else { + warning("BaseSoundBuffer::resume - Called without a handle or a stream"); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::stop() { + if (_stream && _handle) { + g_system->getMixer()->stopHandle(*_handle); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::pause() { + if (_stream && _handle) { + g_system->getMixer()->pauseHandle(*_handle, true); + } + return STATUS_OK; + +} + +////////////////////////////////////////////////////////////////////////// +uint32 BaseSoundBuffer::getLength() { + if (_stream) { + uint32 len = _stream->getLength().msecs(); + return len * 1000; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::setType(Audio::Mixer::SoundType type) { + _type = type; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSoundBuffer::updateVolume() { + setVolume(_privateVolume); +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setVolume(int volume) { + _volume = volume * _gameRef->_soundMgr->getMasterVolume() / 255; + if (_stream && _handle) { + byte vol = (byte)(_volume); + g_system->getMixer()->setChannelVolume(*_handle, vol); + } + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setPrivateVolume(int volume) { + _privateVolume = volume; + return setVolume(_privateVolume); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::isPlaying() { + if (_stream && _handle) { + return _freezePaused || g_system->getMixer()->isSoundHandleActive(*_handle); + } else { + return false; + } +} + + +////////////////////////////////////////////////////////////////////////// +uint32 BaseSoundBuffer::getPosition() { + if (_stream && _handle) { + uint32 pos = g_system->getMixer()->getSoundElapsedTime(*_handle); + return pos; + } + return 0; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setPosition(uint32 pos) { + if (isPlaying()) { + warning("BaseSoundBuffer::SetPosition - not implemented for playing sounds yet."); + } + _startPos = pos; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setLoopStart(uint32 pos) { + _loopStart = pos; + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::setPan(float pan) { + if (_handle) { + g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127)); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundBuffer::applyFX(TSFXType type, float param1, float param2, float param3, float param4) { + // This function was already stubbed out in WME Lite, and thus isn't reimplemented here either. + switch (type) { + case SFX_ECHO: + //warning("BaseSoundBuffer::ApplyFX(SFX_ECHO, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); + break; + + case SFX_REVERB: + //warning("BaseSoundBuffer::ApplyFX(SFX_REVERB, %f, %f, %f, %f) - not implemented yet", param1, param2, param3, param4); + break; + + default: + break; + } + return STATUS_OK; +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_buffer.h b/engines/wintermute/base/sound/base_sound_buffer.h index 29402ee76e..9c39f4c34b 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.h +++ b/engines/wintermute/base/sound/base_sound_buffer.h @@ -1,100 +1,100 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SOUNDBUFFER_H -#define WINTERMUTE_BASE_SOUNDBUFFER_H - - -#include "engines/wintermute/base/base.h" -#include "audio/mixer.h" -#include "common/stream.h" - -namespace Audio { -class SeekableAudioStream; -class SoundHandle; -} - -namespace Wintermute { - -class BaseFile; -class BaseSoundBuffer : public BaseClass { -public: - - BaseSoundBuffer(BaseGame *inGame); - virtual ~BaseSoundBuffer(); - - bool pause(); - bool play(bool looping = false, uint32 startSample = 0); - bool resume(); - bool stop(); - bool isPlaying(); - - void setLooping(bool looping); - - uint32 getPosition(); - bool setPosition(uint32 pos); - uint32 getLength(); - - bool setLoopStart(uint32 pos); - uint32 getLoopStart() const { - return _loopStart; - } - - bool setPan(float pan); - bool setPrivateVolume(int colume); - bool setVolume(int colume); - void updateVolume(); - - void setType(Audio::Mixer::SoundType Type); - - bool loadFromFile(const Common::String &filename, bool forceReload = false); - void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); - bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); - - //HSTREAM _stream; - //HSYNC _sync; - Audio::SeekableAudioStream *_stream; - Audio::SoundHandle *_handle; - - bool _freezePaused; - uint32 _loopStart; - Audio::Mixer::SoundType _type; - bool _looping; - - int _privateVolume; -private: - uint32 _startPos; - Common::String _filename; - bool _streamed; - Common::SeekableReadStream *_file; - int _volume; -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUNDBUFFER_H +#define WINTERMUTE_BASE_SOUNDBUFFER_H + + +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/stream.h" + +namespace Audio { +class SeekableAudioStream; +class SoundHandle; +} + +namespace Wintermute { + +class BaseFile; +class BaseSoundBuffer : public BaseClass { +public: + + BaseSoundBuffer(BaseGame *inGame); + virtual ~BaseSoundBuffer(); + + bool pause(); + bool play(bool looping = false, uint32 startSample = 0); + bool resume(); + bool stop(); + bool isPlaying(); + + void setLooping(bool looping); + + uint32 getPosition(); + bool setPosition(uint32 pos); + uint32 getLength(); + + bool setLoopStart(uint32 pos); + uint32 getLoopStart() const { + return _loopStart; + } + + bool setPan(float pan); + bool setPrivateVolume(int colume); + bool setVolume(int colume); + void updateVolume(); + + void setType(Audio::Mixer::SoundType Type); + + bool loadFromFile(const Common::String &filename, bool forceReload = false); + void setStreaming(bool streamed, uint32 numBlocks = 0, uint32 blockSize = 0); + bool applyFX(TSFXType type, float param1, float param2, float param3, float param4); + + //HSTREAM _stream; + //HSYNC _sync; + Audio::SeekableAudioStream *_stream; + Audio::SoundHandle *_handle; + + bool _freezePaused; + uint32 _loopStart; + Audio::Mixer::SoundType _type; + bool _looping; + + int _privateVolume; +private: + uint32 _startPos; + Common::String _filename; + bool _streamed; + Common::SeekableReadStream *_file; + int _volume; +}; + +} // end of namespace Wintermute + +#endif diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index 2bfe0499f9..f7788cd255 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -1,282 +1,282 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#include "engines/wintermute/base/sound/base_sound_manager.h" -#include "engines/wintermute/base/base_engine.h" -#include "engines/wintermute/utils/path_util.h" -#include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/base/sound/base_sound_buffer.h" -#include "engines/wintermute/wintermute.h" -#include "common/config-manager.h" -#include "audio/mixer.h" - -namespace Wintermute { - -////////////////////////////////////////////////////////////////////// -// Construction/Destruction -////////////////////////////////////////////////////////////////////// - -//IMPLEMENT_PERSISTENT(BaseSoundMgr, true); - -////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { - _soundAvailable = false; - _volumeMaster = 255; -} - - -////////////////////////////////////////////////////////////////////////// -BaseSoundMgr::~BaseSoundMgr() { - saveSettings(); - cleanup(); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::cleanup() { - for (uint32 i = 0; i < _sounds.size(); i++) { - delete _sounds[i]; - } - _sounds.clear(); - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -void BaseSoundMgr::saveSettings() { - if (_soundAvailable) { - ConfMan.setInt("master_volume", _volumeMaster); - } -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::initialize() { - _soundAvailable = false; - - if (!g_system->getMixer()->isReady()) { - return STATUS_FAILED; - } - _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); - _soundAvailable = true; - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { - if (!_soundAvailable) { - return NULL; - } - - BaseSoundBuffer *sound; - - Common::String useFilename = filename; - // try to switch WAV to OGG file (if available) - AnsiString ext = PathUtil::getExtension(filename); - if (StringUtil::compareNoCase(ext, "wav")) { - AnsiString path = PathUtil::getDirectoryName(filename); - AnsiString name = PathUtil::getFileNameWithoutExtension(filename); - - AnsiString newFile = PathUtil::combine(path, name + "ogg"); - if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { - useFilename = newFile; - } - } - - sound = new BaseSoundBuffer(_gameRef); - if (!sound) { - return NULL; - } - - sound->setStreaming(streamed); - sound->setType(type); - - - bool res = sound->loadFromFile(useFilename); - if (DID_FAIL(res)) { - _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); - delete sound; - return NULL; - } - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return sound; - - return NULL; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { - if (!sound) { - return STATUS_FAILED; - } - - // Make sure the master-volume is applied to the sound. - sound->updateVolume(); - - // register sound - _sounds.push_back(sound); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i] == sound) { - delete _sounds[i]; - _sounds.remove_at(i); - return STATUS_OK; - } - } - - return STATUS_FAILED; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { - if (!_soundAvailable) { - return STATUS_OK; - } - - switch (type) { - case Audio::Mixer::kSFXSoundType: - ConfMan.setInt("sfx_volume", volume); - break; - case Audio::Mixer::kSpeechSoundType: - ConfMan.setInt("speech_volume", volume); - break; - case Audio::Mixer::kMusicSoundType: - ConfMan.setInt("music_volume", volume); - break; - case Audio::Mixer::kPlainSoundType: - error("Plain sound type shouldn't be used in WME"); - } - g_engine->syncSoundSettings(); - - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { - return setVolume(type, percent * 255 / 100); -} - - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { - int volume = 0; - - switch (type) { - case Audio::Mixer::kSFXSoundType: - case Audio::Mixer::kSpeechSoundType: - case Audio::Mixer::kMusicSoundType: - volume = g_system->getMixer()->getVolumeForSoundType(type); - break; - default: - error("Sound-type not set"); - break; - } - - return (byte)(volume * 100 / 255); -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setMasterVolume(byte value) { - _volumeMaster = value; - for (uint32 i = 0; i < _sounds.size(); i++) { - _sounds[i]->updateVolume(); - } - return STATUS_OK; -} - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::setMasterVolumePercent(byte percent) { - setMasterVolume(percent * 255 / 100); - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::getMasterVolumePercent() { - return getMasterVolume() * 100 / 255; -} - -////////////////////////////////////////////////////////////////////////// -byte BaseSoundMgr::getMasterVolume() { - return (byte)_volumeMaster; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::pauseAll(bool includingMusic) { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { - _sounds[i]->pause(); - _sounds[i]->_freezePaused = true; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -bool BaseSoundMgr::resumeAll() { - - for (uint32 i = 0; i < _sounds.size(); i++) { - if (_sounds[i]->_freezePaused) { - _sounds[i]->resume(); - _sounds[i]->_freezePaused = false; - } - } - - return STATUS_OK; -} - - -////////////////////////////////////////////////////////////////////////// -float BaseSoundMgr::posToPan(int x, int y) { - float relPos = (float)x / ((float)_gameRef->_renderer->_width); - - float minPan = -0.7f; - float maxPan = 0.7f; - - return minPan + relPos * (maxPan - minPan); -} - -} // end of namespace Wintermute +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#include "engines/wintermute/base/sound/base_sound_manager.h" +#include "engines/wintermute/base/base_engine.h" +#include "engines/wintermute/utils/path_util.h" +#include "engines/wintermute/utils/string_util.h" +#include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/sound/base_sound_buffer.h" +#include "engines/wintermute/wintermute.h" +#include "common/config-manager.h" +#include "audio/mixer.h" + +namespace Wintermute { + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +//IMPLEMENT_PERSISTENT(BaseSoundMgr, true); + +////////////////////////////////////////////////////////////////////////// +BaseSoundMgr::BaseSoundMgr(BaseGame *inGame) : BaseClass(inGame) { + _soundAvailable = false; + _volumeMaster = 255; +} + + +////////////////////////////////////////////////////////////////////////// +BaseSoundMgr::~BaseSoundMgr() { + saveSettings(); + cleanup(); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::cleanup() { + for (uint32 i = 0; i < _sounds.size(); i++) { + delete _sounds[i]; + } + _sounds.clear(); + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +void BaseSoundMgr::saveSettings() { + if (_soundAvailable) { + ConfMan.setInt("master_volume", _volumeMaster); + } +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::initialize() { + _soundAvailable = false; + + if (!g_system->getMixer()->isReady()) { + return STATUS_FAILED; + } + _volumeMaster = (ConfMan.hasKey("master_volume") ? ConfMan.getInt("master_volume") : 255); + _soundAvailable = true; + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +BaseSoundBuffer *BaseSoundMgr::addSound(const Common::String &filename, Audio::Mixer::SoundType type, bool streamed) { + if (!_soundAvailable) { + return NULL; + } + + BaseSoundBuffer *sound; + + Common::String useFilename = filename; + // try to switch WAV to OGG file (if available) + AnsiString ext = PathUtil::getExtension(filename); + if (StringUtil::compareNoCase(ext, "wav")) { + AnsiString path = PathUtil::getDirectoryName(filename); + AnsiString name = PathUtil::getFileNameWithoutExtension(filename); + + AnsiString newFile = PathUtil::combine(path, name + "ogg"); + if (BaseFileManager::getEngineInstance()->hasFile(newFile)) { + useFilename = newFile; + } + } + + sound = new BaseSoundBuffer(_gameRef); + if (!sound) { + return NULL; + } + + sound->setStreaming(streamed); + sound->setType(type); + + + bool res = sound->loadFromFile(useFilename); + if (DID_FAIL(res)) { + _gameRef->LOG(res, "Error loading sound '%s'", useFilename.c_str()); + delete sound; + return NULL; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return sound; + + return NULL; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type) { + if (!sound) { + return STATUS_FAILED; + } + + // Make sure the master-volume is applied to the sound. + sound->updateVolume(); + + // register sound + _sounds.push_back(sound); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::removeSound(BaseSoundBuffer *sound) { + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i] == sound) { + delete _sounds[i]; + _sounds.remove_at(i); + return STATUS_OK; + } + } + + return STATUS_FAILED; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setVolume(Audio::Mixer::SoundType type, int volume) { + if (!_soundAvailable) { + return STATUS_OK; + } + + switch (type) { + case Audio::Mixer::kSFXSoundType: + ConfMan.setInt("sfx_volume", volume); + break; + case Audio::Mixer::kSpeechSoundType: + ConfMan.setInt("speech_volume", volume); + break; + case Audio::Mixer::kMusicSoundType: + ConfMan.setInt("music_volume", volume); + break; + case Audio::Mixer::kPlainSoundType: + error("Plain sound type shouldn't be used in WME"); + } + g_engine->syncSoundSettings(); + + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setVolumePercent(Audio::Mixer::SoundType type, byte percent) { + return setVolume(type, percent * 255 / 100); +} + + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::getVolumePercent(Audio::Mixer::SoundType type) { + int volume = 0; + + switch (type) { + case Audio::Mixer::kSFXSoundType: + case Audio::Mixer::kSpeechSoundType: + case Audio::Mixer::kMusicSoundType: + volume = g_system->getMixer()->getVolumeForSoundType(type); + break; + default: + error("Sound-type not set"); + break; + } + + return (byte)(volume * 100 / 255); +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setMasterVolume(byte value) { + _volumeMaster = value; + for (uint32 i = 0; i < _sounds.size(); i++) { + _sounds[i]->updateVolume(); + } + return STATUS_OK; +} + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::setMasterVolumePercent(byte percent) { + setMasterVolume(percent * 255 / 100); + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::getMasterVolumePercent() { + return getMasterVolume() * 100 / 255; +} + +////////////////////////////////////////////////////////////////////////// +byte BaseSoundMgr::getMasterVolume() { + return (byte)_volumeMaster; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::pauseAll(bool includingMusic) { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->isPlaying() && (_sounds[i]->_type != Audio::Mixer::kMusicSoundType || includingMusic)) { + _sounds[i]->pause(); + _sounds[i]->_freezePaused = true; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +bool BaseSoundMgr::resumeAll() { + + for (uint32 i = 0; i < _sounds.size(); i++) { + if (_sounds[i]->_freezePaused) { + _sounds[i]->resume(); + _sounds[i]->_freezePaused = false; + } + } + + return STATUS_OK; +} + + +////////////////////////////////////////////////////////////////////////// +float BaseSoundMgr::posToPan(int x, int y) { + float relPos = (float)x / ((float)_gameRef->_renderer->_width); + + float minPan = -0.7f; + float maxPan = 0.7f; + + return minPan + relPos * (maxPan - minPan); +} + +} // end of namespace Wintermute diff --git a/engines/wintermute/base/sound/base_sound_manager.h b/engines/wintermute/base/sound/base_sound_manager.h index d0b782b2b7..36a729b5ae 100644 --- a/engines/wintermute/base/sound/base_sound_manager.h +++ b/engines/wintermute/base/sound/base_sound_manager.h @@ -1,68 +1,68 @@ -/* ScummVM - Graphic Adventure Engine - * - * ScummVM is the legal property of its developers, whose names - * are too numerous to list here. Please refer to the COPYRIGHT - * file distributed with this source distribution. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - * - */ - -/* - * This file is based on WME Lite. - * http://dead-code.org/redir.php?target=wmelite - * Copyright (c) 2011 Jan Nedoma - */ - -#ifndef WINTERMUTE_BASE_SOUNDMGR_H -#define WINTERMUTE_BASE_SOUNDMGR_H - -#include "engines/wintermute/coll_templ.h" -#include "engines/wintermute/base/base.h" -#include "audio/mixer.h" -#include "common/array.h" - -namespace Wintermute { -class BaseSoundBuffer; -class BaseSoundMgr : public BaseClass { -public: - float posToPan(int x, int y); - bool resumeAll(); - bool pauseAll(bool includingMusic = true); - bool cleanup(); - //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); - byte getMasterVolumePercent(); - byte getMasterVolume(); - bool setMasterVolume(byte percent); - bool setMasterVolumePercent(byte percent); - byte getVolumePercent(Audio::Mixer::SoundType type); - bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); - bool setVolume(Audio::Mixer::SoundType type, int volume); - uint32 _volumeOriginal; - int _volumeMaster; - bool removeSound(BaseSoundBuffer *sound); - BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); - bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); - bool initialize(); - bool _soundAvailable; - BaseSoundMgr(BaseGame *inGame); - virtual ~BaseSoundMgr(); - Common::Array _sounds; - void saveSettings(); -}; - -} // end of namespace Wintermute - -#endif +/* ScummVM - Graphic Adventure Engine + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ + +/* + * This file is based on WME Lite. + * http://dead-code.org/redir.php?target=wmelite + * Copyright (c) 2011 Jan Nedoma + */ + +#ifndef WINTERMUTE_BASE_SOUNDMGR_H +#define WINTERMUTE_BASE_SOUNDMGR_H + +#include "engines/wintermute/coll_templ.h" +#include "engines/wintermute/base/base.h" +#include "audio/mixer.h" +#include "common/array.h" + +namespace Wintermute { +class BaseSoundBuffer; +class BaseSoundMgr : public BaseClass { +public: + float posToPan(int x, int y); + bool resumeAll(); + bool pauseAll(bool includingMusic = true); + bool cleanup(); + //DECLARE_PERSISTENT(BaseSoundMgr, BaseClass); + byte getMasterVolumePercent(); + byte getMasterVolume(); + bool setMasterVolume(byte percent); + bool setMasterVolumePercent(byte percent); + byte getVolumePercent(Audio::Mixer::SoundType type); + bool setVolumePercent(Audio::Mixer::SoundType type, byte percent); + bool setVolume(Audio::Mixer::SoundType type, int volume); + uint32 _volumeOriginal; + int _volumeMaster; + bool removeSound(BaseSoundBuffer *sound); + BaseSoundBuffer *addSound(const Common::String &filename, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType, bool streamed = false); + bool addSound(BaseSoundBuffer *sound, Audio::Mixer::SoundType type = Audio::Mixer::kSFXSoundType); + bool initialize(); + bool _soundAvailable; + BaseSoundMgr(BaseGame *inGame); + virtual ~BaseSoundMgr(); + Common::Array _sounds; + void saveSettings(); +}; + +} // end of namespace Wintermute + +#endif -- cgit v1.2.3 From 2a6e55169530b46985d6d6af6ebcbb12e7c5a603 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 11 Sep 2012 02:51:33 +0200 Subject: WINTERMUTE: Only include base_renderer.h where needed --- engines/wintermute/base/base_active_rect.cpp | 1 + engines/wintermute/base/base_fader.cpp | 1 + engines/wintermute/base/base_game.h | 1 - engines/wintermute/base/base_save_thumb_helper.cpp | 1 + engines/wintermute/base/base_sub_frame.cpp | 1 + engines/wintermute/base/base_surface_storage.cpp | 1 + engines/wintermute/base/base_transition_manager.cpp | 1 + engines/wintermute/base/base_viewport.cpp | 1 + engines/wintermute/base/font/base_font_bitmap.cpp | 1 + engines/wintermute/base/particles/part_emitter.cpp | 1 + engines/wintermute/base/saveload.cpp | 1 + engines/wintermute/base/sound/base_sound_manager.cpp | 1 + 12 files changed, 11 insertions(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_active_rect.cpp b/engines/wintermute/base/base_active_rect.cpp index d754cf0114..4addf15be8 100644 --- a/engines/wintermute/base/base_active_rect.cpp +++ b/engines/wintermute/base/base_active_rect.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/base/base_active_rect.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_region.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/platform_osystem.h" namespace Wintermute { diff --git a/engines/wintermute/base/base_fader.cpp b/engines/wintermute/base/base_fader.cpp index 08e6f689ba..985718fcab 100644 --- a/engines/wintermute/base/base_fader.cpp +++ b/engines/wintermute/base/base_fader.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_fader.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "common/util.h" namespace Wintermute { diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 93cbc4536b..8c337e82e9 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -29,7 +29,6 @@ #ifndef WINTERMUTE_BASE_GAME_H #define WINTERMUTE_BASE_GAME_H -#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_object.h" #include "engines/wintermute/persistent.h" #include "engines/wintermute/coll_templ.h" diff --git a/engines/wintermute/base/base_save_thumb_helper.cpp b/engines/wintermute/base/base_save_thumb_helper.cpp index 186e1234a8..b4205c21c4 100644 --- a/engines/wintermute/base/base_save_thumb_helper.cpp +++ b/engines/wintermute/base/base_save_thumb_helper.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_save_thumb_helper.h" #include "engines/wintermute/base/gfx/base_image.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_game.h" namespace Wintermute { diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 6a9246efd4..2ff12e8deb 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -34,6 +34,7 @@ #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/scriptables/script_value.h" #include "engines/wintermute/base/scriptables/script_stack.h" diff --git a/engines/wintermute/base/base_surface_storage.cpp b/engines/wintermute/base/base_surface_storage.cpp index 1dcebb0595..4e795ca813 100644 --- a/engines/wintermute/base/base_surface_storage.cpp +++ b/engines/wintermute/base/base_surface_storage.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_surface_storage.h" #include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" diff --git a/engines/wintermute/base/base_transition_manager.cpp b/engines/wintermute/base/base_transition_manager.cpp index 5c28f36d30..7785f3d5af 100644 --- a/engines/wintermute/base/base_transition_manager.cpp +++ b/engines/wintermute/base/base_transition_manager.cpp @@ -28,6 +28,7 @@ #include "engines/wintermute/base/base_transition_manager.h" #include "engines/wintermute/base/base_game.h" +#include "engines/wintermute/base/gfx/base_renderer.h" namespace Wintermute { diff --git a/engines/wintermute/base/base_viewport.cpp b/engines/wintermute/base/base_viewport.cpp index 3b003e1c49..7ec995449f 100644 --- a/engines/wintermute/base/base_viewport.cpp +++ b/engines/wintermute/base/base_viewport.cpp @@ -29,6 +29,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/base_viewport.h" +#include "engines/wintermute/base/gfx/base_renderer.h" namespace Wintermute { diff --git a/engines/wintermute/base/font/base_font_bitmap.cpp b/engines/wintermute/base/font/base_font_bitmap.cpp index fced08c7e2..55f46c476b 100644 --- a/engines/wintermute/base/font/base_font_bitmap.cpp +++ b/engines/wintermute/base/font/base_font_bitmap.cpp @@ -31,6 +31,7 @@ #include "engines/wintermute/base/base_parser.h" #include "engines/wintermute/base/base_frame.h" #include "engines/wintermute/base/gfx/base_surface.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/base_frame.h" diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 3655b89131..4e3fc2239e 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -35,6 +35,7 @@ #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/platform_osystem.h" #include "common/str.h" diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index 06e9fd2565..0ca68c743f 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -35,6 +35,7 @@ #include "engines/wintermute/base/base_region.h" #include "engines/wintermute/base/base_sub_frame.h" #include "engines/wintermute/base/font/base_font.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/scriptables/script.h" #include "common/savefile.h" diff --git a/engines/wintermute/base/sound/base_sound_manager.cpp b/engines/wintermute/base/sound/base_sound_manager.cpp index f7788cd255..441793144d 100644 --- a/engines/wintermute/base/sound/base_sound_manager.cpp +++ b/engines/wintermute/base/sound/base_sound_manager.cpp @@ -32,6 +32,7 @@ #include "engines/wintermute/utils/string_util.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_file_manager.h" +#include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/sound/base_sound_buffer.h" #include "engines/wintermute/wintermute.h" #include "common/config-manager.h" -- cgit v1.2.3 From 8c864170a4afef9d1c88c4d35169da9ce49c4f16 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 11 Sep 2012 03:11:02 +0200 Subject: WINTERMUTE: Remove unneccessary includes of base_file.h --- engines/wintermute/base/font/base_font_truetype.cpp | 1 - engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp | 1 - engines/wintermute/base/scriptables/script_ext_file.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 - 4 files changed, 4 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 599010bbd5..214b3e3d45 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/font/base_font_truetype.h" #include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" diff --git a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp index d5464782a3..bee876bb65 100644 --- a/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_surface_osystem.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/gfx/osystem/base_surface_osystem.h" diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index ab574d464b..2dc385b015 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -33,7 +33,6 @@ #include "engines/wintermute/base/scriptables/script.h" #include "engines/wintermute/utils/utils.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/platform_osystem.h" #include "engines/wintermute/base/scriptables/script_ext_file.h" diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index 3fd6c4d5f2..c0e6660865 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -26,7 +26,6 @@ * Copyright (c) 2011 Jan Nedoma */ -#include "engines/wintermute/base/file/base_file.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/sound/base_sound_buffer.h" -- cgit v1.2.3 From f33884b02091537275a17ff55ae756ff4e862c29 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Tue, 11 Sep 2012 03:40:56 +0200 Subject: WINTERMUTE: Remove a few more unused includes. --- engines/wintermute/base/file/base_save_thumb_file.cpp | 1 - engines/wintermute/base/font/base_font_storage.cpp | 1 - engines/wintermute/base/font/base_font_truetype.cpp | 2 -- engines/wintermute/base/scriptables/script_engine.cpp | 1 - engines/wintermute/base/sound/base_sound_buffer.cpp | 1 - 5 files changed, 6 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_save_thumb_file.cpp b/engines/wintermute/base/file/base_save_thumb_file.cpp index 5bdab0853e..94d3e5a94e 100644 --- a/engines/wintermute/base/file/base_save_thumb_file.cpp +++ b/engines/wintermute/base/file/base_save_thumb_file.cpp @@ -28,7 +28,6 @@ #include "engines/wintermute/base/base_persistence_manager.h" #include "engines/wintermute/base/file/base_save_thumb_file.h" -#include "engines/wintermute/platform_osystem.h" namespace Wintermute { diff --git a/engines/wintermute/base/font/base_font_storage.cpp b/engines/wintermute/base/font/base_font_storage.cpp index d26fa1d593..8128ffe897 100644 --- a/engines/wintermute/base/font/base_font_storage.cpp +++ b/engines/wintermute/base/font/base_font_storage.cpp @@ -29,7 +29,6 @@ #include "engines/wintermute/base/font/base_font_storage.h" #include "engines/wintermute/base/font/base_font.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/platform_osystem.h" #include "common/str.h" namespace Wintermute { diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 214b3e3d45..3219918e6d 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -27,9 +27,7 @@ */ #include "engines/wintermute/base/font/base_font_truetype.h" -#include "engines/wintermute/utils/path_util.h" #include "engines/wintermute/utils/string_util.h" -#include "engines/wintermute/math/math_util.h" #include "engines/wintermute/base/gfx/base_renderer.h" #include "engines/wintermute/base/gfx/base_surface.h" #include "engines/wintermute/base/base_parser.h" diff --git a/engines/wintermute/base/scriptables/script_engine.cpp b/engines/wintermute/base/scriptables/script_engine.cpp index 20e2ccadd1..3d1863946e 100644 --- a/engines/wintermute/base/scriptables/script_engine.cpp +++ b/engines/wintermute/base/scriptables/script_engine.cpp @@ -33,7 +33,6 @@ #include "engines/wintermute/base/scriptables/script_ext_math.h" #include "engines/wintermute/base/base_engine.h" #include "engines/wintermute/base/base_game.h" -#include "engines/wintermute/base/sound/base_sound.h" #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/utils/utils.h" diff --git a/engines/wintermute/base/sound/base_sound_buffer.cpp b/engines/wintermute/base/sound/base_sound_buffer.cpp index c0e6660865..250570f2b8 100644 --- a/engines/wintermute/base/sound/base_sound_buffer.cpp +++ b/engines/wintermute/base/sound/base_sound_buffer.cpp @@ -30,7 +30,6 @@ #include "engines/wintermute/base/sound/base_sound_manager.h" #include "engines/wintermute/base/sound/base_sound_buffer.h" #include "engines/wintermute/base/base_file_manager.h" -#include "engines/wintermute/utils/utils.h" #include "engines/wintermute/wintermute.h" #include "audio/audiostream.h" #include "audio/mixer.h" -- cgit v1.2.3 From b1ec9280fd757184ce8262d3f25b3cf75fed19ec Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 15 Sep 2012 18:05:18 +0200 Subject: WINTERMUTE: Disable aspect-ratio correction for now. --- engines/wintermute/base/gfx/osystem/base_render_osystem.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 6d67253038..03ec827668 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -573,6 +573,11 @@ Rect32 BaseRenderOSystem::getViewPort() { ////////////////////////////////////////////////////////////////////////// void BaseRenderOSystem::modTargetRect(Common::Rect *rect) { + // FIXME: This is wrong in quite a few ways right now, and ends up + // breaking the notebook in Dirty Split, so we disable the correction + // for now, this will need fixing when a game with odd aspect-ratios + // show up. + return; rect->left = (int16)MathUtil::round(rect->left * _ratioX + _borderLeft - _renderRect.left); rect->top = (int16)MathUtil::round(rect->top * _ratioY + _borderTop - _renderRect.top); rect->setWidth((int16)MathUtil::roundUp(rect->width() * _ratioX)); -- cgit v1.2.3 From edeedc3cc57b2d0fee8431a6b6f27b1b308bb2b7 Mon Sep 17 00:00:00 2001 From: Willem Jan Palenstijn Date: Sun, 23 Sep 2012 21:23:20 +0200 Subject: WINTERMUTE: Fix leak --- engines/wintermute/base/file/base_disk_file.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/file/base_disk_file.cpp b/engines/wintermute/base/file/base_disk_file.cpp index 2d3951b026..25be3dad2d 100644 --- a/engines/wintermute/base/file/base_disk_file.cpp +++ b/engines/wintermute/base/file/base_disk_file.cpp @@ -178,10 +178,8 @@ Common::SeekableReadStream *openDiskFile(const Common::String &filename) { } delete[] compBuffer; - - return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); delete file; - file = NULL; + return new Common::MemoryReadStream(data, uncompSize, DisposeAfterUse::YES); } else { file->seek(0, SEEK_SET); return file; -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- engines/wintermute/base/base_engine.cpp | 12 +++--- engines/wintermute/base/base_engine.h | 6 +-- engines/wintermute/base/base_game.cpp | 4 +- engines/wintermute/base/file/base_package.cpp | 8 ++-- engines/wintermute/base/gfx/base_renderer.cpp | 10 ++--- .../base/gfx/osystem/base_render_osystem.cpp | 2 +- engines/wintermute/base/saveload.cpp | 46 +++++++++++----------- engines/wintermute/base/saveload.h | 8 ++-- 8 files changed, 48 insertions(+), 48 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp index 2368f8b106..8146d14beb 100644 --- a/engines/wintermute/base/base_engine.cpp +++ b/engines/wintermute/base/base_engine.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - + #include "engines/wintermute/base/base_file_manager.h" #include "engines/wintermute/base/base_game.h" #include "engines/wintermute/base/base_engine.h" @@ -71,10 +71,10 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { secs = secs % 3600; uint32 mins = secs / 60; secs = secs % 60; - + char buff[512]; va_list va; - + va_start(va, fmt); vsprintf(buff, fmt, va); va_end(va); @@ -82,7 +82,7 @@ void BaseEngine::LOG(bool res, const char *fmt, ...) { if (instance()._gameRef) { instance()._gameRef->LOG("%s", buff); } else { - debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); + debugCN(kWintermuteDebugLog, "%02d:%02d:%02d: %s\n", hours, mins, secs, buff); } } diff --git a/engines/wintermute/base/base_engine.h b/engines/wintermute/base/base_engine.h index 1cef7b33ba..1ed0e3ab01 100644 --- a/engines/wintermute/base/base_engine.h +++ b/engines/wintermute/base/base_engine.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - + #ifndef WINTERMUTE_BASE_ENGINE_H #define WINTERMUTE_BASE_ENGINE_H diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 622e85cc11..7b0024414e 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -740,7 +740,7 @@ bool BaseGame::loadBuffer(byte *buffer, bool complete) { TOKEN_TABLE(LOCAL_SAVE_DIR) TOKEN_TABLE(COMPAT_KILL_METHOD_THREADS) TOKEN_TABLE_END - + // Declare a few variables necessary for moving data from these settings over to the renderer: // The values are the same as the defaults set in BaseRenderer. int loadImageX = 0; @@ -3624,7 +3624,7 @@ bool BaseGame::persist(BasePersistenceManager *persistMgr) { persistMgr->transfer(TMEMBER(_musicCrossfadeChannel1)); persistMgr->transfer(TMEMBER(_musicCrossfadeChannel2)); persistMgr->transfer(TMEMBER(_musicCrossfadeSwap)); - + _renderer->persistSaveLoadImages(persistMgr); persistMgr->transfer(TMEMBER_INT(_textEncoding)); diff --git a/engines/wintermute/base/file/base_package.cpp b/engines/wintermute/base/file/base_package.cpp index 9780992652..51a1558a7c 100644 --- a/engines/wintermute/base/file/base_package.cpp +++ b/engines/wintermute/base/file/base_package.cpp @@ -86,16 +86,16 @@ void TPackageHeader::readFromStream(Common::ReadStream *stream) { _magic1 = stream->readUint32LE(); _magic2 = stream->readUint32LE(); _packageVersion = stream->readUint32LE(); - + _gameVersion = stream->readUint32LE(); - + _priority = stream->readByte(); _cd = stream->readByte(); _masterIndex = stream->readByte(); stream->readByte(); // To align the next byte... - + _creationTime = stream->readUint32LE(); - + stream->read(_desc, 100); _numDirs = stream->readUint32LE(); } diff --git a/engines/wintermute/base/gfx/base_renderer.cpp b/engines/wintermute/base/gfx/base_renderer.cpp index 9205438a5b..e7ffc14c25 100644 --- a/engines/wintermute/base/gfx/base_renderer.cpp +++ b/engines/wintermute/base/gfx/base_renderer.cpp @@ -129,13 +129,13 @@ void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { _indicatorDisplay = true; _indicatorProgress = 0; _hasDrawnSaveLoadImage = false; - + if (isSaving && !quickSave) { delete _saveLoadImage; _saveLoadImage = NULL; if (_saveImageName.size()) { _saveLoadImage = createSurface(); - + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_saveImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; @@ -146,7 +146,7 @@ void BaseRenderer::initSaveLoad(bool isSaving, bool quickSave) { _saveLoadImage = NULL; if (_loadImageName.size()) { _saveLoadImage = createSurface(); - + if (!_saveLoadImage || DID_FAIL(_saveLoadImage->create(_loadImageName, true, 0, 0, 0))) { delete _saveLoadImage; _saveLoadImage = NULL; @@ -360,7 +360,7 @@ bool BaseRenderer::displayIndicator() { flip(); _hasDrawnSaveLoadImage = true; } - + if ((!_indicatorDisplay && _indicatorWidth <= 0) || _indicatorHeight <= 0) { return STATUS_OK; } @@ -369,7 +369,7 @@ bool BaseRenderer::displayIndicator() { for (int i = 0; i < _indicatorHeight; i++) { drawLine(_indicatorX, _indicatorY + i, _indicatorX + curWidth, _indicatorY + i, _indicatorColor); } - + setup2D(); _indicatorWidthDrawn = curWidth; if (_indicatorWidthDrawn) { diff --git a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp index 03ec827668..7970a25300 100644 --- a/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp +++ b/engines/wintermute/base/gfx/osystem/base_render_osystem.cpp @@ -261,7 +261,7 @@ void BaseRenderOSystem::fade(uint16 alpha) { void BaseRenderOSystem::fadeToColor(byte r, byte g, byte b, byte a, Common::Rect *rect) { // This particular warning is rather messy, as this function is called a ton, // thus we avoid printing it more than once. - + // TODO: Add fading with dirty rects. if (!_disableDirtyRects) { warning("BaseRenderOSystem::FadeToColor - Breaks when using dirty rects"); diff --git a/engines/wintermute/base/saveload.cpp b/engines/wintermute/base/saveload.cpp index 0ca68c743f..12204e1b35 100644 --- a/engines/wintermute/base/saveload.cpp +++ b/engines/wintermute/base/saveload.cpp @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -45,11 +45,11 @@ namespace Wintermute { bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { gameRef->LOG(0, "Loading game '%s'...", filename.c_str()); - + bool ret; - + gameRef->_renderer->initSaveLoad(false); - + gameRef->_loadInProgress = true; BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initLoad(filename))) { @@ -61,20 +61,20 @@ bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { // data initialization after load SaveLoad::initAfterLoad(); - + gameRef->applyEvent("AfterLoad", true); - + gameRef->displayContent(true, false); //_renderer->flip(); } } } - + delete pm; gameRef->_loadInProgress = false; - + gameRef->_renderer->endSaveLoad(); - + //_gameRef->LOG(0, "Load end %d", BaseUtils::GetUsedMemMB()); // AdGame: if (DID_SUCCEED(ret)) { @@ -85,13 +85,13 @@ bool SaveLoad::loadGame(const Common::String &filename, BaseGame *gameRef) { bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef) { Common::String filename = SaveLoad::getSaveSlotFilename(slot); - + gameRef->LOG(0, "Saving game '%s'...", filename.c_str()); - + gameRef->applyEvent("BeforeSave", true); - + bool ret; - + BasePersistenceManager *pm = new BasePersistenceManager(); if (DID_SUCCEED(ret = pm->initSave(desc))) { gameRef->_renderer->initSaveLoad(true, quickSave); // TODO: The original code inited the indicator before the conditionals @@ -104,11 +104,11 @@ bool SaveLoad::saveGame(int slot, const char *desc, bool quickSave, BaseGame *ga } } } - + delete pm; - + gameRef->_renderer->endSaveLoad(); - + return ret; } @@ -166,21 +166,21 @@ Common::String SaveLoad::getSaveSlotFilename(int slot) { bool SaveLoad::getSaveSlotDescription(int slot, char *buffer) { buffer[0] = '\0'; - + Common::String filename = getSaveSlotFilename(slot); BasePersistenceManager *pm = new BasePersistenceManager(); if (!pm) { return false; } - + if (!(pm->initLoad(filename))) { delete pm; return false; } - + strcpy(buffer, pm->_savedDescription); delete pm; - + return true; } @@ -199,6 +199,6 @@ bool SaveLoad::emptySaveSlot(int slot) { delete pm; return true; } - - + + } // end of namespace Wintermute diff --git a/engines/wintermute/base/saveload.h b/engines/wintermute/base/saveload.h index e448cc8814..722f7a89b6 100644 --- a/engines/wintermute/base/saveload.h +++ b/engines/wintermute/base/saveload.h @@ -8,12 +8,12 @@ * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - + * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. @@ -25,7 +25,7 @@ * http://dead-code.org/redir.php?target=wmelite * Copyright (c) 2011 Jan Nedoma */ - + #ifndef WINTERMUTE_SAVEGAME_H #define WINTERMUTE_SAVEGAME_H @@ -39,7 +39,7 @@ public: static bool isSaveSlotUsed(int slot); static bool getSaveSlotDescription(int slot, char *buffer); static Common::String getSaveSlotFilename(int slot); - + static bool loadGame(const Common::String &filename, BaseGame *gameRef); static bool saveGame(int slot, const char *desc, bool quickSave, BaseGame *gameRef); static bool initAfterLoad(); -- cgit v1.2.3 From ee4a92cce511586898c8334e0ade2e82db57b1f7 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 28 Sep 2012 15:42:08 +0200 Subject: WINTERMUTE: Privatise member-variables in BaseDynamicBuffer --- engines/wintermute/base/base_dynamic_buffer.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_dynamic_buffer.h b/engines/wintermute/base/base_dynamic_buffer.h index b6f3e12b9c..2d1a7fbe48 100644 --- a/engines/wintermute/base/base_dynamic_buffer.h +++ b/engines/wintermute/base/base_dynamic_buffer.h @@ -29,14 +29,12 @@ #ifndef WINTERMUTE_BASE_DYNAMIC_BUFFER_H #define WINTERMUTE_BASE_DYNAMIC_BUFFER_H - #include "engines/wintermute/base/base.h" namespace Wintermute { class BaseDynamicBuffer { public: - bool _initialized; void putText(const char *fmt, ...); void putTextIndent(int indent, const char *fmt, ...); uint32 getDWORD(); @@ -48,12 +46,13 @@ public: uint32 getSize(); bool init(uint32 initSize = 0); void cleanup(); - uint32 _size; - byte *_buffer; BaseDynamicBuffer(BaseGame *inGame, uint32 initSize = 1000, uint32 growBy = 1000); virtual ~BaseDynamicBuffer(); private: + uint32 _size; + byte *_buffer; + bool _initialized; uint32 _realSize; uint32 _growBy; uint32 _initSize; -- cgit v1.2.3 From f6d7d05343375b05f5f487c0c9006fe2cdd7a387 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 28 Sep 2012 15:53:05 +0200 Subject: WINTERMUTE: Privatize variables in BaseFader --- engines/wintermute/base/base_fader.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_fader.h b/engines/wintermute/base/base_fader.h index d3ced4aacc..116c8c963d 100644 --- a/engines/wintermute/base/base_fader.h +++ b/engines/wintermute/base/base_fader.h @@ -36,7 +36,6 @@ namespace Wintermute { class BaseFader : public BaseObject { public: - bool _system; uint32 getCurrentColor(); bool fadeOut(uint32 targetColor, uint32 duration, bool system = false); bool fadeIn(uint32 sourceColor, uint32 duration, bool system = false); @@ -47,6 +46,7 @@ public: BaseFader(BaseGame *inGame); virtual ~BaseFader(); private: + bool _system; bool _active; byte _red; byte _green; -- cgit v1.2.3 From b31d6212ffc35b987cfb7ee35a5ae3f75bf34a60 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 28 Sep 2012 23:42:16 +0200 Subject: WINTERMUTE: Privatize variables in BaseFrame and BaseSprite --- engines/wintermute/base/base_frame.cpp | 6 ++++++ engines/wintermute/base/base_frame.h | 10 +++++---- engines/wintermute/base/base_sprite.cpp | 11 +++++++--- engines/wintermute/base/base_sprite.h | 37 ++++++++++++++++++--------------- 4 files changed, 40 insertions(+), 24 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index e1b29a3a5c..3e67c29d2f 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -87,6 +87,12 @@ bool BaseFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float return STATUS_OK; } +void BaseFrame::stopSound() { + if (_sound) { + _sound->stop(); + } +} + ////////////////////////////////////////////////////////////////////////// bool BaseFrame::oneTimeDisplay(BaseObject *owner, bool muted) { diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index ea5467b6fe..60887210f4 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -41,11 +41,10 @@ class ScStack; class BaseFrame: public BaseScriptable { public: bool _killSound; - bool _keyframe; + void stopSound(); bool oneTimeDisplay(BaseObject *owner, bool muted = false); DECLARE_PERSISTENT(BaseFrame, BaseScriptable) - BaseSound *_sound; - bool _editorExpanded; + bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); bool saveAsText(BaseDynamicBuffer *buffer, int indent); int _moveY; @@ -65,7 +64,10 @@ public: virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); - +private: + bool _keyframe; + bool _editorExpanded; + BaseSound *_sound; }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index e2dd8bbd39..0baa25af22 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -121,6 +121,13 @@ bool BaseSprite::draw(int x, int y, BaseObject *registerOwner, float zoomX, floa return display(x, y, registerOwner, zoomX, zoomY, alpha); } +bool BaseSprite::isChanged() { + return _changed; +} + +bool BaseSprite::isFinished() { + return _finished; +} ////////////////////////////////////////////////////////////////////// bool BaseSprite::loadFile(const Common::String &filename, int lifeTime, TSpriteCacheType cacheType) { @@ -804,9 +811,7 @@ const char *BaseSprite::scToString() { ////////////////////////////////////////////////////////////////////////// bool BaseSprite::killAllSounds() { for (uint32 i = 0; i < _frames.size(); i++) { - if (_frames[i]->_sound) { - _frames[i]->_sound->stop(); - } + _frames[i]->stopSound(); } return STATUS_OK; } diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index c861ca9930..cef874b254 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -39,36 +39,21 @@ class BaseSurface; class BaseObject; class BaseSprite: public BaseScriptHolder { public: - bool killAllSounds(); BaseSurface *getSurface(); - char *_editorBgFile; - int _editorBgOffsetX; - int _editorBgOffsetY; - int _editorBgAlpha; - bool _streamed; - bool _streamedKeepLoaded; void cleanup(); void setDefaults(); - bool _precise; DECLARE_PERSISTENT(BaseSprite, BaseScriptHolder) - bool _editorAllFrames; bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); int _moveY; int _moveX; bool display(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getCurrentFrame(float zoomX = 100, float zoomY = 100); - bool _canBreak; - bool _editorMuted; - bool _continuous; void reset(); - BaseObject *_owner; - bool _changed; - bool _paused; - bool _finished; + bool isChanged(); + bool isFinished(); bool loadBuffer(byte *buffer, bool compete = true, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); bool loadFile(const Common::String &filename, int lifeTime = -1, TSpriteCacheType cacheType = CACHE_ALL); - uint32 _lastFrameTime; bool draw(int x, int y, BaseObject *Register = NULL, float zoomX = 100, float zoomY = 100, uint32 alpha = 0xFFFFFFFF); bool _looping; int _currentFrame; @@ -83,6 +68,24 @@ public: virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); +private: + BaseObject *_owner; + bool _canBreak; + bool _changed; + bool _editorAllFrames; + char *_editorBgFile; + int _editorBgOffsetX; + int _editorBgOffsetY; + int _editorBgAlpha; + bool _editorMuted; + bool _finished; + bool _continuous; + uint32 _lastFrameTime; + bool _precise; + bool _paused; + bool _streamed; + bool _streamedKeepLoaded; + bool killAllSounds(); }; } // end of namespace Wintermute -- cgit v1.2.3 From 03e7bffc77c8b4e74bee34573da35fe88459703e Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 28 Sep 2012 23:55:41 +0200 Subject: WINTERMUTE: Privatize variables in BaseRegion and BaseSubFrame --- engines/wintermute/base/base_region.h | 7 ++++--- engines/wintermute/base/base_sub_frame.cpp | 3 +++ engines/wintermute/base/base_sub_frame.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 8dd02fe928..51989de630 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -36,9 +36,6 @@ namespace Wintermute { class BaseRegion : public BaseObject { public: - float _lastMimicScale; - int _lastMimicX; - int _lastMimicY; void cleanup(); bool mimic(BaseRegion *region, float scale = 100.0f, int x = 0, int y = 0); bool getBoundingRect(Rect32 *rect); @@ -62,6 +59,10 @@ public: virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); +private: + float _lastMimicScale; + int _lastMimicX; + int _lastMimicY; }; } // end of namespace Wintermute diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index 2ff12e8deb..fd7ee50eda 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -226,6 +226,9 @@ void BaseSubFrame::setRect(Rect32 rect) { _rect = rect; } +const char* BaseSubFrame::getSurfaceFilename() { + return _surfaceFilename; +} ////////////////////////////////////////////////////////////////////// bool BaseSubFrame::draw(int x, int y, BaseObject *registerOwner, float zoomX, float zoomY, bool precise, uint32 alpha, float rotate, TSpriteBlendMode blendMode) { diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index b174c6e5f0..0be77c544a 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -54,6 +54,7 @@ public: bool loadBuffer(byte *buffer, int lifeTime, bool keepLoaded); bool draw(int x, int y, BaseObject *registerOwner = NULL, float zoomX = 100, float zoomY = 100, bool precise = true, uint32 alpha = 0xFFFFFFFF, float rotate = 0.0f, TSpriteBlendMode blendMode = BLEND_NORMAL); bool getBoundingRect(Rect32 *rect, int x, int y, float scaleX = 100, float scaleY = 100); + const char* getSurfaceFilename(); int _hotspotX; int _hotspotY; @@ -65,6 +66,7 @@ public: private: bool _wantsDefaultRect; Rect32 _rect; + char *_surfaceFilename; public: bool _cKDefault; byte _cKRed; @@ -72,7 +74,6 @@ public: byte _cKBlue; int _lifeTime; bool _keepLoaded; - char *_surfaceFilename; bool _2DOnly; bool _3DOnly; -- cgit v1.2.3 From 67a7f5b3063c8d9634f43ee36ba26b18c2e6cd11 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 28 Sep 2012 23:57:42 +0200 Subject: WINTERMUTE: Privatize variables in BaseQuickMsg --- engines/wintermute/base/base_quick_msg.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_quick_msg.h b/engines/wintermute/base/base_quick_msg.h index 4fed5ffc2e..67f9613461 100644 --- a/engines/wintermute/base/base_quick_msg.h +++ b/engines/wintermute/base/base_quick_msg.h @@ -37,10 +37,10 @@ class BaseQuickMsg : public BaseClass { public: char *getText(); uint32 _startTime; - char *_text; - BaseQuickMsg(BaseGame *inGame, const char *Text); + BaseQuickMsg(BaseGame *inGame, const char *text); virtual ~BaseQuickMsg(); - +private: + char *_text; }; } // end of namespace Wintermute -- cgit v1.2.3 From afc21941e37a7481f5fe050d220968bdce43c873 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Sat, 29 Sep 2012 00:47:12 +0200 Subject: WINTERMUTE: Make scGetProperty use Common::String& instead of const char* --- engines/wintermute/base/base_frame.cpp | 18 ++-- engines/wintermute/base/base_frame.h | 2 +- engines/wintermute/base/base_game.cpp | 96 +++++++++++----------- engines/wintermute/base/base_game.h | 2 +- engines/wintermute/base/base_keyboard_state.cpp | 16 ++-- engines/wintermute/base/base_keyboard_state.h | 2 +- engines/wintermute/base/base_object.cpp | 48 +++++------ engines/wintermute/base/base_object.h | 2 +- engines/wintermute/base/base_region.cpp | 10 +-- engines/wintermute/base/base_region.h | 2 +- engines/wintermute/base/base_script_holder.cpp | 8 +- engines/wintermute/base/base_script_holder.h | 2 +- engines/wintermute/base/base_scriptable.cpp | 4 +- engines/wintermute/base/base_scriptable.h | 2 +- engines/wintermute/base/base_sprite.cpp | 18 ++-- engines/wintermute/base/base_sprite.h | 2 +- engines/wintermute/base/base_sub_frame.cpp | 22 ++--- engines/wintermute/base/base_sub_frame.h | 2 +- engines/wintermute/base/particles/part_emitter.cpp | 72 ++++++++-------- engines/wintermute/base/particles/part_emitter.h | 2 +- .../base/scriptables/script_ext_array.cpp | 8 +- .../wintermute/base/scriptables/script_ext_array.h | 2 +- .../base/scriptables/script_ext_date.cpp | 6 +- .../wintermute/base/scriptables/script_ext_date.h | 2 +- .../base/scriptables/script_ext_file.cpp | 14 ++-- .../wintermute/base/scriptables/script_ext_file.h | 2 +- .../base/scriptables/script_ext_math.cpp | 6 +- .../wintermute/base/scriptables/script_ext_math.h | 2 +- .../base/scriptables/script_ext_mem_buffer.cpp | 6 +- .../base/scriptables/script_ext_mem_buffer.h | 2 +- .../base/scriptables/script_ext_string.cpp | 8 +- .../base/scriptables/script_ext_string.h | 2 +- 32 files changed, 196 insertions(+), 196 deletions(-) (limited to 'engines/wintermute/base') diff --git a/engines/wintermute/base/base_frame.cpp b/engines/wintermute/base/base_frame.cpp index 3e67c29d2f..7c64144480 100644 --- a/engines/wintermute/base/base_frame.cpp +++ b/engines/wintermute/base/base_frame.cpp @@ -624,7 +624,7 @@ bool BaseFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStac ////////////////////////////////////////////////////////////////////////// -ScValue *BaseFrame::scGetProperty(const char *name) { +ScValue *BaseFrame::scGetProperty(const Common::String &name) { if (!_scValue) { _scValue = new ScValue(_gameRef); } @@ -633,7 +633,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("frame"); return _scValue; } @@ -641,7 +641,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Delay ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Delay") == 0) { + else if (name == "Delay") { _scValue->setInt(_delay); return _scValue; } @@ -649,7 +649,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Keyframe ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyframe") == 0) { + else if (name == "Keyframe") { _scValue->setBool(_keyframe); return _scValue; } @@ -657,7 +657,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // KillSounds ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KillSounds") == 0) { + else if (name == "KillSounds") { _scValue->setBool(_killSound); return _scValue; } @@ -665,7 +665,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MoveX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveX") == 0) { + else if (name == "MoveX") { _scValue->setInt(_moveX); return _scValue; } @@ -673,7 +673,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MoveY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MoveY") == 0) { + else if (name == "MoveY") { _scValue->setInt(_moveY); return _scValue; } @@ -681,7 +681,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumSubframes (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumSubframes") == 0) { + else if (name == "NumSubframes") { _scValue->setInt(_subframes.size()); return _scValue; } @@ -689,7 +689,7 @@ ScValue *BaseFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumEvents (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumEvents") == 0) { + else if (name == "NumEvents") { _scValue->setInt(_applyEvent.size()); return _scValue; } diff --git a/engines/wintermute/base/base_frame.h b/engines/wintermute/base/base_frame.h index 60887210f4..7c5d893e70 100644 --- a/engines/wintermute/base/base_frame.h +++ b/engines/wintermute/base/base_frame.h @@ -60,7 +60,7 @@ public: BaseArray _applyEvent; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_game.cpp b/engines/wintermute/base/base_game.cpp index 7b0024414e..f0b1171ca4 100644 --- a/engines/wintermute/base/base_game.cpp +++ b/engines/wintermute/base/base_game.cpp @@ -2241,27 +2241,27 @@ bool BaseGame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *BaseGame::scGetProperty(const char *name) { +ScValue *BaseGame::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("game"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Hwnd (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Hwnd") == 0) { + else if (name == "Hwnd") { _scValue->setInt((int)_renderer->_window); return _scValue; } @@ -2269,7 +2269,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CurrentTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentTime") == 0) { + else if (name == "CurrentTime") { _scValue->setInt((int)_timer); return _scValue; } @@ -2277,7 +2277,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WindowsTime (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowsTime") == 0) { + else if (name == "WindowsTime") { _scValue->setInt((int)g_system->getMillis()); return _scValue; } @@ -2285,7 +2285,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // WindowedMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "WindowedMode") == 0) { + else if (name == "WindowedMode") { _scValue->setBool(_renderer->_windowed); return _scValue; } @@ -2293,7 +2293,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseX") == 0) { + else if (name == "MouseX") { _scValue->setInt(_mousePos.x); return _scValue; } @@ -2301,7 +2301,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MouseY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MouseY") == 0) { + else if (name == "MouseY") { _scValue->setInt(_mousePos.y); return _scValue; } @@ -2309,7 +2309,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MainObject ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MainObject") == 0) { + else if (name == "MainObject") { _scValue->setNative(_mainObject, true); return _scValue; } @@ -2317,7 +2317,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ActiveObject (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ActiveObject") == 0) { + else if (name == "ActiveObject") { _scValue->setNative(_activeObject, true); return _scValue; } @@ -2325,7 +2325,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScreenWidth (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenWidth") == 0) { + else if (name == "ScreenWidth") { _scValue->setInt(_renderer->_width); return _scValue; } @@ -2333,7 +2333,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScreenHeight (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScreenHeight") == 0) { + else if (name == "ScreenHeight") { _scValue->setInt(_renderer->_height); return _scValue; } @@ -2341,7 +2341,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Interactive") == 0) { + else if (name == "Interactive") { _scValue->setBool(_interactive); return _scValue; } @@ -2349,7 +2349,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // DebugMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DebugMode") == 0) { + else if (name == "DebugMode") { _scValue->setBool(_debugDebugMode); return _scValue; } @@ -2357,7 +2357,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SoundAvailable (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundAvailable") == 0) { + else if (name == "SoundAvailable") { _scValue->setBool(_soundMgr->_soundAvailable); return _scValue; } @@ -2365,7 +2365,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SFXVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SFXVolume") == 0) { + else if (name == "SFXVolume") { _gameRef->LOG(0, "**Warning** The SFXVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSFXSoundType)); return _scValue; @@ -2374,7 +2374,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SpeechVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SpeechVolume") == 0) { + else if (name == "SpeechVolume") { _gameRef->LOG(0, "**Warning** The SpeechVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kSpeechSoundType)); return _scValue; @@ -2383,7 +2383,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MusicVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MusicVolume") == 0) { + else if (name == "MusicVolume") { _gameRef->LOG(0, "**Warning** The MusicVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getVolumePercent(Audio::Mixer::kMusicSoundType)); return _scValue; @@ -2392,7 +2392,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MasterVolume ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MasterVolume") == 0) { + else if (name == "MasterVolume") { _gameRef->LOG(0, "**Warning** The MasterVolume attribute is obsolete"); _scValue->setInt(_soundMgr->getMasterVolumePercent()); return _scValue; @@ -2401,7 +2401,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Keyboard (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Keyboard") == 0) { + else if (name == "Keyboard") { if (_keyboardState) { _scValue->setNative(_keyboardState, true); } else { @@ -2414,7 +2414,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Subtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Subtitles") == 0) { + else if (name == "Subtitles") { _scValue->setBool(_subtitles); return _scValue; } @@ -2422,14 +2422,14 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SubtitlesSpeed ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SubtitlesSpeed") == 0) { + else if (name == "SubtitlesSpeed") { _scValue->setInt(_subtitlesSpeed); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VideoSubtitles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VideoSubtitles") == 0) { + else if (name == "VideoSubtitles") { _scValue->setBool(_videoSubtitles); return _scValue; } @@ -2437,7 +2437,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FPS (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FPS") == 0) { + else if (name == "FPS") { _scValue->setInt(_fps); return _scValue; } @@ -2445,7 +2445,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AcceleratedMode / Accelerated (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AcceleratedMode") == 0 || strcmp(name, "Accelerated") == 0) { + else if (name == "AcceleratedMode" || name == "Accelerated") { _scValue->setBool(_useD3D); return _scValue; } @@ -2453,7 +2453,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextEncoding ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextEncoding") == 0) { + else if (name == "TextEncoding") { _scValue->setInt(_textEncoding); return _scValue; } @@ -2461,7 +2461,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextRTL ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextRTL") == 0) { + else if (name == "TextRTL") { _scValue->setBool(_textRTL); return _scValue; } @@ -2469,7 +2469,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SoundBufferSize ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundBufferSize") == 0) { + else if (name == "SoundBufferSize") { _scValue->setInt(_soundBufferSizeSec); return _scValue; } @@ -2477,7 +2477,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SuspendedRendering ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuspendedRendering") == 0) { + else if (name == "SuspendedRendering") { _scValue->setBool(_suspendedRendering); return _scValue; } @@ -2485,7 +2485,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SuppressScriptErrors ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SuppressScriptErrors") == 0) { + else if (name == "SuppressScriptErrors") { _scValue->setBool(_suppressScriptErrors); return _scValue; } @@ -2494,7 +2494,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Frozen ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Frozen") == 0) { + else if (name == "Frozen") { _scValue->setBool(_state == GAME_FROZEN); return _scValue; } @@ -2502,7 +2502,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSEnabled") == 0) { + else if (name == "AccTTSEnabled") { _scValue->setBool(false); return _scValue; } @@ -2510,7 +2510,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSTalk ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSTalk") == 0) { + else if (name == "AccTTSTalk") { _scValue->setBool(false); return _scValue; } @@ -2518,7 +2518,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSCaptions ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSCaptions") == 0) { + else if (name == "AccTTSCaptions") { _scValue->setBool(false); return _scValue; } @@ -2526,7 +2526,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccTTSKeypress ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccTTSKeypress") == 0) { + else if (name == "AccTTSKeypress") { _scValue->setBool(false); return _scValue; } @@ -2534,7 +2534,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardEnabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardEnabled") == 0) { + else if (name == "AccKeyboardEnabled") { _scValue->setBool(false); return _scValue; } @@ -2542,7 +2542,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardCursorSkip ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardCursorSkip") == 0) { + else if (name == "AccKeyboardCursorSkip") { _scValue->setBool(false); return _scValue; } @@ -2550,7 +2550,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccKeyboardPause ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccKeyboardPause") == 0) { + else if (name == "AccKeyboardPause") { _scValue->setBool(false); return _scValue; } @@ -2558,7 +2558,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutorunDisabled ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutorunDisabled") == 0) { + else if (name == "AutorunDisabled") { _scValue->setBool(_autorunDisabled); return _scValue; } @@ -2566,7 +2566,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SaveDirectory (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveDirectory") == 0) { + else if (name == "SaveDirectory") { AnsiString dataDir = "saves/"; // TODO: This is just to avoid telling the engine actual paths. _scValue->setString(dataDir.c_str()); return _scValue; @@ -2575,7 +2575,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveOnExit ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveOnExit") == 0) { + else if (name == "AutoSaveOnExit") { _scValue->setBool(_autoSaveOnExit); return _scValue; } @@ -2583,7 +2583,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AutoSaveSlot ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AutoSaveSlot") == 0) { + else if (name == "AutoSaveSlot") { _scValue->setInt(_autoSaveSlot); return _scValue; } @@ -2591,7 +2591,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CursorHidden ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CursorHidden") == 0) { + else if (name == "CursorHidden") { _scValue->setBool(_cursorHidden); return _scValue; } @@ -2599,7 +2599,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Platform (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Platform") == 0) { + else if (name == "Platform") { _scValue->setString(BasePlatform::getPlatformName().c_str()); return _scValue; } @@ -2607,7 +2607,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // DeviceType (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "DeviceType") == 0) { + else if (name == "DeviceType") { _scValue->setString(getDeviceType().c_str()); return _scValue; } @@ -2615,7 +2615,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MostRecentSaveSlot (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MostRecentSaveSlot") == 0) { + else if (name == "MostRecentSaveSlot") { if (!ConfMan.hasKey("most_recent_saveslot")) { _scValue->setInt(-1); } else { @@ -2627,7 +2627,7 @@ ScValue *BaseGame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Store (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Store") == 0) { + else if (name == "Store") { _scValue->setNULL(); error("Request for a SXStore-object, which is not supported by ScummVM"); diff --git a/engines/wintermute/base/base_game.h b/engines/wintermute/base/base_game.h index 8c337e82e9..0f764b3d03 100644 --- a/engines/wintermute/base/base_game.h +++ b/engines/wintermute/base/base_game.h @@ -164,7 +164,7 @@ public: virtual bool externalCall(ScScript *script, ScStack *stack, ScStack *thisStack, char *name); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_keyboard_state.cpp b/engines/wintermute/base/base_keyboard_state.cpp index fd5f2b0e1d..da7baafd2d 100644 --- a/engines/wintermute/base/base_keyboard_state.cpp +++ b/engines/wintermute/base/base_keyboard_state.cpp @@ -103,13 +103,13 @@ bool BaseKeyboardState::scCallMethod(ScScript *script, ScStack *stack, ScStack * ////////////////////////////////////////////////////////////////////////// -ScValue *BaseKeyboardState::scGetProperty(const char *name) { +ScValue *BaseKeyboardState::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("keyboard"); return _scValue; } @@ -117,7 +117,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Key ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Key") == 0) { + else if (name == "Key") { if (_currentPrintable) { char key[2]; key[0] = (char)_currentCharCode; @@ -133,7 +133,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Printable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Printable") == 0) { + else if (name == "Printable") { _scValue->setBool(_currentPrintable); return _scValue; } @@ -141,7 +141,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // KeyCode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "KeyCode") == 0) { + else if (name == "KeyCode") { _scValue->setInt(_currentCharCode); return _scValue; } @@ -149,7 +149,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsShift ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsShift") == 0) { + else if (name == "IsShift") { _scValue->setBool(_currentShift); return _scValue; } @@ -157,7 +157,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsAlt ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsAlt") == 0) { + else if (name == "IsAlt") { _scValue->setBool(_currentAlt); return _scValue; } @@ -165,7 +165,7 @@ ScValue *BaseKeyboardState::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // IsControl ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "IsControl") == 0) { + else if (name == "IsControl") { _scValue->setBool(_currentControl); return _scValue; } else { diff --git a/engines/wintermute/base/base_keyboard_state.h b/engines/wintermute/base/base_keyboard_state.h index ebc0c83ee1..dfd0efdec0 100644 --- a/engines/wintermute/base/base_keyboard_state.h +++ b/engines/wintermute/base/base_keyboard_state.h @@ -59,7 +59,7 @@ public: static bool isAltDown(); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_object.cpp b/engines/wintermute/base/base_object.cpp index b6a6887624..eba8416485 100644 --- a/engines/wintermute/base/base_object.cpp +++ b/engines/wintermute/base/base_object.cpp @@ -531,13 +531,13 @@ bool BaseObject::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseObject::scGetProperty(const char *name) { +ScValue *BaseObject::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("object"); return _scValue; } @@ -545,7 +545,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Caption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Caption") == 0) { + else if (name == "Caption") { _scValue->setString(getCaption(1)); return _scValue; } @@ -553,7 +553,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { + else if (name == "X") { _scValue->setInt(_posX); return _scValue; } @@ -561,7 +561,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { + else if (name == "Y") { _scValue->setInt(_posY); return _scValue; } @@ -569,7 +569,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Height (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(getHeight()); return _scValue; } @@ -577,7 +577,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Ready (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Ready") == 0) { + else if (name == "Ready") { _scValue->setBool(_ready); return _scValue; } @@ -585,7 +585,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Movable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Movable") == 0) { + else if (name == "Movable") { _scValue->setBool(_movable); return _scValue; } @@ -593,7 +593,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Registrable/Interactive ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Registrable") == 0 || strcmp(name, "Interactive") == 0) { + else if (name == "Registrable" || name == "Interactive") { _scValue->setBool(_registrable); return _scValue; } @@ -601,21 +601,21 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Zoomable/Scalable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Zoomable") == 0 || strcmp(name, "Scalable") == 0) { + else if (name == "Zoomable" || name == "Scalable") { _scValue->setBool(_zoomable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotatable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotatable") == 0) { + else if (name == "Rotatable") { _scValue->setBool(_rotatable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { + else if (name == "AlphaColor") { _scValue->setInt((int)_alphaColor); return _scValue; } @@ -623,7 +623,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // BlendMode ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "BlendMode") == 0) { + else if (name == "BlendMode") { _scValue->setInt((int)_blendMode); return _scValue; } @@ -631,7 +631,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Scale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale") == 0) { + else if (name == "Scale") { if (_scale < 0) { _scValue->setNULL(); } else { @@ -643,7 +643,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScaleX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleX") == 0) { + else if (name == "ScaleX") { if (_scaleX < 0) { _scValue->setNULL(); } else { @@ -655,7 +655,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // ScaleY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleY") == 0) { + else if (name == "ScaleY") { if (_scaleY < 0) { _scValue->setNULL(); } else { @@ -667,7 +667,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // RelativeScale ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeScale") == 0) { + else if (name == "RelativeScale") { _scValue->setFloat((double)_relativeScale); return _scValue; } @@ -675,7 +675,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Rotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotate") == 0) { + else if (name == "Rotate") { if (!_rotateValid) { _scValue->setNULL(); } else { @@ -687,7 +687,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // RelativeRotate ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "RelativeRotate") == 0) { + else if (name == "RelativeRotate") { _scValue->setFloat((double)_relativeRotate); return _scValue; } @@ -695,14 +695,14 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Colorable ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Colorable") == 0) { + else if (name == "Colorable") { _scValue->setBool(_shadowable); return _scValue; } ////////////////////////////////////////////////////////////////////////// // SoundPanning ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SoundPanning") == 0) { + else if (name == "SoundPanning") { _scValue->setBool(_autoSoundPanning); return _scValue; } @@ -710,7 +710,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // SaveState ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "SaveState") == 0) { + else if (name == "SaveState") { _scValue->setBool(_saveState); return _scValue; } @@ -718,7 +718,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NonIntMouseEvents ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NonIntMouseEvents") == 0) { + else if (name == "NonIntMouseEvents") { _scValue->setBool(_nonIntMouseEvents); return _scValue; } @@ -726,7 +726,7 @@ ScValue *BaseObject::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccCaption ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccCaption") == 0) { + else if (name == "AccCaption") { _scValue->setNULL(); return _scValue; } else { diff --git a/engines/wintermute/base/base_object.h b/engines/wintermute/base/base_object.h index 34adbdb585..d7d91a25f6 100644 --- a/engines/wintermute/base/base_object.h +++ b/engines/wintermute/base/base_object.h @@ -136,7 +136,7 @@ public: public: // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_region.cpp b/engines/wintermute/base/base_region.cpp index e332ffe9ff..0bc5975e51 100644 --- a/engines/wintermute/base/base_region.cpp +++ b/engines/wintermute/base/base_region.cpp @@ -327,13 +327,13 @@ bool BaseRegion::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseRegion::scGetProperty(const char *name) { +ScValue *BaseRegion::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("region"); return _scValue; } @@ -341,7 +341,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -349,7 +349,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Active ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Active") == 0) { + else if (name == "Active") { _scValue->setBool(_active); return _scValue; } @@ -357,7 +357,7 @@ ScValue *BaseRegion::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumPoints ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumPoints") == 0) { + else if (name == "NumPoints") { _scValue->setInt(_points.size()); return _scValue; } else { diff --git a/engines/wintermute/base/base_region.h b/engines/wintermute/base/base_region.h index 51989de630..464f25be2f 100644 --- a/engines/wintermute/base/base_region.h +++ b/engines/wintermute/base/base_region.h @@ -55,7 +55,7 @@ public: virtual bool saveAsText(BaseDynamicBuffer *buffer, int indent, const char *nameOverride); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_script_holder.cpp b/engines/wintermute/base/base_script_holder.cpp index d3e6078d43..c5d5e82f76 100644 --- a/engines/wintermute/base/base_script_holder.cpp +++ b/engines/wintermute/base/base_script_holder.cpp @@ -219,13 +219,13 @@ bool BaseScriptHolder::scCallMethod(ScScript *script, ScStack *stack, ScStack *t ////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptHolder::scGetProperty(const char *name) { +ScValue *BaseScriptHolder::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("script_holder"); return _scValue; } @@ -233,7 +233,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Name") == 0) { + else if (name == "Name") { _scValue->setString(getName()); return _scValue; } @@ -241,7 +241,7 @@ ScValue *BaseScriptHolder::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Filename") == 0) { + else if (name == "Filename") { _scValue->setString(_filename); return _scValue; } else { diff --git a/engines/wintermute/base/base_script_holder.h b/engines/wintermute/base/base_script_holder.h index 0c3d7a1a70..5fd0dbec9c 100644 --- a/engines/wintermute/base/base_script_holder.h +++ b/engines/wintermute/base/base_script_holder.h @@ -59,7 +59,7 @@ public: BaseArray _scripts; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_scriptable.cpp b/engines/wintermute/base/base_scriptable.cpp index 143934402b..a2dd8b00e7 100644 --- a/engines/wintermute/base/base_scriptable.cpp +++ b/engines/wintermute/base/base_scriptable.cpp @@ -76,12 +76,12 @@ bool BaseScriptable::scCallMethod(ScScript *script, ScStack *stack, ScStack *thi ////////////////////////////////////////////////////////////////////////// -ScValue *BaseScriptable::scGetProperty(const char *name) { +ScValue *BaseScriptable::scGetProperty(const Common::String &name) { if (!_scProp) { _scProp = new ScValue(_gameRef); } if (_scProp) { - return _scProp->getProp(name); + return _scProp->getProp(name.c_str()); // TODO: Change to Common::String } else { return NULL; } diff --git a/engines/wintermute/base/base_scriptable.h b/engines/wintermute/base/base_scriptable.h index b006e6e07c..fbe14fc299 100644 --- a/engines/wintermute/base/base_scriptable.h +++ b/engines/wintermute/base/base_scriptable.h @@ -50,7 +50,7 @@ public: // high level scripting interface virtual bool canHandleMethod(const char *eventMethod); virtual bool scSetProperty(const char *name, ScValue *value); - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); virtual void *scToMemBuffer(); diff --git a/engines/wintermute/base/base_sprite.cpp b/engines/wintermute/base/base_sprite.cpp index 0baa25af22..468af1bd75 100644 --- a/engines/wintermute/base/base_sprite.cpp +++ b/engines/wintermute/base/base_sprite.cpp @@ -693,13 +693,13 @@ bool BaseSprite::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSta ////////////////////////////////////////////////////////////////////////// -ScValue *BaseSprite::scGetProperty(const char *name) { +ScValue *BaseSprite::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("sprite"); return _scValue; } @@ -707,7 +707,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // NumFrames (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumFrames") == 0) { + else if (name == "NumFrames") { _scValue->setInt(_frames.size()); return _scValue; } @@ -715,7 +715,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // CurrentFrame ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "CurrentFrame") == 0) { + else if (name == "CurrentFrame") { _scValue->setInt(_currentFrame); return _scValue; } @@ -723,7 +723,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PixelPerfect ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PixelPerfect") == 0) { + else if (name == "PixelPerfect") { _scValue->setBool(_precise); return _scValue; } @@ -731,7 +731,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Looping ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Looping") == 0) { + else if (name == "Looping") { _scValue->setBool(_looping); return _scValue; } @@ -739,7 +739,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Owner (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Owner") == 0) { + else if (name == "Owner") { if (_owner == NULL) { _scValue->setNULL(); } else { @@ -751,7 +751,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Finished (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Finished") == 0) { + else if (name == "Finished") { _scValue->setBool(_finished); return _scValue; } @@ -759,7 +759,7 @@ ScValue *BaseSprite::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Paused (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Paused") == 0) { + else if (name == "Paused") { _scValue->setBool(_paused); return _scValue; } else { diff --git a/engines/wintermute/base/base_sprite.h b/engines/wintermute/base/base_sprite.h index cef874b254..1d244c3a52 100644 --- a/engines/wintermute/base/base_sprite.h +++ b/engines/wintermute/base/base_sprite.h @@ -64,7 +64,7 @@ public: bool saveAsText(BaseDynamicBuffer *buffer, int indent); // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/base_sub_frame.cpp b/engines/wintermute/base/base_sub_frame.cpp index fd7ee50eda..77cc522ae7 100644 --- a/engines/wintermute/base/base_sub_frame.cpp +++ b/engines/wintermute/base/base_sub_frame.cpp @@ -446,7 +446,7 @@ bool BaseSubFrame::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisS ////////////////////////////////////////////////////////////////////////// -ScValue *BaseSubFrame::scGetProperty(const char *name) { +ScValue *BaseSubFrame::scGetProperty(const Common::String &name) { if (!_scValue) { _scValue = new ScValue(_gameRef); } @@ -455,7 +455,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("subframe"); return _scValue; } @@ -463,7 +463,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AlphaColor ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaColor") == 0) { + else if (name == "AlphaColor") { _scValue->setInt((int)_alpha); return _scValue; @@ -472,7 +472,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TransparentColor (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TransparentColor") == 0) { + else if (name == "TransparentColor") { _scValue->setInt((int)_transparent); return _scValue; } @@ -480,7 +480,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Is2DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is2DOnly") == 0) { + else if (name == "Is2DOnly") { _scValue->setBool(_2DOnly); return _scValue; } @@ -488,7 +488,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Is3DOnly ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Is3DOnly") == 0) { + else if (name == "Is3DOnly") { _scValue->setBool(_3DOnly); return _scValue; } @@ -496,7 +496,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MirrorX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorX") == 0) { + else if (name == "MirrorX") { _scValue->setBool(_mirrorX); return _scValue; } @@ -504,7 +504,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MirrorY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MirrorY") == 0) { + else if (name == "MirrorY") { _scValue->setBool(_mirrorY); return _scValue; } @@ -512,7 +512,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Decoration ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Decoration") == 0) { + else if (name == "Decoration") { _scValue->setBool(_decoration); return _scValue; } @@ -520,7 +520,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // HotspotX ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotX") == 0) { + else if (name == "HotspotX") { _scValue->setInt(_hotspotX); return _scValue; } @@ -528,7 +528,7 @@ ScValue *BaseSubFrame::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // HotspotY ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "HotspotY") == 0) { + else if (name == "HotspotY") { _scValue->setInt(_hotspotY); return _scValue; } else { diff --git a/engines/wintermute/base/base_sub_frame.h b/engines/wintermute/base/base_sub_frame.h index 0be77c544a..c173ae69d1 100644 --- a/engines/wintermute/base/base_sub_frame.h +++ b/engines/wintermute/base/base_sub_frame.h @@ -81,7 +81,7 @@ public: BaseSurface *_surface; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/particles/part_emitter.cpp b/engines/wintermute/base/particles/part_emitter.cpp index 4e3fc2239e..bab4d4609e 100644 --- a/engines/wintermute/base/particles/part_emitter.cpp +++ b/engines/wintermute/base/particles/part_emitter.cpp @@ -604,41 +604,41 @@ bool PartEmitter::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt } ////////////////////////////////////////////////////////////////////////// -ScValue *PartEmitter::scGetProperty(const char *name) { +ScValue *PartEmitter::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("particle-emitter"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // X ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "X") == 0) { + else if (name == "X") { _scValue->setInt(_posX); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Y ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Y") == 0) { + else if (name == "Y") { _scValue->setInt(_posY); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Width ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Width") == 0) { + else if (name == "Width") { _scValue->setInt(_width); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Height ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Height") == 0) { + else if (name == "Height") { _scValue->setInt(_height); return _scValue; } @@ -646,21 +646,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Scale1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale1") == 0) { + else if (name == "Scale1") { _scValue->setFloat(_scale1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Scale2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Scale2") == 0) { + else if (name == "Scale2") { _scValue->setFloat(_scale2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ScaleZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ScaleZBased") == 0) { + else if (name == "ScaleZBased") { _scValue->setBool(_scaleZBased); return _scValue; } @@ -668,21 +668,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Velocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity1") == 0) { + else if (name == "Velocity1") { _scValue->setFloat(_velocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Velocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Velocity2") == 0) { + else if (name == "Velocity2") { _scValue->setFloat(_velocity2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // VelocityZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "VelocityZBased") == 0) { + else if (name == "VelocityZBased") { _scValue->setBool(_velocityZBased); return _scValue; } @@ -690,21 +690,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // LifeTime1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime1") == 0) { + else if (name == "LifeTime1") { _scValue->setInt(_lifeTime1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTime2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTime2") == 0) { + else if (name == "LifeTime2") { _scValue->setInt(_lifeTime2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // LifeTimeZBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "LifeTimeZBased") == 0) { + else if (name == "LifeTimeZBased") { _scValue->setBool(_lifeTimeZBased); return _scValue; } @@ -712,14 +712,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Angle1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle1") == 0) { + else if (name == "Angle1") { _scValue->setInt(_angle1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Angle2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Angle2") == 0) { + else if (name == "Angle2") { _scValue->setInt(_angle2); return _scValue; } @@ -727,14 +727,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AngVelocity1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity1") == 0) { + else if (name == "AngVelocity1") { _scValue->setFloat(_angVelocity1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AngVelocity2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AngVelocity2") == 0) { + else if (name == "AngVelocity2") { _scValue->setFloat(_angVelocity2); return _scValue; } @@ -742,14 +742,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Rotation1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation1") == 0) { + else if (name == "Rotation1") { _scValue->setFloat(_rotation1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Rotation2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Rotation2") == 0) { + else if (name == "Rotation2") { _scValue->setFloat(_rotation2); return _scValue; } @@ -757,21 +757,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Alpha1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha1") == 0) { + else if (name == "Alpha1") { _scValue->setInt(_alpha1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Alpha2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Alpha2") == 0) { + else if (name == "Alpha2") { _scValue->setInt(_alpha2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // AlphaTimeBased ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AlphaTimeBased") == 0) { + else if (name == "AlphaTimeBased") { _scValue->setBool(_alphaTimeBased); return _scValue; } @@ -779,14 +779,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // MaxParticles ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxParticles") == 0) { + else if (name == "MaxParticles") { _scValue->setInt(_maxParticles); return _scValue; } ////////////////////////////////////////////////////////////////////////// // NumLiveParticles (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "NumLiveParticles") == 0) { + else if (name == "NumLiveParticles") { int numAlive = 0; for (uint32 i = 0; i < _particles.size(); i++) { if (_particles[i] && !_particles[i]->_isDead) { @@ -800,21 +800,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // GenerationInterval ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationInterval") == 0) { + else if (name == "GenerationInterval") { _scValue->setInt(_genInterval); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GenerationAmount ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GenerationAmount") == 0) { + else if (name == "GenerationAmount") { _scValue->setInt(_genAmount); return _scValue; } ////////////////////////////////////////////////////////////////////////// // MaxBatches ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "MaxBatches") == 0) { + else if (name == "MaxBatches") { _scValue->setInt(_maxBatches); return _scValue; } @@ -822,14 +822,14 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // FadeInTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeInTime") == 0) { + else if (name == "FadeInTime") { _scValue->setInt(_fadeInTime); return _scValue; } ////////////////////////////////////////////////////////////////////////// // FadeOutTime ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "FadeOutTime") == 0) { + else if (name == "FadeOutTime") { _scValue->setInt(_fadeOutTime); return _scValue; } @@ -837,21 +837,21 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // GrowthRate1 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate1") == 0) { + else if (name == "GrowthRate1") { _scValue->setFloat(_growthRate1); return _scValue; } ////////////////////////////////////////////////////////////////////////// // GrowthRate2 ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "GrowthRate2") == 0) { + else if (name == "GrowthRate2") { _scValue->setFloat(_growthRate2); return _scValue; } ////////////////////////////////////////////////////////////////////////// // ExponentialGrowth ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "ExponentialGrowth") == 0) { + else if (name == "ExponentialGrowth") { _scValue->setBool(_exponentialGrowth); return _scValue; } @@ -859,7 +859,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // UseRegion ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "UseRegion") == 0) { + else if (name == "UseRegion") { _scValue->setBool(_useRegion); return _scValue; } @@ -867,7 +867,7 @@ ScValue *PartEmitter::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // EmitEvent ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "EmitEvent") == 0) { + else if (name == "EmitEvent") { if (!_emitEvent) { _scValue->setNULL(); } else { diff --git a/engines/wintermute/base/particles/part_emitter.h b/engines/wintermute/base/particles/part_emitter.h index 9a35cd9bbc..f2c8f139f1 100644 --- a/engines/wintermute/base/particles/part_emitter.h +++ b/engines/wintermute/base/particles/part_emitter.h @@ -63,7 +63,7 @@ public: BaseArray _forces; // scripting interface - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scSetProperty(const char *name, ScValue *value); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); virtual const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_array.cpp b/engines/wintermute/base/scriptables/script_ext_array.cpp index 5ed07f0da6..613cbd0758 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.cpp +++ b/engines/wintermute/base/scriptables/script_ext_array.cpp @@ -140,13 +140,13 @@ bool SXArray::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXArray::scGetProperty(const char *name) { +ScValue *SXArray::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("array"); return _scValue; } @@ -154,7 +154,7 @@ ScValue *SXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Length ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { _scValue->setInt(_length); return _scValue; } @@ -164,7 +164,7 @@ ScValue *SXArray::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// else { char paramName[20]; - if (validNumber(name, paramName)) { + if (validNumber(name.c_str(), paramName)) { // TODO: Change to Common::String return _values->getProp(paramName); } else { return _scValue; diff --git a/engines/wintermute/base/scriptables/script_ext_array.h b/engines/wintermute/base/scriptables/script_ext_array.h index d9805ef94f..284c547a27 100644 --- a/engines/wintermute/base/scriptables/script_ext_array.h +++ b/engines/wintermute/base/scriptables/script_ext_array.h @@ -41,7 +41,7 @@ public: SXArray(BaseGame *inGame, ScStack *stack); SXArray(BaseGame *inGame); virtual ~SXArray(); - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_date.cpp b/engines/wintermute/base/scriptables/script_ext_date.cpp index 11eead3b9c..5aa069d0b2 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.cpp +++ b/engines/wintermute/base/scriptables/script_ext_date.cpp @@ -203,13 +203,13 @@ bool SXDate::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXDate::scGetProperty(const char *name) { +ScValue *SXDate::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("date"); return _scValue; } else { @@ -224,7 +224,7 @@ bool SXDate::scSetProperty(const char *name, ScValue *value) { ////////////////////////////////////////////////////////////////////////// // Name ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Name")==0){ + if (name == "Name")==0){ setName(value->getString()); return STATUS_OK; } diff --git a/engines/wintermute/base/scriptables/script_ext_date.h b/engines/wintermute/base/scriptables/script_ext_date.h index f6f04dd7e6..062b7c55c7 100644 --- a/engines/wintermute/base/scriptables/script_ext_date.h +++ b/engines/wintermute/base/scriptables/script_ext_date.h @@ -40,7 +40,7 @@ public: DECLARE_PERSISTENT(SXDate, BaseScriptable) SXDate(BaseGame *inGame, ScStack *Stack); virtual ~SXDate(); - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_file.cpp b/engines/wintermute/base/scriptables/script_ext_file.cpp index 2dc385b015..a1d39c5d0a 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.cpp +++ b/engines/wintermute/base/scriptables/script_ext_file.cpp @@ -640,13 +640,13 @@ bool SXFile::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXFile::scGetProperty(const char *name) { +ScValue *SXFile::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("file"); return _scValue; } @@ -654,7 +654,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Filename (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Filename") == 0) { + if (name == "Filename") { _scValue->setString(_filename); return _scValue; } @@ -662,7 +662,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Position (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Position") == 0) { + else if (name == "Position") { _scValue->setInt(getPos()); return _scValue; } @@ -670,7 +670,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { _scValue->setInt(getLength()); return _scValue; } @@ -678,7 +678,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // TextMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "TextMode") == 0) { + else if (name == "TextMode") { _scValue->setBool(_textMode); return _scValue; } @@ -686,7 +686,7 @@ ScValue *SXFile::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // AccessMode (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "AccessMode") == 0) { + else if (name == "AccessMode") { _scValue->setInt(_mode); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_file.h b/engines/wintermute/base/scriptables/script_ext_file.h index b91a53e695..f7c72fcfb3 100644 --- a/engines/wintermute/base/scriptables/script_ext_file.h +++ b/engines/wintermute/base/scriptables/script_ext_file.h @@ -40,7 +40,7 @@ class BaseFile; class SXFile : public BaseScriptable { public: DECLARE_PERSISTENT(SXFile, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_math.cpp b/engines/wintermute/base/scriptables/script_ext_math.cpp index 598b80cff3..d816fbec65 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.cpp +++ b/engines/wintermute/base/scriptables/script_ext_math.cpp @@ -250,13 +250,13 @@ bool SXMath::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, ////////////////////////////////////////////////////////////////////////// -ScValue *SXMath::scGetProperty(const char *name) { +ScValue *SXMath::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("math"); return _scValue; } @@ -264,7 +264,7 @@ ScValue *SXMath::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // PI ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "PI") == 0) { + else if (name == "PI") { _scValue->setFloat(M_PI); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_math.h b/engines/wintermute/base/scriptables/script_ext_math.h index f86d59fe7b..48c43ea7e8 100644 --- a/engines/wintermute/base/scriptables/script_ext_math.h +++ b/engines/wintermute/base/scriptables/script_ext_math.h @@ -39,7 +39,7 @@ public: DECLARE_PERSISTENT(SXMath, BaseScriptable) SXMath(BaseGame *inGame); virtual ~SXMath(); - virtual ScValue *scGetProperty(const char *name); + virtual ScValue *scGetProperty(const Common::String &name); virtual bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); private: diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp index 5ed9bd5313..8f05b7bff6 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.cpp @@ -447,13 +447,13 @@ bool SXMemBuffer::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisSt ////////////////////////////////////////////////////////////////////////// -ScValue *SXMemBuffer::scGetProperty(const char *name) { +ScValue *SXMemBuffer::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("membuffer"); return _scValue; } @@ -461,7 +461,7 @@ ScValue *SXMemBuffer::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Size (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Size") == 0) { + if (name == "Size") { _scValue->setInt(_size); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h index d2662b3036..1527a323dc 100644 --- a/engines/wintermute/base/scriptables/script_ext_mem_buffer.h +++ b/engines/wintermute/base/scriptables/script_ext_mem_buffer.h @@ -38,7 +38,7 @@ class SXMemBuffer : public BaseScriptable { public: virtual int scCompare(BaseScriptable *Val); DECLARE_PERSISTENT(SXMemBuffer, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); const char *scToString(); diff --git a/engines/wintermute/base/scriptables/script_ext_string.cpp b/engines/wintermute/base/scriptables/script_ext_string.cpp index 8d87a92dc1..5f7da1c2dd 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.cpp +++ b/engines/wintermute/base/scriptables/script_ext_string.cpp @@ -343,20 +343,20 @@ bool SXString::scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack ////////////////////////////////////////////////////////////////////////// -ScValue *SXString::scGetProperty(const char *name) { +ScValue *SXString::scGetProperty(const Common::String &name) { _scValue->setNULL(); ////////////////////////////////////////////////////////////////////////// // Type (RO) ////////////////////////////////////////////////////////////////////////// - if (strcmp(name, "Type") == 0) { + if (name == "Type") { _scValue->setString("string"); return _scValue; } ////////////////////////////////////////////////////////////////////////// // Length (RO) ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Length") == 0) { + else if (name == "Length") { if (_gameRef->_textEncoding == TEXT_UTF8) { WideString wstr = StringUtil::utf8ToWide(_string); _scValue->setInt(wstr.size()); @@ -369,7 +369,7 @@ ScValue *SXString::scGetProperty(const char *name) { ////////////////////////////////////////////////////////////////////////// // Capacity ////////////////////////////////////////////////////////////////////////// - else if (strcmp(name, "Capacity") == 0) { + else if (name == "Capacity") { _scValue->setInt(_capacity); return _scValue; } else { diff --git a/engines/wintermute/base/scriptables/script_ext_string.h b/engines/wintermute/base/scriptables/script_ext_string.h index 255b9c57eb..00bffab3a9 100644 --- a/engines/wintermute/base/scriptables/script_ext_string.h +++ b/engines/wintermute/base/scriptables/script_ext_string.h @@ -38,7 +38,7 @@ class SXString : public BaseScriptable { public: virtual int scCompare(BaseScriptable *Val); DECLARE_PERSISTENT(SXString, BaseScriptable) - ScValue *scGetProperty(const char *name); + ScValue *scGetProperty(const Common::String &name); bool scSetProperty(const char *name, ScValue *value); bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name); void scSetString(const char *val); -- cgit v1.2.3